From dd1f982bded5c9fd51175be9ce569ac9e97551c3 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Thu, 30 Apr 2015 17:40:35 +0200 Subject: [PATCH 001/250] Parse abstract keyword --- src/compiler/scanner.ts | 1 + src/compiler/types.ts | 24 +++++++++++++----------- src/compiler/utilities.ts | 2 ++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index f7224e619bbd9..94cb784ca8846 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -43,6 +43,7 @@ module ts { } let textToToken: Map = { + "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, "boolean": SyntaxKind.BooleanKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4799f31406369..1185b949e9cdd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -131,6 +131,7 @@ module ts { StaticKeyword, YieldKeyword, // Contextual keywords + AbstractKeyword, AsKeyword, AnyKeyword, BooleanKeyword, @@ -307,17 +308,18 @@ module ts { Private = 0x00000020, // Property/Method Protected = 0x00000040, // Property/Method Static = 0x00000080, // Property/Method - Default = 0x00000100, // Function/Class (export default declaration) - MultiLine = 0x00000200, // Multi-line array or object literal - Synthetic = 0x00000400, // Synthetic node (for full fidelity) - DeclarationFile = 0x00000800, // Node is a .d.ts file - Let = 0x00001000, // Variable declaration - Const = 0x00002000, // Variable declaration - OctalLiteral = 0x00004000, // Octal numeric literal - Namespace = 0x00008000, // Namespace declaration - ExportContext = 0x00010000, // Export context (initialized by binding) - - Modifier = Export | Ambient | Public | Private | Protected | Static | Default, + Abstract = 0x00000100, + Default = 0x00000200, // Function/Class (export default declaration) + MultiLine = 0x00000400, // Multi-line array or object literal + Synthetic = 0x00000800, // Synthetic node (for full fidelity) + DeclarationFile = 0x00001000, // Node is a .d.ts file + Let = 0x00002000, // Variable declaration + Const = 0x00004000, // Variable declaration + OctalLiteral = 0x00008000, // Octal numeric literal + Namespace = 0x00010000, // Namespace declaration + ExportContext = 0x00020000, // Export context (initialized by binding) + + Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5296f063a9470..7dd89e9d99ecb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1141,6 +1141,7 @@ module ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: + case SyntaxKind.AbstractKeyword: case SyntaxKind.ExportKeyword: case SyntaxKind.DeclareKeyword: case SyntaxKind.ConstKeyword: @@ -1626,6 +1627,7 @@ module ts { case SyntaxKind.PublicKeyword: return NodeFlags.Public; case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected; case SyntaxKind.PrivateKeyword: return NodeFlags.Private; + case SyntaxKind.AbstractKeyword: return NodeFlags.Abstract; case SyntaxKind.ExportKeyword: return NodeFlags.Export; case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient; case SyntaxKind.ConstKeyword: return NodeFlags.Const; From 0e72677fd2b2ad8414d193953939cc0b180eda05 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Thu, 30 Apr 2015 17:43:07 +0200 Subject: [PATCH 002/250] Accept baseline changes --- tests/baselines/reference/APISample_linter.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index cd2df23ffbf4f..d034b7ebd80d4 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - if (node.statement.kind !== 180 /* Block */) { + case 188 /* ForStatement */: + case 189 /* ForInStatement */: + case 187 /* WhileStatement */: + case 186 /* DoStatement */: + if (node.statement.kind !== 181 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 184 /* IfStatement */: + case 185 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 180 /* Block */) { + if (ifStatement.thenStatement.kind !== 181 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 180 /* Block */ && - ifStatement.elseStatement.kind !== 184 /* IfStatement */) { + ifStatement.elseStatement.kind !== 181 /* Block */ && + ifStatement.elseStatement.kind !== 185 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 170 /* BinaryExpression */: + case 171 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); From b42e447df8b5716561fe833d4c2a57dc4660cd5f Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Thu, 30 Apr 2015 17:51:16 +0200 Subject: [PATCH 003/250] Error on creating a new instance of an abstract class --- src/compiler/checker.ts | 5 +++++ src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 469ecf80c84fe..eecd469d5a025 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7084,6 +7084,11 @@ module ts { return resolveErrorCall(node); } + var valueDecl = (expressionType.symbol ? expressionType.symbol.valueDeclaration : undefined); + if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + } + // Technically, this signatures list may be incomplete. We are taking the apparent type, // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 98b5a170ae660..19c8e94534616 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -363,6 +363,7 @@ module ts { An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2502, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 60d8e8e651507..68ca54990b913 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1440,6 +1440,10 @@ "category": "Error", "code": 2501 }, + "Cannot create an instance of the abstract class '{0}'": { + "category": "Error", + "code": 2502 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From 3aeae55fc3e7733a2fc667d90ee26010b4bbc46c Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Thu, 30 Apr 2015 17:53:39 +0200 Subject: [PATCH 004/250] Output abstract keyword in declaration files (for classes) --- src/compiler/declarationEmitter.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 5c705f1819045..3082c12e2d628 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -908,6 +908,10 @@ module ts { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } + write("class "); writeTextOfNode(currentSourceFile, node.name); let prevEnclosingDeclaration = enclosingDeclaration; From 9436934aa58a7b172d5f5df4ef0e76fecaa9e944 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Thu, 30 Apr 2015 18:34:06 +0200 Subject: [PATCH 005/250] Added test for abstract-classes --- tests/cases/compiler/abstractClass1.ts | 36 +++++++++++++++++++ .../compiler/abstractClassIdentifierName.ts | 4 +++ .../compiler/abstractIdentifierNameStrict.ts | 6 ++++ .../abstractInterfaceIdentifierName.ts | 4 +++ 4 files changed, 50 insertions(+) create mode 100644 tests/cases/compiler/abstractClass1.ts create mode 100644 tests/cases/compiler/abstractClassIdentifierName.ts create mode 100644 tests/cases/compiler/abstractIdentifierNameStrict.ts create mode 100644 tests/cases/compiler/abstractInterfaceIdentifierName.ts diff --git a/tests/cases/compiler/abstractClass1.ts b/tests/cases/compiler/abstractClass1.ts new file mode 100644 index 0000000000000..1590ee907f0d9 --- /dev/null +++ b/tests/cases/compiler/abstractClass1.ts @@ -0,0 +1,36 @@ +// @declaration: true + +abstract class Foo { + constructor(f: any) { } + public static bar(): void { } + + public empty() { } +} + +class Bar extends Foo { + constructor(f: any) { + super(f); + } +} + +var a = new Foo(1); // Error +var b = new Foo(); // Error because of invalid constructor arguments + +module baz { + export abstract class Qux { + } + export class Quz extends Qux { + } +} + +new baz.Qux(); + +// Valid +var c = new Bar(1); +c.empty(); + +// Calling a static method on a abstract class is valid +Foo.bar(); + +var Copy = Foo; +new Copy(); diff --git a/tests/cases/compiler/abstractClassIdentifierName.ts b/tests/cases/compiler/abstractClassIdentifierName.ts new file mode 100644 index 0000000000000..09d07f16fb895 --- /dev/null +++ b/tests/cases/compiler/abstractClassIdentifierName.ts @@ -0,0 +1,4 @@ +class abstract { + + abstract(): void { } +} diff --git a/tests/cases/compiler/abstractIdentifierNameStrict.ts b/tests/cases/compiler/abstractIdentifierNameStrict.ts new file mode 100644 index 0000000000000..c75fbf4304324 --- /dev/null +++ b/tests/cases/compiler/abstractIdentifierNameStrict.ts @@ -0,0 +1,6 @@ +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} \ No newline at end of file diff --git a/tests/cases/compiler/abstractInterfaceIdentifierName.ts b/tests/cases/compiler/abstractInterfaceIdentifierName.ts new file mode 100644 index 0000000000000..c7bdc100ccfb6 --- /dev/null +++ b/tests/cases/compiler/abstractInterfaceIdentifierName.ts @@ -0,0 +1,4 @@ + +interface abstract { + abstract(): void; +} From 0ed7898f9f4cde41743c1cbf82040cf102406d0c Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Thu, 30 Apr 2015 18:35:57 +0200 Subject: [PATCH 006/250] Accepted baselines --- .../reference/abstractClass1.errors.txt | 57 ++++++++++ tests/baselines/reference/abstractClass1.js | 107 ++++++++++++++++++ .../reference/abstractClassIdentifierName.js | 14 +++ .../abstractClassIdentifierName.symbols | 8 ++ .../abstractClassIdentifierName.types | 8 ++ .../reference/abstractIdentifierNameStrict.js | 14 +++ .../abstractIdentifierNameStrict.symbols | 11 ++ .../abstractIdentifierNameStrict.types | 15 +++ .../abstractInterfaceIdentifierName.js | 8 ++ .../abstractInterfaceIdentifierName.symbols | 9 ++ .../abstractInterfaceIdentifierName.types | 9 ++ 11 files changed, 260 insertions(+) create mode 100644 tests/baselines/reference/abstractClass1.errors.txt create mode 100644 tests/baselines/reference/abstractClass1.js create mode 100644 tests/baselines/reference/abstractClassIdentifierName.js create mode 100644 tests/baselines/reference/abstractClassIdentifierName.symbols create mode 100644 tests/baselines/reference/abstractClassIdentifierName.types create mode 100644 tests/baselines/reference/abstractIdentifierNameStrict.js create mode 100644 tests/baselines/reference/abstractIdentifierNameStrict.symbols create mode 100644 tests/baselines/reference/abstractIdentifierNameStrict.types create mode 100644 tests/baselines/reference/abstractInterfaceIdentifierName.js create mode 100644 tests/baselines/reference/abstractInterfaceIdentifierName.symbols create mode 100644 tests/baselines/reference/abstractInterfaceIdentifierName.types diff --git a/tests/baselines/reference/abstractClass1.errors.txt b/tests/baselines/reference/abstractClass1.errors.txt new file mode 100644 index 0000000000000..5892f54266317 --- /dev/null +++ b/tests/baselines/reference/abstractClass1.errors.txt @@ -0,0 +1,57 @@ +tests/cases/compiler/abstractClass1.ts(15,9): error TS2502: Cannot create an instance of the abstract class 'Foo' +tests/cases/compiler/abstractClass1.ts(16,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/abstractClass1.ts(16,9): error TS2502: Cannot create an instance of the abstract class 'Foo' +tests/cases/compiler/abstractClass1.ts(25,1): error TS2502: Cannot create an instance of the abstract class 'Qux' +tests/cases/compiler/abstractClass1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/abstractClass1.ts(35,1): error TS2502: Cannot create an instance of the abstract class 'Foo' + + +==== tests/cases/compiler/abstractClass1.ts (6 errors) ==== + + abstract class Foo { + constructor(f: any) { } + public static bar(): void { } + + public empty() { } + } + + class Bar extends Foo { + constructor(f: any) { + super(f); + } + } + + var a = new Foo(1); // Error + ~~~~~~~~~~ +!!! error TS2502: Cannot create an instance of the abstract class 'Foo' + var b = new Foo(); // Error because of invalid constructor arguments + ~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~~~~~ +!!! error TS2502: Cannot create an instance of the abstract class 'Foo' + + module baz { + export abstract class Qux { + } + export class Quz extends Qux { + } + } + + new baz.Qux(); + ~~~~~~~~~~~~~ +!!! error TS2502: Cannot create an instance of the abstract class 'Qux' + + // Valid + var c = new Bar(1); + c.empty(); + + // Calling a static method on a abstract class is valid + Foo.bar(); + + var Copy = Foo; + new Copy(); + ~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~~~~~~ +!!! error TS2502: Cannot create an instance of the abstract class 'Foo' + \ No newline at end of file diff --git a/tests/baselines/reference/abstractClass1.js b/tests/baselines/reference/abstractClass1.js new file mode 100644 index 0000000000000..4cb36d91ae1dd --- /dev/null +++ b/tests/baselines/reference/abstractClass1.js @@ -0,0 +1,107 @@ +//// [abstractClass1.ts] + +abstract class Foo { + constructor(f: any) { } + public static bar(): void { } + + public empty() { } +} + +class Bar extends Foo { + constructor(f: any) { + super(f); + } +} + +var a = new Foo(1); // Error +var b = new Foo(); // Error because of invalid constructor arguments + +module baz { + export abstract class Qux { + } + export class Quz extends Qux { + } +} + +new baz.Qux(); + +// Valid +var c = new Bar(1); +c.empty(); + +// Calling a static method on a abstract class is valid +Foo.bar(); + +var Copy = Foo; +new Copy(); + + +//// [abstractClass1.js] +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Foo = (function () { + function Foo(f) { + } + Foo.bar = function () { }; + Foo.prototype.empty = function () { }; + return Foo; +})(); +var Bar = (function (_super) { + __extends(Bar, _super); + function Bar(f) { + _super.call(this, f); + } + return Bar; +})(Foo); +var a = new Foo(1); // Error +var b = new Foo(); // Error because of invalid constructor arguments +var baz; +(function (baz) { + var Qux = (function () { + function Qux() { + } + return Qux; + })(); + baz.Qux = Qux; + var Quz = (function (_super) { + __extends(Quz, _super); + function Quz() { + _super.apply(this, arguments); + } + return Quz; + })(Qux); + baz.Quz = Quz; +})(baz || (baz = {})); +new baz.Qux(); +// Valid +var c = new Bar(1); +c.empty(); +// Calling a static method on a abstract class is valid +Foo.bar(); +var Copy = Foo; +new Copy(); + + +//// [abstractClass1.d.ts] +declare abstract class Foo { + constructor(f: any); + static bar(): void; + empty(): void; +} +declare class Bar extends Foo { + constructor(f: any); +} +declare var a: Foo; +declare var b: any; +declare module baz { + abstract class Qux { + } + class Quz extends Qux { + } +} +declare var c: Bar; +declare var Copy: typeof Foo; diff --git a/tests/baselines/reference/abstractClassIdentifierName.js b/tests/baselines/reference/abstractClassIdentifierName.js new file mode 100644 index 0000000000000..71827d2cb5bd8 --- /dev/null +++ b/tests/baselines/reference/abstractClassIdentifierName.js @@ -0,0 +1,14 @@ +//// [abstractClassIdentifierName.ts] +class abstract { + + abstract(): void { } +} + + +//// [abstractClassIdentifierName.js] +var abstract = (function () { + function abstract() { + } + abstract.prototype.abstract = function () { }; + return abstract; +})(); diff --git a/tests/baselines/reference/abstractClassIdentifierName.symbols b/tests/baselines/reference/abstractClassIdentifierName.symbols new file mode 100644 index 0000000000000..41c46649c435e --- /dev/null +++ b/tests/baselines/reference/abstractClassIdentifierName.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/abstractClassIdentifierName.ts === +class abstract { +>abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 0)) + + abstract(): void { } +>abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 16)) +} + diff --git a/tests/baselines/reference/abstractClassIdentifierName.types b/tests/baselines/reference/abstractClassIdentifierName.types new file mode 100644 index 0000000000000..ef152979f13a0 --- /dev/null +++ b/tests/baselines/reference/abstractClassIdentifierName.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/abstractClassIdentifierName.ts === +class abstract { +>abstract : abstract + + abstract(): void { } +>abstract : () => void +} + diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.js b/tests/baselines/reference/abstractIdentifierNameStrict.js new file mode 100644 index 0000000000000..8544019c4d1f7 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.js @@ -0,0 +1,14 @@ +//// [abstractIdentifierNameStrict.ts] +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} + +//// [abstractIdentifierNameStrict.js] +var abstract = true; +function foo() { + "use strict"; + var abstract = true; +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.symbols b/tests/baselines/reference/abstractIdentifierNameStrict.symbols new file mode 100644 index 0000000000000..f983ddccdc92b --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 0, 3)) + +function foo() { +>foo : Symbol(foo, Decl(abstractIdentifierNameStrict.ts, 0, 20)) + + "use strict"; + var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 4, 7)) +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.types b/tests/baselines/reference/abstractIdentifierNameStrict.types new file mode 100644 index 0000000000000..e43207007e03a --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : boolean +>true : boolean + +function foo() { +>foo : () => void + + "use strict"; +>"use strict" : string + + var abstract = true; +>abstract : boolean +>true : boolean +} diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.js b/tests/baselines/reference/abstractInterfaceIdentifierName.js new file mode 100644 index 0000000000000..c3913ae5cdfaa --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.js @@ -0,0 +1,8 @@ +//// [abstractInterfaceIdentifierName.ts] + +interface abstract { + abstract(): void; +} + + +//// [abstractInterfaceIdentifierName.js] diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.symbols b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols new file mode 100644 index 0000000000000..db2ad0aceba69 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 0, 0)) + + abstract(): void; +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 1, 20)) +} + diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.types b/tests/baselines/reference/abstractInterfaceIdentifierName.types new file mode 100644 index 0000000000000..3a5c6024f4ca7 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : abstract + + abstract(): void; +>abstract : () => void +} + From d19a200750ab16720d0a383b3cc1c85d3c38ddb4 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 5 May 2015 17:57:21 -0700 Subject: [PATCH 007/250] Added types, scan, parse, and check for async functions --- src/compiler/checker.ts | 447 +++++++++++++++++- .../diagnosticInformationMap.generated.ts | 29 +- src/compiler/diagnosticMessages.json | 101 +++- src/compiler/parser.ts | 425 +++++++++++------ src/compiler/scanner.ts | 2 + src/compiler/types.ts | 52 +- src/compiler/utilities.ts | 19 + src/lib/core.d.ts | 12 + src/lib/es6.d.ts | 10 - 9 files changed, 905 insertions(+), 192 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04766f22c4ecf..13f527bd9f8ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -89,7 +89,7 @@ module ts { let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null"); let unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); let resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__"); - + let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -101,6 +101,8 @@ module ts { let globalArraySymbol: Symbol; let globalESSymbolConstructorSymbol: Symbol; + + let getGlobalPromiseSymbol: () => Symbol; let globalObjectType: ObjectType; let globalFunctionType: ObjectType; @@ -118,6 +120,11 @@ module ts { let getGlobalParameterDecoratorType: () => ObjectType; let getGlobalPropertyDecoratorType: () => ObjectType; let getGlobalMethodDecoratorType: () => ObjectType; + let getGlobalPromiseType: () => ObjectType; + let getGlobalPromiseLikeType: () => ObjectType; + let getInstantiatedGlobalPromiseLikeType: () => ObjectType; + let getGlobalPromiseConstructorLikeType: () => ObjectType; + let getGlobalThenableType: () => ObjectType; let tupleTypes: Map = {}; let unionTypes: Map = {}; @@ -125,11 +132,14 @@ module ts { let emitExtends = false; let emitDecorate = false; let emitParam = false; + let emitAwaiter = false; + let emitGenerator = false; let mergedSymbols: Symbol[] = []; let symbolLinks: SymbolLinks[] = []; let nodeLinks: NodeLinks[] = []; let potentialThisCollisions: Node[] = []; + var potentialArgumentsCollisions: Node[] = []; let diagnostics = createDiagnosticCollection(); @@ -5146,9 +5156,11 @@ module ts { case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.DeleteExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.YieldExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.SpreadElementExpression: case SyntaxKind.Block: @@ -5406,8 +5418,14 @@ module ts { // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && getContainingFunction(node).kind === SyntaxKind.ArrowFunction && languageVersion < ScriptTarget.ES6) { - error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + let container = getContainingFunction(node); + if (symbol === argumentsSymbol) { + if (container.kind === SyntaxKind.ArrowFunction && languageVersion < ScriptTarget.ES6) { + error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + else if (node.parserContextFlags & ParserContextFlags.Await) { + captureLexicalArguments(node, container); + } } if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -5416,6 +5434,7 @@ module ts { checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedArgumentsVariable(node, node); checkBlockScopedBindingCapturedInLoop(node, symbol); return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); @@ -5497,6 +5516,11 @@ module ts { // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES6); } + + if (node.parserContextFlags & ParserContextFlags.Await) { + // if 'this' is part of an async function, we will need to capture 'this' + needToCaptureLexicalThis = true; + } switch (container.kind) { case SyntaxKind.ModuleDeclaration: @@ -5537,6 +5561,14 @@ module ts { return anyType; } + function captureLexicalArguments(node: Node, container: Node): void { + if (node.parent.kind !== SyntaxKind.Parameter) { + getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; + } + + getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; + } + function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean { for (let n = node; n && n !== constructorDecl; n = n.parent) { if (n.kind === SyntaxKind.Parameter) { @@ -7220,22 +7252,42 @@ module ts { links.type = instantiateType(getTypeOfSymbol(lastOrUndefined(context.parameters)), mapper); } } + + function createPromiseType(promisedType: Type, location: Node): Type { + // creates a `Promise` type where `T` is the promisedType argument + let globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + + error(location, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { let contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + + let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = checkExpressionCached(func.body, contextualMapper); + type = isAsync + ? checkAwaitedExpressionCached(func.body, contextualMapper) + : checkExpressionCached(func.body, contextualMapper); } else { // Aggregate the types of expressions within all the return statements. let types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); if (types.length === 0) { - return voidType; + return isAsync + ? createPromiseType(voidType, func) + : voidType; } + // When return statements are contextually typed we allow the return type to be a union type. Otherwise we require the // return expressions to have a best common supertype. type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); @@ -7247,17 +7299,23 @@ module ts { if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + + let widenedType = getWidenedType(type); + return isAsync + ? createPromiseType(widenedType, func) + : type; } /// Returns a set of types relating to every return expression relating to a function block. - function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper): Type[] { + function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper, isAsync?: boolean): Type[] { let aggregatedTypes: Type[] = []; forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { - let type = checkExpressionCached(expr, contextualMapper); + let type = isAsync + ? checkAwaitedExpressionCached(expr, contextualMapper) + : checkExpressionCached(expr, contextualMapper); if (!contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -7327,6 +7385,12 @@ module ts { if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + let links = getNodeLinks(node); let type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so @@ -7357,6 +7421,7 @@ module ts { if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { checkCollisionWithCapturedSuperVariable(node, (node).name); checkCollisionWithCapturedThisVariable(node, (node).name); + checkCollisionWithCapturedArgumentsVariable(node, (node).name); } return type; @@ -7364,8 +7429,21 @@ module ts { function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + + let isAsync = isAsyncFunctionLike(node); + let returnType = node.type && getTypeFromTypeNode(node.type); + let promisedType: Type; + if (returnType && isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the concise body against the promised type of + // its return type annotation. + promisedType = checkAsyncFunctionReturnType(node, returnType); + } + + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { @@ -7374,8 +7452,11 @@ module ts { } else { let exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); + if (returnType) { + checkTypeAssignableTo( + isAsync ? getAwaitedType(exprType) : exprType, + isAsync ? promisedType : returnType, + node.body); } checkFunctionExpressionBodies(node.body); } @@ -7490,6 +7571,22 @@ module ts { return undefinedType; } + function checkAwaitExpression(node: AwaitExpression): Type { + // Grammar checking + if (!(node.parserContextFlags & ParserContextFlags.Await)) { + var parameter = getContainingParameter(node); + if (parameter && parameter.parserContextFlags & ParserContextFlags.Await) { + grammarErrorAfterFirstToken(node, Diagnostics._0_expression_is_not_allowed_in_an_initializer, "await"); + } + else { + grammarErrorOnFirstToken(node, Diagnostics.await_expression_must_be_contained_within_an_async_function); + } + } + + var operandType = checkExpression(node.expression); + return getAwaitedType(operandType); + } + function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { // Grammar checking // The identifier eval or arguments may not appear as the LeftHandSideExpression of an @@ -7897,7 +7994,13 @@ module ts { function checkYieldExpression(node: YieldExpression): void { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Yield)) { - grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); + let parameter = getContainingParameter(node); + if (parameter && (parameter.parserContextFlags & ParserContextFlags.GeneratorParameter)) { + grammarErrorAfterFirstToken(node, Diagnostics._0_expression_is_not_allowed_in_an_initializer, "yield"); + } + else { + grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); + } } else { grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported); @@ -7931,6 +8034,15 @@ module ts { node.contextualType = saveContextualType; return result; } + + function checkAwaitedExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { + let links = getNodeLinks(node); + if (!links.resolvedAwaitedType) { + links.resolvedAwaitedType = getAwaitedType(checkExpressionCached(node, contextualMapper)); + } + + return links.resolvedAwaitedType; + } function checkExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { let links = getNodeLinks(node); @@ -8078,6 +8190,8 @@ module ts { return checkDeleteExpression(node); case SyntaxKind.VoidExpression: return checkVoidExpression(node); + case SyntaxKind.AwaitExpression: + return checkAwaitExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PostfixUnaryExpression: @@ -8166,6 +8280,7 @@ module ts { } if (produceDiagnostics) { + checkCollisionWithAwaiterVariablesInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -8177,6 +8292,22 @@ module ts { break; } } + if (isAsyncFunctionLike(node)) { + var promiseConstructor = getPromiseConstructor(node); + if (promiseConstructor) { + var promiseIdentifier = getFirstIdentifier(promiseConstructor); + var promiseName = promiseIdentifier.text; + var typeSymbol = resolveName(node, promiseName, SymbolFlags.Type | SymbolFlags.Module, undefined, undefined); + var valueSymbol = resolveName(node, promiseName, SymbolFlags.Value, undefined, undefined); + if (typeSymbol !== valueSymbol) { + var valueLinks = getNodeLinks(valueSymbol.valueDeclaration); + if (!(valueLinks.flags & NodeCheckFlags.PromiseCollision)) { + valueLinks.flags |= NodeCheckFlags.PromiseCollision; + error(valueSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseName, getTextOfNode(promiseConstructor)); + } + } + } + } } checkSpecializedSignatureDeclaration(node); @@ -8772,6 +8903,113 @@ module ts { } } + function getPromisedType(type: Type): Type { + // the "promised type" of a type is the type of the "value" argument of the "onfulfilled" callback. + let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType !== emptyObjectType && isTypeAssignableTo(type, globalPromiseLikeType)) { + let awaitedTypes: Type[] = []; + let thenProp = getPropertyOfType(type, "then"); + let thenType = getTypeOfSymbol(thenProp); + let thenSignatures = getSignaturesOfType(thenType, SignatureKind.Call); + for (let thenSignature of thenSignatures) { + thenSignature = getErasedSignature(thenSignature); + let onfulfilledParameterType = getTypeAtPosition(thenSignature, 0); + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); + for (let onfulfilledParameterSignature of onfulfilledParameterSignatures) { + let valueParameterType = getTypeAtPosition(onfulfilledParameterSignature, 0); + if (valueParameterType !== type) { + awaitedTypes.push(valueParameterType); + } + } + } + + return getUnionType(awaitedTypes); + } + + return emptyObjectType; + } + + function getAwaitedType(type: Type): Type { + // The "awaited type" of an expression is its "promised type" if the expression is a `Promise`; otherwise, it is the type of the expression. + + let promisedType = getPromisedType(type); + if (promisedType === emptyObjectType) { + return type; + } + + // if we have a bad actor in the form of a promise whose promised type is the same promise, return the empty type. + // if this were the actual case in the JavaScript, this Promise would never resolve. + if (promisedType === type) { + return emptyObjectType; + } + + // unwrap any nested promises + let seen: boolean[]; + while (true) { + let nestedPromisedType = getPromisedType(promisedType); + if (nestedPromisedType === emptyObjectType) { + // if this could not be unwrapped further, return the promised type + return promisedType; + } + + if (!seen) { + // `seen` keeps track of types we've tried to await to avoid cycles + seen = []; + seen[type.id] = true; + seen[promisedType.id] = true; + } + else if (seen[nestedPromisedType.id]) { + // if we've already seen this type, this is a promise that would never resolve. As above, we return the empty type. + return emptyObjectType; + } + + seen[nestedPromisedType.id] = true; + promisedType = nestedPromisedType; + } + + return promisedType; + + // if we didn't get a promised type, check the type does not have a callable then member. + if (isTypeAssignableTo(type, getGlobalThenableType())) { + error(null, Diagnostics.Type_for_await_does_not_have_a_valid_callable_then_member); + return emptyObjectType; + } + + // if the type was not a "promise" or a "thenable", return the type. + return type; + } + + function checkAsyncFunctionReturnType(node: SignatureDeclaration, returnType: Type): Type { + // This checks that an async function has a valid Promise-compatible return type, and returns the *awaited type* of the promise. + // An async function has a valid Promise-compatible return type if the resolved value of the return type has a construct + // signature that takes in an `initializer` function that in turn supplies a `resolve` function as one of its arguments + // and results in an object with a callable `then` signature. + let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType !== emptyObjectType) { + if (!returnType) { + returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + + // get the constructor type of the return type + var declaredType = returnType.symbol ? getTypeOfSymbol(returnType.symbol) : emptyObjectType; + if (isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { + var promisedType = getPromisedType(returnType); + if (promisedType !== emptyObjectType) { + // unwrap the promised type + var promiseConstructor = getPromiseConstructor(node); + if (promiseConstructor) { + emitAwaiter = true; + checkExpressionOrQualifiedName(promiseConstructor); + return getAwaitedType(promisedType); + } + } + } + } + + error(node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return emptyObjectType; + } + /** Check a decorator */ function checkDecorator(node: Decorator): void { let expression: Expression = node.expression; @@ -8904,6 +9142,7 @@ module ts { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedArgumentsVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } @@ -8946,7 +9185,14 @@ module ts { checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + let returnType = getTypeFromTypeNode(node.type); + let isAsync = isAsyncFunctionLike(node); + let promisedType: Type; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node, returnType); + } + + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -9016,6 +9262,12 @@ module ts { } } + function checkCollisionWithCapturedArgumentsVariable(node: Node, name: Identifier): void { + if (needCollisionCheckForIdentifier(node, name, "_arguments")) { + potentialArgumentsCollisions.push(node); + } + } + // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node: Node): void { let current = node; @@ -9034,6 +9286,25 @@ module ts { } } + function checkIfArgumentsIsCapturedInEnclosingScope(node: Node): void { + let current = node; + while (current) { + if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureArguments) { + let isDeclaration = node.kind !== SyntaxKind.Identifier; + if (isDeclaration) { + error((node).name, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_variable_declaration_arguments_to_capture_arguments_reference); + } + else { + error(node, Diagnostics.Expression_resolves_to_variable_declaration_arguments_that_compiler_uses_to_capture_arguments_reference); + } + + return; + } + + current = current.parent; + } + } + function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -9149,6 +9420,34 @@ module ts { } } + function getPromiseConstructor(node: SignatureDeclaration): EntityName { + if (node.type && node.type.kind === SyntaxKind.TypeReference) { + return (node.type).typeName; + } + + let globalPromiseSymbol = getGlobalPromiseSymbol(); + if (globalPromiseSymbol && globalPromiseSymbol === resolveName(node, "Promise", SymbolFlags.Value, undefined, undefined)) { + return globalPromiseSymbol.valueDeclaration.name; + } + + return undefined; + } + + function checkCollisionWithAwaiterVariablesInGeneratedCode(node: Node, name: DeclarationName): void { + if (!name || name.kind !== SyntaxKind.Identifier || isTypeNode(name)) { + return; + } + + let identifier = name; + let container = getContainingFunction(name); + if (container && isAsyncFunctionLike(container) && node.kind !== SyntaxKind.Identifier) { + var promiseConstructor = getPromiseConstructor(container); + if (promiseConstructor && promiseConstructor.kind === SyntaxKind.Identifier && (promiseConstructor).text === identifier.text) { + error(node, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, identifier.text, getTextOfNode(promiseConstructor)); + } + } + } + function isParameterDeclaration(node: VariableLikeDeclaration) { while (node.kind === SyntaxKind.BindingElement) { node = node.parent.parent; @@ -9251,8 +9550,14 @@ module ts { } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedArgumentsVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } + + if (symbol === argumentsSymbol && (node.parserContextFlags & ParserContextFlags.Await)) { + let container = getContainingFunction(node); + captureLexicalArguments(node.name, container); + } } function checkVariableDeclaration(node: VariableDeclaration) { @@ -9275,7 +9580,10 @@ module ts { function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node: Node) { if (node.modifiers) { if (inBlockOrObjectLiteralExpression(node)) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + // disallow all but the `async` modifier here + if (isAccessor(node.kind) || !isFunctionLike(node) || (node.modifiers.flags & ~NodeFlags.Async)) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } } } } @@ -9288,6 +9596,8 @@ module ts { node = node.parent; } + + return false; } function checkExpressionStatement(node: ExpressionStatement) { @@ -9667,8 +9977,11 @@ module ts { error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } + else if (func.type && !isAccessor(func.kind) && isAsyncFunctionLike(func)) { + checkTypeAssignableTo(getAwaitedType(exprType), getPromisedType(returnType), node.expression); + } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { - checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, returnType, node.expression); } } } @@ -9943,6 +10256,7 @@ module ts { checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithAwaiterVariablesInGeneratedCode(node, node.name); } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); @@ -10386,6 +10700,7 @@ module ts { checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithAwaiterVariablesInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); @@ -10885,12 +11200,14 @@ module ts { case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.DeleteExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.SpreadElementExpression: + case SyntaxKind.YieldExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: case SyntaxKind.VariableStatement: @@ -10941,6 +11258,7 @@ module ts { emitDecorate = false; emitParam = false; potentialThisCollisions.length = 0; + potentialArgumentsCollisions.length = 0; forEach(node.statements, checkSourceElement); checkFunctionExpressionBodies(node); @@ -10953,6 +11271,11 @@ module ts { forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + + if (potentialArgumentsCollisions.length) { + forEach(potentialArgumentsCollisions, checkIfArgumentsIsCapturedInEnclosingScope); + potentialArgumentsCollisions.length = 0; + } if (emitExtends) { links.flags |= NodeCheckFlags.EmitExtends; @@ -10965,6 +11288,14 @@ module ts { if (emitParam) { links.flags |= NodeCheckFlags.EmitParam; } + + if (emitAwaiter) { + links.flags |= NodeCheckFlags.EmitAwaiter; + } + + if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) { + links.flags |= NodeCheckFlags.EmitGenerator; + } links.flags |= NodeCheckFlags.TypeChecked; } @@ -11982,6 +12313,12 @@ module ts { getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); + getGlobalPromiseSymbol = memoize(() => getGlobalTypeSymbol("Promise")); + getGlobalPromiseType = memoize(() => getTypeOfGlobalSymbol(getGlobalPromiseSymbol(), /*arity*/ 1)); + getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); + getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); + getGlobalThenableType = memoize(createThenableType); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. @@ -12003,6 +12340,26 @@ module ts { anyArrayType = createArrayType(anyType); } + + function createInstantiatedPromiseLikeType(): ObjectType { + let promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + + return emptyObjectType; + } + + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + + let thenableType = createObjectType(TypeFlags.ObjectType); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + return thenableType; + } // GRAMMAR CHECKING function isReservedWordInStrictMode(node: Identifier): boolean { @@ -12203,7 +12560,7 @@ module ts { return; } - let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node; + let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node; let flags = 0; for (let modifier of node.modifiers) { switch (modifier.kind) { @@ -12229,6 +12586,9 @@ module ts { else if (flags & NodeFlags.Static) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } @@ -12239,6 +12599,9 @@ module ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } @@ -12256,6 +12619,9 @@ module ts { else if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } @@ -12269,6 +12635,9 @@ module ts { if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } @@ -12281,6 +12650,20 @@ module ts { flags |= NodeFlags.Ambient; lastDeclare = modifier break; + + case SyntaxKind.AsyncKeyword: + if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & NodeFlags.Ambient || isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= NodeFlags.Async; + lastAsync = modifier; + break; } } @@ -12294,16 +12677,42 @@ module ts { else if (flags & NodeFlags.Private) { return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & NodeFlags.Ambient) { - return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) { - return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); + return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((node).name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & NodeFlags.Async) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + + function checkGrammarAsyncModifier(node: Node, asyncModifier: Node): boolean { + if (languageVersion < ScriptTarget.ES6) { + return grammarErrorOnNode(asyncModifier, Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + + switch (node.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + if (!(node).asteriskToken) { + return false; + } + break; + } + + return grammarErrorOnNode(asyncModifier, Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 14163e81195be..091cabb448027 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -34,8 +34,12 @@ module ts { Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -45,11 +49,13 @@ module ts { A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Type_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Type for 'await' does not have a valid callable 'then' member." }, Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -120,7 +126,7 @@ module ts { 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." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, + yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained within a generator declaration." }, Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, @@ -174,6 +180,18 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + _0_modifier_cannot_be_used_with_a_generator: { code: 1301, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a generator." }, + _0_modifier_cannot_be_used_with_a_module_declaration: { code: 1302, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a module declaration." }, + _0_modifier_cannot_be_used_with_an_enum_declaration: { code: 1303, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with an enum declaration." }, + _0_modifier_cannot_be_used_with_an_export_assignment_declaration: { code: 1304, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with an export assignment declaration." }, + _0_modifier_cannot_be_used_on_a_variable_statement: { code: 1305, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used on a variable statement." }, + _0_modifier_cannot_be_used_with_a_type_declaration: { code: 1306, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a type declaration." }, + _0_modifier_cannot_be_used_with_a_parameter_declaration: { code: 1307, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a parameter declaration." }, + await_expression_must_be_contained_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression must be contained within an async function." }, + _0_modifier_cannot_be_used_on_an_object_literal_element: { code: 1309, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used on an object literal element." }, + _0_expression_is_not_allowed_in_an_initializer: { code: 1310, category: DiagnosticCategory.Error, key: "'{0}' expression is not allowed in an initializer." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, 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." }, @@ -363,6 +381,10 @@ module ts { An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + Duplicate_identifier_arguments_Compiler_uses_variable_declaration_arguments_to_capture_arguments_reference: { code: 2522, category: DiagnosticCategory.Error, key: "Duplicate identifier '_arguments'. Compiler uses variable declaration '_arguments' to capture 'arguments' reference." }, + Expression_resolves_to_variable_declaration_arguments_that_compiler_uses_to_capture_arguments_reference: { code: 2523, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_arguments' that compiler uses to capture 'arguments' reference." }, 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}'." }, @@ -505,6 +527,7 @@ module ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Emit_async_functions_when_ECMAScript_target_version_is_lower_than_ES6: { code: 6063, category: DiagnosticCategory.Message, key: "Emit async functions when ECMAScript target version is lower than 'ES6'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 18c98928dda4c..431aec3f5316d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -123,11 +123,27 @@ "category": "Error", "code": 1039 }, + "'{0}' modifier cannot be used in an ambient context.": { + "category": "Error", + "code": 1040 + }, + "'{0}' modifier cannot be used with a class declaration.": { + "category": "Error", + "code": 1041 + }, + "'{0}' modifier cannot be used here.": { + "category": "Error", + "code": 1042 + }, + "'{0}' modifier cannot appear on a data property.": { + "category": "Error", + "code": 1043 + }, "'{0}' modifier cannot appear on a module element.": { "category": "Error", "code": 1044 }, - "A 'declare' modifier cannot be used with an interface declaration.": { + "A '{0}' modifier cannot be used with an interface declaration.": { "category": "Error", "code": 1045 }, @@ -167,6 +183,14 @@ "category": "Error", "code": 1056 }, + "An async function or method must have a valid awaitable return type.": { + "category": "Error", + "code": 1057 + }, + "Type for 'await' does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1058 + }, "Enum member must have initializer.": { "category": "Error", "code": 1061 @@ -183,7 +207,7 @@ "category": "Error", "code": 1068 }, - "A 'declare' modifier cannot be used with an import declaration.": { + "A '{0}' modifier cannot be used with an import declaration.": { "category": "Error", "code": 1079 }, @@ -467,7 +491,7 @@ "category": "Error", "code": 1162 }, - "'yield' expression must be contained_within a generator declaration.": { + "'yield' expression must be contained within a generator declaration.": { "category": "Error", "code": 1163 }, @@ -684,6 +708,55 @@ "code": 1218 }, + "'with' statements are not allowed in an async function block.": { + "category": "Error", + "code": 1300 + }, + "'{0}' modifier cannot be used with a generator.": { + "category": "Error", + "code": 1301 + }, + "'{0}' modifier cannot be used with a module declaration.": { + "category": "Error", + "code": 1302 + }, + "'{0}' modifier cannot be used with an enum declaration.": { + "category": "Error", + "code": 1303 + }, + "'{0}' modifier cannot be used with an export assignment declaration.": { + "category": "Error", + "code": 1304 + }, + "'{0}' modifier cannot be used on a variable statement.": { + "category": "Error", + "code": 1305 + }, + "'{0}' modifier cannot be used with a type declaration.": { + "category": "Error", + "code": 1306 + }, + "'{0}' modifier cannot be used with a parameter declaration.": { + "category": "Error", + "code": 1307 + }, + "'await' expression must be contained within an async function.": { + "category": "Error", + "code": 1308 + }, + "'{0}' modifier cannot be used on an object literal element.": { + "category": "Error", + "code": 1309 + }, + "'{0}' expression is not allowed in an initializer.": { + "category": "Error", + "code": 1310 + }, + "Async functions are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1311 + }, + "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -1441,6 +1514,23 @@ "code": 2501 }, + "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { + "category": "Error", + "code": 2520 + }, + "Expression resolves to variable declaration '{0}' that compiler uses to support async functions.": { + "category": "Error", + "code": 2521 + }, + "Duplicate identifier '_arguments'. Compiler uses variable declaration '_arguments' to capture 'arguments' reference.": { + "category": "Error", + "code": 2522 + }, + "Expression resolves to variable declaration '_arguments' that compiler uses to capture 'arguments' reference.": { + "category": "Error", + "code": 2523 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2010,7 +2100,10 @@ "category": "Error", "code": 6062 }, - + "Emit async functions when ECMAScript target version is lower than 'ES6'.": { + "category": "Message", + "code": 6063 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 055fc1b6f7465..db9580871788f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -153,6 +153,8 @@ module ts { case SyntaxKind.YieldExpression: return visitNode(cbNode, (node).asteriskToken) || visitNode(cbNode, (node).expression); + case SyntaxKind.AwaitExpression: + return visitNode(cbNode, (node).expression); case SyntaxKind.PostfixUnaryExpression: return visitNode(cbNode, (node).operand); case SyntaxKind.BinaryExpression: @@ -556,9 +558,17 @@ module ts { function setDecoratorContext(val: boolean) { setContextFlag(val, ParserContextFlags.Decorator); } - - function doOutsideOfContext(flags: ParserContextFlags, func: () => T): T { - let currentContextFlags = contextFlags & flags; + + function setAwaitContext(val: boolean) { + setContextFlag(val, ParserContextFlags.Await); + } + + function setAsyncParameterContext(val: boolean) { + setContextFlag(val, ParserContextFlags.AsyncParameter); + } + + function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { + let currentContextFlags = contextFlags & context; if (currentContextFlags) { setContextFlag(false, currentContextFlags); let result = func(); @@ -569,85 +579,86 @@ module ts { // no need to do anything special as we are not in any of the requested contexts return func(); } - - function allowInAnd(func: () => T): T { - if (contextFlags & ParserContextFlags.DisallowIn) { - setDisallowInContext(false); + + function doInsideOfContext(context: ParserContextFlags, func: () => T): T { + let unsetContextFlags = context & ~contextFlags; + if (!unsetContextFlags) { + setContextFlag(true, unsetContextFlags); let result = func(); - setDisallowInContext(true); + setContextFlag(false, unsetContextFlags); return result; } - - // no need to do anything special if 'in' is already allowed. + + // no need to do anything special as we are already in all of the requested contexts return func(); } - function disallowInAnd(func: () => T): T { - if (contextFlags & ParserContextFlags.DisallowIn) { - // no need to do anything special if 'in' is already disallowed. - return func(); - } - - setDisallowInContext(true); - let result = func(); - setDisallowInContext(false); - return result; + function allowInAnd(func: () => T): T { + return doInsideOfContext(ParserContextFlags.DisallowIn, func); } + function disallowInAnd(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.DisallowIn, func); + } + function doInYieldContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Yield) { - // no need to do anything special if we're already in the [Yield] context. - return func(); - } - - setYieldContext(true); - let result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(ParserContextFlags.Yield, func); } function doOutsideOfYieldContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Yield) { - setYieldContext(false); - let result = func(); - setYieldContext(true); - return result; - } - - // no need to do anything special if we're not in the [Yield] context. - return func(); + return doOutsideOfContext(ParserContextFlags.Yield, func); } function doInDecoratorContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Decorator) { - // no need to do anything special if we're already in the [Decorator] context. - return func(); - } - - setDecoratorContext(true); - let result = func(); - setDecoratorContext(false); - return result; + return doInsideOfContext(ParserContextFlags.Decorator, func); + } + + function doInAwaitContext(func: () => T): T { + return doInsideOfContext(ParserContextFlags.Await, func); + } + + function doOutsideOfAwaitContext(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.Await, func); + } + + function doOutsideOfYieldAndAwaitContext(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); + } + + function inContext(flags: ParserContextFlags) { + return (contextFlags & flags) === flags; } function inYieldContext() { - return (contextFlags & ParserContextFlags.Yield) !== 0; + return inContext(ParserContextFlags.Yield); } function inStrictModeContext() { - return (contextFlags & ParserContextFlags.StrictMode) !== 0; + return inContext(ParserContextFlags.StrictMode); } function inGeneratorParameterContext() { - return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0; + return inContext(ParserContextFlags.GeneratorParameter); } function inDisallowInContext() { - return (contextFlags & ParserContextFlags.DisallowIn) !== 0; + return inContext(ParserContextFlags.DisallowIn); } function inDecoratorContext() { - return (contextFlags & ParserContextFlags.Decorator) !== 0; + return inContext(ParserContextFlags.Decorator); + } + + function inAwaitContext() { + return inContext(ParserContextFlags.Await); + } + + function inAsyncParameterContext() { + return inContext(ParserContextFlags.AsyncParameter); + } + + function inGeneratorParameterOrAsyncParameterContext() { + return inContext(ParserContextFlags.GeneratorParameter | ParserContextFlags.AsyncParameter); } function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { @@ -927,7 +938,8 @@ module ts { // PropertyName[Yield,GeneratorParameter] : // LiteralPropertyName // [+GeneratorParameter] ComputedPropertyName - // [~GeneratorParameter] ComputedPropertyName[?Yield] + // [+AsyncParameter] ComputedPropertyName + // [~GeneratorParameter,~AsyncParameter] ComputedPropertyName[?Yield,?Await] // // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] @@ -938,34 +950,40 @@ module ts { // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. - let yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } - - node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } + node.expression = inGeneratorParameterOrAsyncParameterContext() + ? doOutsideOfYieldAndAwaitContext(parseExpression) + : parseExpression(); parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } - function parseContextualModifier(t: SyntaxKind): boolean { - return token === t && tryParse(nextTokenCanFollowModifier); + function parseContextualModifier(t: SyntaxKind, isArrowFunction?: boolean): boolean { + return token === t && tryParse(isArrowFunction + ? nextTokenCanFollowModifierForArrowFunction + : nextTokenCanFollowModifier); + } + + function nextTokenCanFollowModifierForArrowFunction() { + return nextTokenCanFollowModifier(/*isArrowFunction*/ true); } - function nextTokenCanFollowModifier() { + function nextTokenCanFollowModifier(isArrowFunction?: boolean) { nextToken(); - return canFollowModifier(); + return canFollowModifier(isArrowFunction); } - function parseAnyContextualModifier(): boolean { - return isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); + function parseAnyContextualModifier(isArrowFunction?: boolean): boolean { + return isModifier(token) && tryParse(isArrowFunction + ? nextTokenCanFollowContextualModifierForArrowFunction + : nextTokenCanFollowContextualModifier); + } + + function nextTokenCanFollowContextualModifierForArrowFunction() { + return nextTokenCanFollowContextualModifier(/*isArrowFunction*/ true); } - function nextTokenCanFollowContextualModifier() { + function nextTokenCanFollowContextualModifier(isArrowFunction?: boolean) { if (token === SyntaxKind.ConstKeyword) { // 'const' is only a modifier if followed by 'enum'. return nextToken() === SyntaxKind.EnumKeyword; @@ -981,10 +999,19 @@ module ts { return nextTokenIsClassOrFunction(); } nextToken(); - return canFollowModifier(); + return canFollowModifier(isArrowFunction); } - function canFollowModifier(): boolean { + function canFollowModifier(isArrowFunction?: boolean): boolean { + if (isArrowFunction) { + if (scanner.hasPrecedingLineBreak()) { + return false; + } + + return token === SyntaxKind.OpenParenToken + || token === SyntaxKind.LessThanToken; + } + return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.AsteriskToken @@ -1827,11 +1854,10 @@ module ts { setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - // SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // FormalParameter[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.1 + // BindingElement[?Yield,?GeneratorParameter,?Await,?AsyncParameter] - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + node.name = parseIdentifierOrPattern(); if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifier(token)) { // in cases like @@ -1847,7 +1873,7 @@ module ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in @@ -1859,19 +1885,36 @@ module ts { // ambient contexts. return finishNode(node); } + + function parseBindingElementInitializer(inParameter: boolean) { + // BindingElement[Yield,GeneratorParameter,Await,AsyncParameter] : + // [+GeneratorParameter] BindingPattern[?Yield,?Await,GeneratorParameter] Initializer[In]opt + // [+AsyncParameter] BindingPattern[?Yield,?Await,AsyncParameter] Initializer[In]opt + // [~GeneratorParameter,~AsyncParameter] BindingPattern[?Yield,?Await] Initializer[In,?Yield,?Await]opt + // SingleNameBinding[Yield,GeneratorParameter,Await,AsyncParameter] : + // [+GeneratorParameter] BindingIdentifier[Yield] Initializer[In]opt + // [+AsyncParameter] BindingIdentifier[Await] Initializer[In]opt + // [~GeneratorParameter,~AsyncParameter] BindingIdentifier[?Yield,?Await] Initializer[In,?Yield,?Await]opt + + let parseInitializer = inParameter ? parseParameterInitializer : parseNonParameterInitializer; + return inGeneratorParameterOrAsyncParameterContext() + ? doOutsideOfYieldAndAwaitContext(parseInitializer) + : parseInitializer(); + } function parseParameterInitializer() { return parseInitializer(/*inParameter*/ true); } - + function fillSignature( returnToken: SyntaxKind, yieldAndGeneratorParameterContext: boolean, + awaitAndAsyncParameterContext: boolean, requireCompleteParameterList: boolean, signature: SignatureDeclaration): void { let returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, awaitAndAsyncParameterContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); @@ -1886,32 +1929,48 @@ module ts { // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling // this FormalParameters production either always sets both to true, or always sets // both to false. As such we only have a single parameter to represent both. - function parseParameterList(yieldAndGeneratorParameterContext: boolean, requireCompleteParameterList: boolean) { - // FormalParameters[Yield,GeneratorParameter] : + function parseParameterList(yieldAndGeneratorParameterContext: boolean, awaitAndAsyncParameterContext: boolean, requireCompleteParameterList: boolean) { + // FormalParameters[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) // ... // - // FormalParameter[Yield,GeneratorParameter] : - // BindingElement[?Yield, ?GeneratorParameter] + // FormalParameter[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) + // BindingElement[?Yield,?GeneratorParameter,?Await,?AsyncParameter] // - // BindingElement[Yield, GeneratorParameter ] : See 13.2.3 - // SingleNameBinding[?Yield, ?GeneratorParameter] - // [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt - // [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt + // BindingElement[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 13.2.3 + // SingleNameBinding[?Yield,?GeneratorParameter,?Await,?AsyncParameter] + // [+GeneratorParameter]BindingPattern[?Yield,?Await,?AsyncParameter,GeneratorParameter] Initializer[In]opt + // [+AsyncParameter]BindingPattern[?Yield,?Await,?GeneratorParameter,AsyncParameter] Initializer[In]opt + // [~GeneratorParameter,~AsyncParameter]BindingPattern[?Yield,?Await]Initializer[In,?Yield,?Await]opt // - // SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3 + // SingleNameBinding[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 13.2.3 // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // [+AsyncParameter]BindingIdentifier[Await]Initializer[In]opt + // [~GeneratorParameter,~AsyncParameter]BindingIdentifier[?Yield,?Await]Initializer[In,?Yield,?Await]opt if (parseExpected(SyntaxKind.OpenParenToken)) { let savedYieldContext = inYieldContext(); let savedGeneratorParameterContext = inGeneratorParameterContext(); + let savedAwaitContext = inAwaitContext(); + let savedAsyncParameterContext = inAsyncParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); + if (yieldAndGeneratorParameterContext) { + setYieldContext(true); + } + setGeneratorParameterContext(yieldAndGeneratorParameterContext); + + if (awaitAndAsyncParameterContext) { + setAwaitContext(true); + } + + setAsyncParameterContext(awaitAndAsyncParameterContext); let result = parseDelimitedList(ParsingContext.Parameters, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); + + setAwaitContext(savedAwaitContext); + setAsyncParameterContext(savedAsyncParameterContext); if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return @@ -1944,7 +2003,7 @@ module ts { if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList:*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -2034,7 +2093,7 @@ module ts { // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [GeneratorParameter] - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, method); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList:*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } @@ -2173,7 +2232,7 @@ module ts { if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node); + fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldAndGeneratorParameterContext:*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList:*/ false, node); return finishNode(node); } @@ -2302,19 +2361,8 @@ module ts { function parseType(): TypeNode { // The rules about 'yield' only apply to actual code/expression contexts. They don't - // apply to 'type' contexts. So we disable these parameters here before moving on. - let savedYieldContext = inYieldContext(); - let savedGeneratorParameterContext = inGeneratorParameterContext(); - - setYieldContext(false); - setGeneratorParameterContext(false); - - let result = parseTypeWorker(); - - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - - return result; + // apply to 'type' contexts. So we disable these parameters here before moving on. + return doOutsideOfContext(ParserContextFlags.ContextParameterFlags, parseTypeWorker); } function parseTypeWorker(): TypeNode { @@ -2374,6 +2422,7 @@ module ts { case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: case SyntaxKind.LessThanToken: + case SyntaxKind.AwaitKeyword: case SyntaxKind.YieldKeyword: // Yield always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in @@ -2586,7 +2635,7 @@ module ts { node.parameters.end = parameter.end; node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } @@ -2617,7 +2666,7 @@ module ts { var lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition:*/false, Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) - ? parseArrowFunctionExpressionBody() + ? parseArrowFunctionExpressionBody(/*isAsync*/ isAsyncFunctionLike(arrowFunction)) : parseIdentifier(); return finishNode(arrowFunction); @@ -2628,7 +2677,7 @@ module ts { // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression(): Tristate { - if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { + if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken || token === SyntaxKind.AsyncKeyword) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } @@ -2643,6 +2692,10 @@ module ts { } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === SyntaxKind.AsyncKeyword && !parseContextualModifier(SyntaxKind.AsyncKeyword, /*isArrowFunction*/ true)) { + return Tristate.False; + } + let first = token; let second = nextToken(); @@ -2718,6 +2771,9 @@ module ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); + setModifiers(node, parseModifiers(/*isArrowFunction*/ true)); + let isAsync = isAsyncFunctionLike(node); + // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -2725,7 +2781,7 @@ module ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ !allowAmbiguity, node); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList:*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -2748,9 +2804,9 @@ module ts { return node; } - function parseArrowFunctionExpressionBody(): Block | Expression { + function parseArrowFunctionExpressionBody(isAsync: boolean): Block | Expression { if (token === SyntaxKind.OpenBraceToken) { - return parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ false); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (isStartOfStatement(/*inErrorRecovery:*/ true) && @@ -2772,10 +2828,12 @@ module ts { // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } - - return parseAssignmentExpressionOrHigher(); + + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand: Expression): Expression { @@ -2915,8 +2973,32 @@ module ts { node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + + function isAwaitExpression(): boolean { + if (token === SyntaxKind.AwaitKeyword) { + if (inAwaitContext()) { + return true; + } + + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + + return false; + } + + function parseAwaitExpression() { + var node = createNode(SyntaxKind.AwaitExpression); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function parseUnaryExpressionOrHigher(): UnaryExpression { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + switch (token) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: @@ -3230,6 +3312,11 @@ module ts { return parseArrayLiteralExpression(); case SyntaxKind.OpenBraceToken: return parseObjectLiteralExpression(); + case SyntaxKind.AsyncKeyword: + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + return parseFunctionExpression(); case SyntaxKind.ClassKeyword: return parseClassExpression(); case SyntaxKind.FunctionKeyword: @@ -3353,15 +3440,32 @@ module ts { if (saveDecoratorContext) { setDecoratorContext(false); } + let node = createNode(SyntaxKind.FunctionExpression); + setModifiers(node, parseModifiers()); parseExpected(SyntaxKind.FunctionKeyword); - node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ !!node.asteriskToken, /*requireCompleteParameterList:*/ false, node); - node.body = parseFunctionBlock(/*allowYield:*/ !!node.asteriskToken, /* ignoreMissingOpenBrace */ false); + node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); + + let savedYieldContext = inYieldContext(); + let isGenerator = node.asteriskToken != undefined; + setYieldContext(isGenerator); + + let savedAwaitContext = inAwaitContext(); + let isAsync = isAsyncFunctionLike(node); + setAwaitContext(isAsync); + + node.name = parseOptionalIdentifier(); + + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + if (saveDecoratorContext) { setDecoratorContext(true); } + return finishNode(node); } @@ -3394,9 +3498,12 @@ module ts { return finishNode(node); } - function parseFunctionBlock(allowYield: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseFunctionBlock(allowYield: boolean, allowAwait: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { let savedYieldContext = inYieldContext(); setYieldContext(allowYield); + + let savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. @@ -3412,6 +3519,7 @@ module ts { } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } @@ -3702,6 +3810,15 @@ module ts { // In ES 6 'enum' is a future reserved keyword, so it should not be used as identifier let isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; + + case SyntaxKind.AsyncKeyword: + // When followed by the function keyword on the same line, this is a statement + if (lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + return true; + } + + return isStartOfExpression(); + case SyntaxKind.InterfaceKeyword: case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: @@ -3835,13 +3952,13 @@ module ts { return undefined; } - function parseFunctionBlockOrSemicolon(isGenerator: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseFunctionBlockOrSemicolon(isGenerator: boolean, isAsync: boolean, diagnosticMessage?: DiagnosticMessage): Block { if (token !== SyntaxKind.OpenBraceToken && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, /*ignoreMissingOpenBrace:*/ false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace:*/ false, diagnosticMessage); } // DECLARATIONS @@ -3853,7 +3970,7 @@ module ts { let node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } @@ -3870,7 +3987,7 @@ module ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } @@ -3976,8 +4093,10 @@ module ts { parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ !!node.asteriskToken, /*requireCompleteParameterList:*/ false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, Diagnostics.or_expected); + let isGenerator = node.asteriskToken != undefined; + let isAsync = isAsyncFunctionLike(node); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList:*/ false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); return finishNode(node); } @@ -3986,8 +4105,8 @@ module ts { node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator:*/ false, Diagnostics.or_expected); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected); return finishNode(node); } @@ -3998,8 +4117,10 @@ module ts { method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ !!asteriskToken, /*requireCompleteParameterList:*/ false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + let isGenerator = asteriskToken != undefined; + let isAsync = isAsyncFunctionLike(method); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList:*/ false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } @@ -4039,8 +4160,8 @@ module ts { node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator:*/ false); + fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } @@ -4147,14 +4268,14 @@ module ts { return decorators; } - function parseModifiers(): ModifiersArray { + function parseModifiers(isArrowFunction?: boolean): ModifiersArray { let flags = 0; let modifiers: ModifiersArray; while (true) { let modifierStart = scanner.getStartPos(); let modifierKind = token; - if (!parseAnyContextualModifier()) { + if (!parseAnyContextualModifier(isArrowFunction)) { break; } @@ -4228,7 +4349,7 @@ module ts { function parseClassDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassDeclaration { return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, SyntaxKind.ClassDeclaration); } - + function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration { // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code let savedStrictModeContext = inStrictModeContext(); @@ -4243,13 +4364,15 @@ module ts { node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause:*/ true); if (parseExpected(SyntaxKind.OpenBraceToken)) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // ClassTail[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.5 + // [~GeneratorParameter,~AsyncParameter]ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) + // [+AsyncParameter] ClassHeritageopt { ClassBodyopt } + + node.members = inGeneratorParameterOrAsyncParameterContext() + ? doOutsideOfYieldAndAwaitContext(parseClassMembers) : parseClassMembers(); + parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -4262,13 +4385,14 @@ module ts { } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // ClassTail[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.5 + // [~GeneratorParameter,~AsyncParameter]ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // [+AsyncParameter] ClassHeritageopt { ClassBodyopt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) + return isClassHeritageClause && inGeneratorParameterOrAsyncParameterContext() + ? doOutsideOfYieldAndAwaitContext(parseHeritageClausesWorker) : parseHeritageClausesWorker(); } @@ -4652,6 +4776,11 @@ module ts { case SyntaxKind.StaticKeyword: // Check for modifier on source element return lookAhead(nextTokenIsDeclarationStart); + + case SyntaxKind.AsyncKeyword: + // Check for modifier on source element + return lookAhead(nextTokenIsDeclarationStartOnSameLine); + case SyntaxKind.AtToken: // a lookahead here is too costly, and decorators are only valid on a declaration. // We will assume we are parsing a declaration here and report an error later @@ -4690,6 +4819,16 @@ module ts { return isDeclarationStart(/*followsModifier*/ true); } + function nextTokenIsDeclarationStartOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isDeclarationStart(); + } + + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && token === SyntaxKind.FunctionKeyword; + } + function nextTokenIsAsKeyword() { return nextToken() === SyntaxKind.AsKeyword; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 1fc8bff92e677..2dc85174cd913 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -101,6 +101,8 @@ module ts { "while": SyntaxKind.WhileKeyword, "with": SyntaxKind.WithKeyword, "yield": SyntaxKind.YieldKeyword, + "async": SyntaxKind.AsyncKeyword, + "await": SyntaxKind.AwaitKeyword, "of": SyntaxKind.OfKeyword, "{": SyntaxKind.OpenBraceToken, "}": SyntaxKind.CloseBraceToken, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86e680ca8b047..b23b46bc9bddf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -133,6 +133,8 @@ module ts { // Contextual keywords AsKeyword, AnyKeyword, + AsyncKeyword, + AwaitKeyword, BooleanKeyword, ConstructorKeyword, DeclareKeyword, @@ -197,6 +199,7 @@ module ts { DeleteExpression, TypeOfExpression, VoidExpression, + AwaitExpression, PrefixUnaryExpression, PostfixUnaryExpression, BinaryExpression, @@ -316,8 +319,9 @@ module ts { OctalLiteral = 0x00004000, // Octal numeric literal Namespace = 0x00008000, // Namespace declaration ExportContext = 0x00010000, // Export context (initialized by binding) + Async = 0x00020000, // Property/Method/Function - Modifier = Export | Ambient | Public | Private | Protected | Static | Default, + Modifier = Export | Ambient | Public | Private | Protected | Static | Default | Async, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const } @@ -345,17 +349,29 @@ module ts { // error. ThisNodeHasError = 1 << 5, + // If this node was parsed in the parameters of an async function. + AsyncParameter = 1 << 6, + + // If this node was parsed in the 'await' context created when parsing an async function. + Await = 1 << 7, + // Context flags set directly by the parser. - ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError, + ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | AsyncParameter | Await, + // Context flags passed as part of the modified ES6 grammar. + ContextParameterFlags = Yield | GeneratorParameter | AsyncParameter | Await, + // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ThisNodeOrAnySubNodesHasError = 1 << 6, + ThisNodeOrAnySubNodesHasError = 1 << 8, + + // Used to know if we've computed whether any children of this node are or contain an 'await' or 'yield' expression. + ThisNodeOrAnySubNodesHasAwaitOrYield = 1 << 9, // Used to know if we've computed data from children and cached it in this node. - HasAggregatedChildData = 1 << 7 + HasAggregatedChildData = 1 << 10 } /* @internal */ @@ -658,6 +674,10 @@ module ts { expression: UnaryExpression; } + export interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } + export interface YieldExpression extends Expression { asteriskToken?: Node; expression: Expression; @@ -1403,22 +1423,28 @@ module ts { TypeChecked = 0x00000001, // Node has been type checked LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body - EmitExtends = 0x00000008, // Emit __extends - SuperInstance = 0x00000010, // Instance 'super' reference - SuperStatic = 0x00000020, // Static 'super' reference - ContextChecked = 0x00000040, // Contextual types have been assigned + LexicalArguments = 0x00000008, // Lexical 'arguments' reference + CaptureArguments = 0x00000010, // Lexical 'arguments' used in body + EmitExtends = 0x00000020, // Emit __extends + EmitDecorate = 0x00000040, // Emit __decorate + EmitParam = 0x00000080, // Emit __param helper for decorators + EmitAwaiter = 0x00000100, // Emit __awaiter + EmitGenerator = 0x00000200, // Emit __generator + SuperInstance = 0x00000400, // Instance 'super' reference + SuperStatic = 0x00000800, // Static 'super' reference + ContextChecked = 0x00001000, // Contextual types have been assigned + PromiseCollision = 0x00002000, // Declaration collides with the global 'Promise' // Values for enum members have been computed, and any errors have been reported for them. - EnumValuesComputed = 0x00000080, - BlockScopedBindingInLoop = 0x00000100, - EmitDecorate = 0x00000200, // Emit __decorate - EmitParam = 0x00000400, // Emit __param helper for decorators - LexicalModuleMergesWithClass = 0x00000800, // Instantiated lexical module declaration is merged with a previous class declaration. + EnumValuesComputed = 0x00004000, + BlockScopedBindingInLoop = 0x00008000, + LexicalModuleMergesWithClass= 0x00010000, // Instantiated lexical module declaration is merged with a previous class declaration. } /* @internal */ export interface NodeLinks { resolvedType?: Type; // Cached type of type node + resolvedAwaitedType?: Type; // Cached awaited type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result flags?: NodeCheckFlags; // Set of flags specific to Node diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3e825c6802c79..e5856077edcea 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -511,6 +511,19 @@ module ts { } } + export function getContainingParameter(node: Node): ParameterDeclaration { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return undefined; + } + + if (node.kind === SyntaxKind.Parameter) { + return node; + } + } + } + export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node { while (true) { node = node.parent; @@ -1087,6 +1100,10 @@ module ts { return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken; } + export function isAsyncFunctionLike(node: Node): boolean { + return isFunctionLike(node) && !isAccessor(node) && (node.flags & NodeFlags.Async) === NodeFlags.Async; + } + /** * A declaration has a dynamic name if both of the following are true: * 1. The declaration has a computed property name @@ -1145,6 +1162,7 @@ module ts { case SyntaxKind.DeclareKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DefaultKeyword: + case SyntaxKind.AsyncKeyword: return true; } return false; @@ -1630,6 +1648,7 @@ module ts { case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient; case SyntaxKind.ConstKeyword: return NodeFlags.Const; case SyntaxKind.DefaultKeyword: return NodeFlags.Default; + case SyntaxKind.AsyncKeyword: return NodeFlags.Async; } return 0; } diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index c03ab344ab2fe..0405774d99d52 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1169,3 +1169,15 @@ declare type ClassDecorator = (target: TFunction) => declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; +} \ No newline at end of file diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index fb0c64f849522..ff3c517fe4599 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -3572,16 +3572,6 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; -} - /** * Represents the completion of an asynchronous operation */ From e82e8419c275325fab6e6e40abce980a5b4fcfca Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 6 May 2015 17:33:58 -0700 Subject: [PATCH 008/250] Added emit for async functions in ES6 --- src/compiler/checker.ts | 139 +++----- .../diagnosticInformationMap.generated.ts | 3 +- src/compiler/diagnosticMessages.json | 6 +- src/compiler/emitter.ts | 144 +++++++- src/compiler/parser.ts | 23 +- src/compiler/types.ts | 28 +- src/compiler/utilities.ts | 2 +- .../FunctionDeclaration10_es6.errors.txt | 20 +- .../FunctionDeclaration6_es6.errors.txt | 4 +- .../FunctionDeclaration7_es6.errors.txt | 4 +- .../YieldExpression12_es6.errors.txt | 4 +- .../YieldExpression14_es6.errors.txt | 4 +- .../YieldExpression15_es6.errors.txt | 4 +- .../YieldExpression16_es6.errors.txt | 4 +- .../YieldExpression17_es6.errors.txt | 4 +- .../YieldExpression18_es6.errors.txt | 4 +- .../reference/YieldExpression2_es6.errors.txt | 4 +- .../reference/arrayLiterals2ES6.symbols | 6 +- .../asyncArrowFunction10_es6.errors.txt | 24 ++ .../reference/asyncArrowFunction10_es6.js | 13 + .../reference/asyncArrowFunction1_es6.js | 8 + .../reference/asyncArrowFunction1_es6.symbols | 7 + .../reference/asyncArrowFunction1_es6.types | 8 + .../reference/asyncArrowFunction2_es6.js | 7 + .../reference/asyncArrowFunction2_es6.symbols | 5 + .../reference/asyncArrowFunction2_es6.types | 6 + .../asyncArrowFunction3_es6.errors.txt | 8 + .../reference/asyncArrowFunction3_es6.js | 7 + .../reference/asyncArrowFunction4_es6.js | 7 + .../reference/asyncArrowFunction4_es6.symbols | 4 + .../reference/asyncArrowFunction4_es6.types | 5 + .../asyncArrowFunction5_es6.errors.txt | 24 ++ .../reference/asyncArrowFunction5_es6.js | 9 + .../asyncArrowFunction6_es6.errors.txt | 9 + .../reference/asyncArrowFunction6_es6.js | 8 + .../asyncArrowFunction7_es6.errors.txt | 12 + .../reference/asyncArrowFunction7_es6.js | 14 + .../asyncArrowFunction8_es6.errors.txt | 10 + .../reference/asyncArrowFunction8_es6.js | 10 + .../asyncArrowFunction9_es6.errors.txt | 23 ++ .../reference/asyncArrowFunction9_es6.js | 8 + ...owFunctionCapturesArguments_es6.errors.txt | 13 + ...asyncArrowFunctionCapturesArguments_es6.js | 16 + .../asyncArrowFunctionCapturesThis_es6.js | 14 + ...asyncArrowFunctionCapturesThis_es6.symbols | 13 + .../asyncArrowFunctionCapturesThis_es6.types | 14 + .../reference/asyncClass_es6.errors.txt | 8 + tests/baselines/reference/asyncClass_es6.js | 7 + .../reference/asyncConstructor_es6.errors.txt | 10 + .../reference/asyncConstructor_es6.js | 11 + .../reference/asyncDeclare_es6.errors.txt | 7 + tests/baselines/reference/asyncDeclare_es6.js | 4 + .../reference/asyncEnum_es6.errors.txt | 9 + tests/baselines/reference/asyncEnum_es6.js | 10 + .../asyncFunctionDeclaration10_es6.errors.txt | 26 ++ .../asyncFunctionDeclaration10_es6.js | 7 + .../asyncFunctionDeclaration11_es6.js | 9 + .../asyncFunctionDeclaration11_es6.symbols | 5 + .../asyncFunctionDeclaration11_es6.types | 5 + .../asyncFunctionDeclaration12_es6.errors.txt | 16 + .../asyncFunctionDeclaration12_es6.js | 5 + .../asyncFunctionDeclaration13_es6.errors.txt | 11 + .../asyncFunctionDeclaration13_es6.js | 14 + .../asyncFunctionDeclaration14_es6.js | 11 + .../asyncFunctionDeclaration14_es6.symbols | 7 + .../asyncFunctionDeclaration14_es6.types | 7 + .../asyncFunctionDeclaration1_es6.js | 9 + .../asyncFunctionDeclaration1_es6.symbols | 5 + .../asyncFunctionDeclaration1_es6.types | 5 + .../asyncFunctionDeclaration2_es6.js | 7 + .../asyncFunctionDeclaration2_es6.symbols | 5 + .../asyncFunctionDeclaration2_es6.types | 5 + .../asyncFunctionDeclaration3_es6.errors.txt | 8 + .../asyncFunctionDeclaration3_es6.js | 7 + .../asyncFunctionDeclaration4_es6.js | 7 + .../asyncFunctionDeclaration4_es6.symbols | 4 + .../asyncFunctionDeclaration4_es6.types | 4 + .../asyncFunctionDeclaration5_es6.errors.txt | 20 ++ .../asyncFunctionDeclaration5_es6.js | 7 + .../asyncFunctionDeclaration6_es6.errors.txt | 8 + .../asyncFunctionDeclaration6_es6.js | 9 + .../asyncFunctionDeclaration7_es6.errors.txt | 11 + .../asyncFunctionDeclaration7_es6.js | 17 + .../asyncFunctionDeclaration8_es6.errors.txt | 10 + .../asyncFunctionDeclaration8_es6.js | 5 + .../asyncFunctionDeclaration9_es6.errors.txt | 9 + .../asyncFunctionDeclaration9_es6.js | 11 + .../reference/asyncGetter_es6.errors.txt | 13 + tests/baselines/reference/asyncGetter_es6.js | 11 + .../reference/asyncInterface_es6.errors.txt | 8 + .../baselines/reference/asyncInterface_es6.js | 5 + .../reference/asyncModule_es6.errors.txt | 8 + tests/baselines/reference/asyncModule_es6.js | 5 + .../reference/asyncSetter_es6.errors.txt | 10 + tests/baselines/reference/asyncSetter_es6.js | 11 + .../reference/awaitBinaryExpression1_es6.js | 17 + .../awaitBinaryExpression1_es6.symbols | 19 + .../awaitBinaryExpression1_es6.types | 24 ++ .../reference/awaitBinaryExpression2_es6.js | 17 + .../awaitBinaryExpression2_es6.symbols | 19 + .../awaitBinaryExpression2_es6.types | 24 ++ .../reference/awaitBinaryExpression3_es6.js | 17 + .../awaitBinaryExpression3_es6.symbols | 19 + .../awaitBinaryExpression3_es6.types | 24 ++ .../reference/awaitBinaryExpression4_es6.js | 17 + .../awaitBinaryExpression4_es6.symbols | 19 + .../awaitBinaryExpression4_es6.types | 23 ++ .../reference/awaitBinaryExpression5_es6.js | 19 + .../awaitBinaryExpression5_es6.symbols | 24 ++ .../awaitBinaryExpression5_es6.types | 29 ++ .../reference/awaitCallExpression1_es6.js | 21 ++ .../awaitCallExpression1_es6.symbols | 50 +++ .../reference/awaitCallExpression1_es6.types | 54 +++ .../reference/awaitCallExpression2_es6.js | 21 ++ .../awaitCallExpression2_es6.symbols | 49 +++ .../reference/awaitCallExpression2_es6.types | 54 +++ .../reference/awaitCallExpression3_es6.js | 21 ++ .../awaitCallExpression3_es6.symbols | 49 +++ .../reference/awaitCallExpression3_es6.types | 54 +++ .../reference/awaitCallExpression4_es6.js | 21 ++ .../awaitCallExpression4_es6.symbols | 49 +++ .../reference/awaitCallExpression4_es6.types | 55 +++ .../reference/awaitCallExpression5_es6.js | 21 ++ .../awaitCallExpression5_es6.symbols | 52 +++ .../reference/awaitCallExpression5_es6.types | 56 +++ .../reference/awaitCallExpression6_es6.js | 21 ++ .../awaitCallExpression6_es6.symbols | 51 +++ .../reference/awaitCallExpression6_es6.types | 56 +++ .../reference/awaitCallExpression7_es6.js | 21 ++ .../awaitCallExpression7_es6.symbols | 51 +++ .../reference/awaitCallExpression7_es6.types | 56 +++ .../reference/awaitCallExpression8_es6.js | 21 ++ .../awaitCallExpression8_es6.symbols | 51 +++ .../reference/awaitCallExpression8_es6.types | 57 +++ .../reference/callWithSpreadES6.symbols | 2 +- ...tructuringParameterDeclaration3ES5.symbols | 16 +- ...tructuringParameterDeclaration3ES6.symbols | 16 +- ...owFunctionWhenUsingArguments14_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments15_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments16_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments17_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments18_ES6.symbols | 2 +- tests/baselines/reference/for-of13.symbols | 4 +- tests/baselines/reference/for-of18.symbols | 6 +- tests/baselines/reference/for-of19.symbols | 6 +- tests/baselines/reference/for-of20.symbols | 6 +- tests/baselines/reference/for-of21.symbols | 6 +- tests/baselines/reference/for-of22.symbols | 6 +- tests/baselines/reference/for-of23.symbols | 6 +- tests/baselines/reference/for-of25.symbols | 6 +- tests/baselines/reference/for-of26.symbols | 6 +- tests/baselines/reference/for-of27.symbols | 6 +- tests/baselines/reference/for-of28.symbols | 6 +- tests/baselines/reference/for-of37.symbols | 2 +- tests/baselines/reference/for-of38.symbols | 2 +- tests/baselines/reference/for-of40.symbols | 2 +- tests/baselines/reference/for-of44.symbols | 2 +- tests/baselines/reference/for-of45.symbols | 2 +- tests/baselines/reference/for-of50.symbols | 2 +- tests/baselines/reference/for-of57.symbols | 2 +- .../reference/iterableArrayPattern1.symbols | 8 +- .../reference/iterableArrayPattern11.symbols | 6 +- .../reference/iterableArrayPattern12.symbols | 6 +- .../reference/iterableArrayPattern13.symbols | 6 +- .../reference/iterableArrayPattern2.symbols | 8 +- .../reference/iterableArrayPattern3.symbols | 6 +- .../reference/iterableArrayPattern30.symbols | 2 +- .../reference/iterableArrayPattern4.symbols | 6 +- .../reference/iterableArrayPattern9.symbols | 6 +- .../iterableContextualTyping1.symbols | 2 +- .../reference/iteratorSpreadInArray.symbols | 8 +- .../reference/iteratorSpreadInArray11.symbols | 2 +- .../reference/iteratorSpreadInArray2.symbols | 14 +- .../reference/iteratorSpreadInArray3.symbols | 8 +- .../reference/iteratorSpreadInArray4.symbols | 8 +- .../reference/iteratorSpreadInArray7.symbols | 8 +- .../reference/iteratorSpreadInCall11.symbols | 8 +- .../reference/iteratorSpreadInCall12.symbols | 14 +- .../reference/iteratorSpreadInCall3.symbols | 8 +- .../reference/iteratorSpreadInCall5.symbols | 14 +- .../reference/parserSymbolProperty1.symbols | 6 +- .../reference/parserSymbolProperty2.symbols | 6 +- .../reference/parserSymbolProperty3.symbols | 6 +- .../reference/parserSymbolProperty4.symbols | 6 +- .../reference/parserSymbolProperty5.symbols | 6 +- .../reference/parserSymbolProperty6.symbols | 6 +- .../reference/parserSymbolProperty7.symbols | 6 +- .../reference/parserSymbolProperty8.symbols | 6 +- .../reference/parserSymbolProperty9.symbols | 6 +- .../reference/symbolDeclarationEmit1.symbols | 6 +- .../reference/symbolDeclarationEmit10.symbols | 12 +- .../reference/symbolDeclarationEmit11.symbols | 24 +- .../reference/symbolDeclarationEmit13.symbols | 12 +- .../reference/symbolDeclarationEmit14.symbols | 12 +- .../reference/symbolDeclarationEmit2.symbols | 6 +- .../reference/symbolDeclarationEmit3.symbols | 18 +- .../reference/symbolDeclarationEmit4.symbols | 12 +- .../reference/symbolDeclarationEmit5.symbols | 6 +- .../reference/symbolDeclarationEmit6.symbols | 6 +- .../reference/symbolDeclarationEmit7.symbols | 6 +- .../reference/symbolDeclarationEmit8.symbols | 6 +- .../reference/symbolDeclarationEmit9.symbols | 6 +- .../reference/symbolProperty11.symbols | 6 +- .../reference/symbolProperty13.symbols | 12 +- .../reference/symbolProperty14.symbols | 12 +- .../reference/symbolProperty15.symbols | 6 +- .../reference/symbolProperty16.symbols | 12 +- .../reference/symbolProperty18.symbols | 36 +- .../reference/symbolProperty19.symbols | 24 +- .../reference/symbolProperty2.symbols | 2 +- .../reference/symbolProperty20.symbols | 24 +- .../reference/symbolProperty21.symbols | 30 +- .../reference/symbolProperty22.symbols | 12 +- .../reference/symbolProperty23.symbols | 12 +- .../reference/symbolProperty26.symbols | 12 +- .../reference/symbolProperty27.symbols | 12 +- .../reference/symbolProperty28.symbols | 12 +- .../reference/symbolProperty4.symbols | 6 +- .../reference/symbolProperty40.symbols | 30 +- .../reference/symbolProperty41.symbols | 30 +- .../reference/symbolProperty45.symbols | 12 +- .../reference/symbolProperty5.symbols | 18 +- .../reference/symbolProperty50.symbols | 6 +- .../reference/symbolProperty51.symbols | 6 +- .../reference/symbolProperty55.symbols | 12 +- .../reference/symbolProperty56.symbols | 6 +- .../reference/symbolProperty57.symbols | 8 +- .../reference/symbolProperty6.symbols | 24 +- .../reference/symbolProperty8.symbols | 12 +- .../baselines/reference/symbolType11.symbols | 6 +- .../baselines/reference/symbolType16.symbols | 2 +- ...teStringWithEmbeddedNewOperatorES6.symbols | 2 +- tests/baselines/reference/typedArrays.symbols | 330 +++++++++--------- .../asyncArrowFunction10_es6.ts | 7 + .../asyncArrowFunction1_es6.ts | 5 + .../asyncArrowFunction2_es6.ts | 4 + .../asyncArrowFunction3_es6.ts | 4 + .../asyncArrowFunction4_es6.ts | 4 + .../asyncArrowFunction5_es6.ts | 5 + .../asyncArrowFunction6_es6.ts | 5 + .../asyncArrowFunction7_es6.ts | 8 + .../asyncArrowFunction8_es6.ts | 6 + .../asyncArrowFunction9_es6.ts | 4 + ...asyncArrowFunctionCapturesArguments_es6.ts | 8 + .../asyncArrowFunctionCapturesThis_es6.ts | 7 + .../conformance/async/es6/asyncClass_es6.ts | 4 + .../async/es6/asyncConstructor_es6.ts | 6 + .../conformance/async/es6/asyncDeclare_es6.ts | 3 + .../conformance/async/es6/asyncEnum_es6.ts | 5 + .../conformance/async/es6/asyncGetter_es6.ts | 6 + .../async/es6/asyncInterface_es6.ts | 4 + .../conformance/async/es6/asyncModule_es6.ts | 4 + .../conformance/async/es6/asyncSetter_es6.ts | 6 + .../awaitBinaryExpression1_es6.ts | 9 + .../awaitBinaryExpression2_es6.ts | 9 + .../awaitBinaryExpression3_es6.ts | 9 + .../awaitBinaryExpression4_es6.ts | 9 + .../awaitBinaryExpression5_es6.ts | 10 + .../awaitCallExpression1_es6.ts | 13 + .../awaitCallExpression2_es6.ts | 13 + .../awaitCallExpression3_es6.ts | 13 + .../awaitCallExpression4_es6.ts | 13 + .../awaitCallExpression5_es6.ts | 13 + .../awaitCallExpression6_es6.ts | 13 + .../awaitCallExpression7_es6.ts | 13 + .../awaitCallExpression8_es6.ts | 13 + .../asyncFunctionDeclaration10_es6.ts | 4 + .../asyncFunctionDeclaration11_es6.ts | 4 + .../asyncFunctionDeclaration12_es6.ts | 3 + .../asyncFunctionDeclaration13_es6.ts | 6 + .../asyncFunctionDeclaration14_es6.ts | 5 + .../asyncFunctionDeclaration1_es6.ts | 4 + .../asyncFunctionDeclaration2_es6.ts | 4 + .../asyncFunctionDeclaration3_es6.ts | 4 + .../asyncFunctionDeclaration4_es6.ts | 4 + .../asyncFunctionDeclaration5_es6.ts | 4 + .../asyncFunctionDeclaration6_es6.ts | 4 + .../asyncFunctionDeclaration7_es6.ts | 7 + .../asyncFunctionDeclaration8_es6.ts | 3 + .../asyncFunctionDeclaration9_es6.ts | 5 + 280 files changed, 3208 insertions(+), 767 deletions(-) create mode 100644 tests/baselines/reference/asyncArrowFunction10_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction10_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction1_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction1_es6.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction1_es6.types create mode 100644 tests/baselines/reference/asyncArrowFunction2_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction2_es6.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction2_es6.types create mode 100644 tests/baselines/reference/asyncArrowFunction3_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction3_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction4_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction4_es6.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction4_es6.types create mode 100644 tests/baselines/reference/asyncArrowFunction5_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction5_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction6_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction6_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction7_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction7_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction8_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction8_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types create mode 100644 tests/baselines/reference/asyncClass_es6.errors.txt create mode 100644 tests/baselines/reference/asyncClass_es6.js create mode 100644 tests/baselines/reference/asyncConstructor_es6.errors.txt create mode 100644 tests/baselines/reference/asyncConstructor_es6.js create mode 100644 tests/baselines/reference/asyncDeclare_es6.errors.txt create mode 100644 tests/baselines/reference/asyncDeclare_es6.js create mode 100644 tests/baselines/reference/asyncEnum_es6.errors.txt create mode 100644 tests/baselines/reference/asyncEnum_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es6.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration12_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration13_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es6.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es6.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es6.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration3_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es6.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration5_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration6_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration7_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration8_es6.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration9_es6.js create mode 100644 tests/baselines/reference/asyncGetter_es6.errors.txt create mode 100644 tests/baselines/reference/asyncGetter_es6.js create mode 100644 tests/baselines/reference/asyncInterface_es6.errors.txt create mode 100644 tests/baselines/reference/asyncInterface_es6.js create mode 100644 tests/baselines/reference/asyncModule_es6.errors.txt create mode 100644 tests/baselines/reference/asyncModule_es6.js create mode 100644 tests/baselines/reference/asyncSetter_es6.errors.txt create mode 100644 tests/baselines/reference/asyncSetter_es6.js create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es6.js create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es6.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es6.types create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es6.js create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es6.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es6.types create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es6.js create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es6.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es6.types create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es6.js create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es6.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es6.types create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es6.js create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es6.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression1_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression1_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression1_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression2_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression2_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression2_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression3_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression3_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression3_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression4_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression4_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression4_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression5_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression5_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression5_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression6_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression6_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression6_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression7_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression7_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression7_es6.types create mode 100644 tests/baselines/reference/awaitCallExpression8_es6.js create mode 100644 tests/baselines/reference/awaitCallExpression8_es6.symbols create mode 100644 tests/baselines/reference/awaitCallExpression8_es6.types create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncClass_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncConstructor_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncDeclare_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncEnum_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncGetter_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncInterface_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncModule_es6.ts create mode 100644 tests/cases/conformance/async/es6/asyncSetter_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts create mode 100644 tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 13f527bd9f8ca..3532c778dd1fd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -102,7 +102,7 @@ module ts { let globalArraySymbol: Symbol; let globalESSymbolConstructorSymbol: Symbol; - let getGlobalPromiseSymbol: () => Symbol; + let getGlobalPromiseConstructorSymbol: () => Symbol; let globalObjectType: ObjectType; let globalFunctionType: ObjectType; @@ -139,7 +139,6 @@ module ts { let symbolLinks: SymbolLinks[] = []; let nodeLinks: NodeLinks[] = []; let potentialThisCollisions: Node[] = []; - var potentialArgumentsCollisions: Node[] = []; let diagnostics = createDiagnosticCollection(); @@ -5420,11 +5419,13 @@ module ts { // can explicitly bound arguments objects let container = getContainingFunction(node); if (symbol === argumentsSymbol) { - if (container.kind === SyntaxKind.ArrowFunction && languageVersion < ScriptTarget.ES6) { - error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } - else if (node.parserContextFlags & ParserContextFlags.Await) { - captureLexicalArguments(node, container); + if (container.kind === SyntaxKind.ArrowFunction) { + if (languageVersion < ScriptTarget.ES6) { + error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + else if (node.parserContextFlags & ParserContextFlags.Await) { + error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression); + } } } @@ -5434,7 +5435,6 @@ module ts { checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkCollisionWithCapturedArgumentsVariable(node, node); checkBlockScopedBindingCapturedInLoop(node, symbol); return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); @@ -5516,10 +5516,9 @@ module ts { // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES6); } - - if (node.parserContextFlags & ParserContextFlags.Await) { + else if (node.parserContextFlags & ParserContextFlags.Await) { // if 'this' is part of an async function, we will need to capture 'this' - needToCaptureLexicalThis = true; + needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES6); } switch (container.kind) { @@ -5561,14 +5560,6 @@ module ts { return anyType; } - function captureLexicalArguments(node: Node, container: Node): void { - if (node.parent.kind !== SyntaxKind.Parameter) { - getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; - } - - getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; - } - function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean { for (let n = node; n && n !== constructorDecl; n = n.parent) { if (n.kind === SyntaxKind.Parameter) { @@ -7303,7 +7294,7 @@ module ts { let widenedType = getWidenedType(type); return isAsync ? createPromiseType(widenedType, func) - : type; + : widenedType; } /// Returns a set of types relating to every return expression relating to a function block. @@ -7421,7 +7412,6 @@ module ts { if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { checkCollisionWithCapturedSuperVariable(node, (node).name); checkCollisionWithCapturedThisVariable(node, (node).name); - checkCollisionWithCapturedArgumentsVariable(node, (node).name); } return type; @@ -7574,13 +7564,7 @@ module ts { function checkAwaitExpression(node: AwaitExpression): Type { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Await)) { - var parameter = getContainingParameter(node); - if (parameter && parameter.parserContextFlags & ParserContextFlags.Await) { - grammarErrorAfterFirstToken(node, Diagnostics._0_expression_is_not_allowed_in_an_initializer, "await"); - } - else { - grammarErrorOnFirstToken(node, Diagnostics.await_expression_must_be_contained_within_an_async_function); - } + grammarErrorOnFirstToken(node, Diagnostics.await_expression_must_be_contained_within_an_async_function); } var operandType = checkExpression(node.expression); @@ -7994,13 +7978,7 @@ module ts { function checkYieldExpression(node: YieldExpression): void { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Yield)) { - let parameter = getContainingParameter(node); - if (parameter && (parameter.parserContextFlags & ParserContextFlags.GeneratorParameter)) { - grammarErrorAfterFirstToken(node, Diagnostics._0_expression_is_not_allowed_in_an_initializer, "yield"); - } - else { - grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); - } + grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); } else { grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported); @@ -8907,23 +8885,25 @@ module ts { // the "promised type" of a type is the type of the "value" argument of the "onfulfilled" callback. let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); if (globalPromiseLikeType !== emptyObjectType && isTypeAssignableTo(type, globalPromiseLikeType)) { - let awaitedTypes: Type[] = []; let thenProp = getPropertyOfType(type, "then"); - let thenType = getTypeOfSymbol(thenProp); - let thenSignatures = getSignaturesOfType(thenType, SignatureKind.Call); - for (let thenSignature of thenSignatures) { - thenSignature = getErasedSignature(thenSignature); - let onfulfilledParameterType = getTypeAtPosition(thenSignature, 0); - let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); - for (let onfulfilledParameterSignature of onfulfilledParameterSignatures) { - let valueParameterType = getTypeAtPosition(onfulfilledParameterSignature, 0); - if (valueParameterType !== type) { - awaitedTypes.push(valueParameterType); + if (thenProp) { + let awaitedTypes: Type[] = []; + let thenType = getTypeOfSymbol(thenProp); + let thenSignatures = getSignaturesOfType(thenType, SignatureKind.Call); + for (let thenSignature of thenSignatures) { + thenSignature = getErasedSignature(thenSignature); + let onfulfilledParameterType = getTypeAtPosition(thenSignature, 0); + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); + for (let onfulfilledParameterSignature of onfulfilledParameterSignatures) { + let valueParameterType = getTypeAtPosition(onfulfilledParameterSignature, 0); + if (valueParameterType !== type) { + awaitedTypes.push(valueParameterType); + } } } - } - - return getUnionType(awaitedTypes); + + return getUnionType(awaitedTypes); + } } return emptyObjectType; @@ -9142,7 +9122,6 @@ module ts { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithCapturedArgumentsVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } @@ -9262,12 +9241,6 @@ module ts { } } - function checkCollisionWithCapturedArgumentsVariable(node: Node, name: Identifier): void { - if (needCollisionCheckForIdentifier(node, name, "_arguments")) { - potentialArgumentsCollisions.push(node); - } - } - // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node: Node): void { let current = node; @@ -9286,25 +9259,6 @@ module ts { } } - function checkIfArgumentsIsCapturedInEnclosingScope(node: Node): void { - let current = node; - while (current) { - if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureArguments) { - let isDeclaration = node.kind !== SyntaxKind.Identifier; - if (isDeclaration) { - error((node).name, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_variable_declaration_arguments_to_capture_arguments_reference); - } - else { - error(node, Diagnostics.Expression_resolves_to_variable_declaration_arguments_that_compiler_uses_to_capture_arguments_reference); - } - - return; - } - - current = current.parent; - } - } - function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -9421,15 +9375,17 @@ module ts { } function getPromiseConstructor(node: SignatureDeclaration): EntityName { - if (node.type && node.type.kind === SyntaxKind.TypeReference) { - return (node.type).typeName; - } - - let globalPromiseSymbol = getGlobalPromiseSymbol(); - if (globalPromiseSymbol && globalPromiseSymbol === resolveName(node, "Promise", SymbolFlags.Value, undefined, undefined)) { - return globalPromiseSymbol.valueDeclaration.name; + if (isAsyncFunctionLike(node)) { + let links = getNodeLinks(node); + if (!links.promiseConstructor) { + if (node.type && node.type.kind === SyntaxKind.TypeReference) { + links.promiseConstructor = (node.type).typeName; + } + } + + return links.promiseConstructor; } - + return undefined; } @@ -9550,14 +9506,8 @@ module ts { } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithCapturedArgumentsVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } - - if (symbol === argumentsSymbol && (node.parserContextFlags & ParserContextFlags.Await)) { - let container = getContainingFunction(node); - captureLexicalArguments(node.name, container); - } } function checkVariableDeclaration(node: VariableDeclaration) { @@ -11258,7 +11208,6 @@ module ts { emitDecorate = false; emitParam = false; potentialThisCollisions.length = 0; - potentialArgumentsCollisions.length = 0; forEach(node.statements, checkSourceElement); checkFunctionExpressionBodies(node); @@ -11272,11 +11221,6 @@ module ts { potentialThisCollisions.length = 0; } - if (potentialArgumentsCollisions.length) { - forEach(potentialArgumentsCollisions, checkIfArgumentsIsCapturedInEnclosingScope); - potentialArgumentsCollisions.length = 0; - } - if (emitExtends) { links.flags |= NodeCheckFlags.EmitExtends; } @@ -12279,6 +12223,7 @@ module ts { serializeTypeOfNode, serializeParameterTypesOfNode, serializeReturnTypeOfNode, + getPromiseConstructor, }; } @@ -12313,10 +12258,10 @@ module ts { getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); - getGlobalPromiseSymbol = memoize(() => getGlobalTypeSymbol("Promise")); - getGlobalPromiseType = memoize(() => getTypeOfGlobalSymbol(getGlobalPromiseSymbol(), /*arity*/ 1)); + getGlobalPromiseType = memoize(() => getGlobalType("Promise", /*arity*/ 1)); getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = memoize(() => getGlobalValueSymbol("Promise")); getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); getGlobalThenableType = memoize(createThenableType); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 091cabb448027..39492ac534486 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -383,8 +383,7 @@ module ts { A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - Duplicate_identifier_arguments_Compiler_uses_variable_declaration_arguments_to_capture_arguments_reference: { code: 2522, category: DiagnosticCategory.Error, key: "Duplicate identifier '_arguments'. Compiler uses variable declaration '_arguments' to capture 'arguments' reference." }, - Expression_resolves_to_variable_declaration_arguments_that_compiler_uses_to_capture_arguments_reference: { code: 2523, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_arguments' that compiler uses to capture 'arguments' reference." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression." }, 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 431aec3f5316d..874c259a3b616 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1522,14 +1522,10 @@ "category": "Error", "code": 2521 }, - "Duplicate identifier '_arguments'. Compiler uses variable declaration '_arguments' to capture 'arguments' reference.": { + "The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression.": { "category": "Error", "code": 2522 }, - "Expression resolves to variable declaration '_arguments' that compiler uses to capture 'arguments' reference.": { - "category": "Error", - "code": 2523 - }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5a9a654ce60a7..e31989e672688 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -48,6 +48,21 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } };`; + const awaiterHelper = ` +var __awaiter = (this && this.__awaiter) || function (generator, ctor) { + function resolve(value) { return step(generator.next(value)); } + function reject(reason) { return step(generator["throw"](reason)); } + function step(result) { + while (true) { + var done = result.done, value = result.value, then; + if (done) return value; + if (value && typeof (then = value.then) === "function") return then.call(value, resolve, reject); + result = generator.next(value); + } + } + return new (ctor || Promise)(function (resolver) { resolver(resolve(undefined)); }); +}`; + let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; @@ -131,6 +146,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let extendsEmitted = false; let decorateEmitted = false; let paramEmitted = false; + let awaiterEmitted = false; let tempFlags = 0; let tempVariables: Identifier[]; let tempParameters: Identifier[]; @@ -1350,6 +1366,31 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.expression); } } + + function emitAwaitExpression(node: AwaitExpression) { + let needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(tokenToString(SyntaxKind.YieldKeyword)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + + function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) { + for (let current: Node = node; isExpression(current.parent); current = current.parent) { + if (current.parent.kind === SyntaxKind.BinaryExpression) { + if ((current.parent).left === current) { + return true; + } + } + } + + return false; + } function needsParenthesisForPropertyAccessOrInvocation(node: Expression) { switch (node.kind) { @@ -3280,38 +3321,96 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.parameters[0]); return; } + emitSignatureParameters(node); } - function emitSignatureAndBody(node: FunctionLikeDeclaration) { - let saveTempFlags = tempFlags; - let saveTempVariables = tempVariables; - let saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); + function emitAsyncSignatureAndBodyForES6(node: FunctionLikeDeclaration) { + let promiseConstructor = resolver.getPromiseConstructor(node); + let resolve = makeUniqueName("resolve"); + let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; + let args: string; + if (isArrowFunction) { + if (node.parameters.length) { + args = makeUniqueName("arguments"); + write(`(...${args}) => `); + } + else { + write("() => "); + } } else { - emitSignatureParameters(node); + args = "arguments"; + write("() {"); + increaseIndent(); + writeLine(); + write("return "); } - + + write("__awaiter(function *"); + + emitSignatureParameters(node); + emitFunctionBody(node); + write(".apply(this"); + if (args) { + write(`, ${args}`); + } + write(")"); + if (promiseConstructor) { + write(", "); + emit(promiseConstructor); + } + write(")"); + + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + + function emitFunctionBody(node: FunctionLikeDeclaration) { if (!node.body) { // There can be no body when there are parse errors. Just emit an empty block // in that case. write(" { }"); } - else if (node.body.kind === SyntaxKind.Block) { - emitBlockFunctionBody(node, node.body); + else { + if (node.body.kind === SyntaxKind.Block) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + + function emitSignatureAndBody(node: FunctionLikeDeclaration) { + let saveTempFlags = tempFlags; + let saveTempVariables = tempVariables; + let saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + + let isAsync = isAsyncFunctionLike(node); + if (isAsync && languageVersion === ScriptTarget.ES6) { + emitAsyncSignatureAndBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + + emitFunctionBody(node); } - + if (!isES6ExportedDeclaration(node)) { emitExportMemberAssignment(node); } @@ -3329,7 +3428,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES6 || node.flags & NodeFlags.Async) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -5636,6 +5735,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLines(paramHelper); paramEmitted = true; } + + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitAwaiter) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (isExternalModule(node) || compilerOptions.separateCompilation) { @@ -5806,6 +5910,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTypeOfExpression(node); case SyntaxKind.VoidExpression: return emitVoidExpression(node); + case SyntaxKind.AwaitExpression: + return emitAwaitExpression(node); case SyntaxKind.PrefixUnaryExpression: return emitPrefixUnaryExpression(node); case SyntaxKind.PostfixUnaryExpression: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index db9580871788f..a22ec28ecbcb7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -568,11 +568,11 @@ module ts { } function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { - let currentContextFlags = contextFlags & context; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + let setContextFlags = context & contextFlags; + if (setContextFlags) { + setContextFlag(false, setContextFlags); let result = func(); - setContextFlag(true, currentContextFlags); + setContextFlag(true, setContextFlags); return result; } @@ -582,7 +582,7 @@ module ts { function doInsideOfContext(context: ParserContextFlags, func: () => T): T { let unsetContextFlags = context & ~contextFlags; - if (!unsetContextFlags) { + if (unsetContextFlags) { setContextFlag(true, unsetContextFlags); let result = func(); setContextFlag(false, unsetContextFlags); @@ -594,11 +594,11 @@ module ts { } function allowInAnd(func: () => T): T { - return doInsideOfContext(ParserContextFlags.DisallowIn, func); + return doOutsideOfContext(ParserContextFlags.DisallowIn, func); } function disallowInAnd(func: () => T): T { - return doOutsideOfContext(ParserContextFlags.DisallowIn, func); + return doInsideOfContext(ParserContextFlags.DisallowIn, func); } function doInYieldContext(func: () => T): T { @@ -772,6 +772,12 @@ module ts { if (token === SyntaxKind.YieldKeyword && inYieldContext()) { return false; } + + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === SyntaxKind.AwaitKeyword && inAwaitContext()) { + return false; + } return token > SyntaxKind.LastReservedWord; } @@ -2642,12 +2648,11 @@ module ts { function tryParseParenthesizedArrowFunctionExpression(): Expression { let triState = isParenthesizedArrowFunctionExpression(); - if (triState === Tristate.False) { // It's definitely not a parenthesized arrow function expression. return undefined; } - + // If we definitely have an arrow function, then we can just parse one, not requiring a // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b23b46bc9bddf..f256c63056f4b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1304,6 +1304,7 @@ module ts { serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[]; serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[]; serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[]; + getPromiseConstructor(node: SignatureDeclaration): EntityName; } export const enum SymbolFlags { @@ -1423,22 +1424,20 @@ module ts { TypeChecked = 0x00000001, // Node has been type checked LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body - LexicalArguments = 0x00000008, // Lexical 'arguments' reference - CaptureArguments = 0x00000010, // Lexical 'arguments' used in body - EmitExtends = 0x00000020, // Emit __extends - EmitDecorate = 0x00000040, // Emit __decorate - EmitParam = 0x00000080, // Emit __param helper for decorators - EmitAwaiter = 0x00000100, // Emit __awaiter - EmitGenerator = 0x00000200, // Emit __generator - SuperInstance = 0x00000400, // Instance 'super' reference - SuperStatic = 0x00000800, // Static 'super' reference - ContextChecked = 0x00001000, // Contextual types have been assigned - PromiseCollision = 0x00002000, // Declaration collides with the global 'Promise' + EmitExtends = 0x00000008, // Emit __extends + EmitDecorate = 0x00000010, // Emit __decorate + EmitParam = 0x00000020, // Emit __param helper for decorators + EmitAwaiter = 0x00000040, // Emit __awaiter + EmitGenerator = 0x00000080, // Emit __generator + SuperInstance = 0x00000100, // Instance 'super' reference + SuperStatic = 0x00000200, // Static 'super' reference + ContextChecked = 0x00000400, // Contextual types have been assigned + PromiseCollision = 0x00000800, // Declaration collides with the global 'Promise' // Values for enum members have been computed, and any errors have been reported for them. - EnumValuesComputed = 0x00004000, - BlockScopedBindingInLoop = 0x00008000, - LexicalModuleMergesWithClass= 0x00010000, // Instantiated lexical module declaration is merged with a previous class declaration. + EnumValuesComputed = 0x00001000, + BlockScopedBindingInLoop = 0x00002000, + LexicalModuleMergesWithClass= 0x00004000, // Instantiated lexical module declaration is merged with a previous class declaration. } /* @internal */ @@ -1456,6 +1455,7 @@ module ts { assignmentChecks?: Map; // Cache of assignment checks hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side + promiseConstructor?: EntityName; } export const enum TypeFlags { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e5856077edcea..3536315853b45 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1705,7 +1705,7 @@ module ts { return false; } } - + export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { return (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) || (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 8c6b09c82d6bd..6efd10dce099f 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,20 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ==== function * foo(a = yield => yield) { - ~ -!!! error TS9001: Generators are not currently supported. + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~ +!!! error TS1005: ';' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index b5ea3f494a74b..13f69a47653b1 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS9000: 'yield' expressions are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,1 ~ !!! error TS9001: Generators are not currently supported. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index f129d3fa30b45..8b15522b136c1 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS9000: 'yield' expressions are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== @@ -12,6 +12,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,2 ~ !!! error TS9001: Generators are not currently supported. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS9000: 'yield' expressions are not currently supported. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression12_es6.errors.txt b/tests/baselines/reference/YieldExpression12_es6.errors.txt index 10843421a3f4a..04c50ca2c3497 100644 --- a/tests/baselines/reference/YieldExpression12_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression12_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): erro constructor() { yield foo ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: 'yield' expression must be contained within a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression14_es6.errors.txt b/tests/baselines/reference/YieldExpression14_es6.errors.txt index baeaf3ba30ed3..ddc427bacbe48 100644 --- a/tests/baselines/reference/YieldExpression14_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression14_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): erro foo() { yield foo ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: 'yield' expression must be contained within a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression15_es6.errors.txt b/tests/baselines/reference/YieldExpression15_es6.errors.txt index 5e548799f5d5b..12d16a52d0a96 100644 --- a/tests/baselines/reference/YieldExpression15_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression15_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ==== var v = () => { yield foo ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: 'yield' expression must be contained within a generator declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index c0d2e4c8fc8c3..0b3d71c6ae4bf 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ==== @@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): erro function bar() { yield foo; ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: 'yield' expression must be contained within a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression17_es6.errors.txt b/tests/baselines/reference/YieldExpression17_es6.errors.txt index b39f47b07f946..0bcefebede23a 100644 --- a/tests/baselines/reference/YieldExpression17_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression17_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ==== @@ -10,4 +10,4 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err ~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file +!!! error TS1163: 'yield' expression must be contained within a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression18_es6.errors.txt b/tests/baselines/reference/YieldExpression18_es6.errors.txt index 3a67acdebcdff..1fae530e44beb 100644 --- a/tests/baselines/reference/YieldExpression18_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression18_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ==== "use strict"; yield(foo); ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file +!!! error TS1163: 'yield' expression must be contained within a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression2_es6.errors.txt b/tests/baselines/reference/YieldExpression2_es6.errors.txt index 553dab51fc20f..9a3a4d69facd9 100644 --- a/tests/baselines/reference/YieldExpression2_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression2_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained within a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ==== yield foo; ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file +!!! error TS1163: 'yield' expression must be contained within a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index 3b435de2e51be..30f541751a151 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt new file mode 100644 index 0000000000000..2476eaec6e360 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,17): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,20): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(4,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts (5 errors) ==== + + var foo = async foo(): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.js b/tests/baselines/reference/asyncArrowFunction10_es6.js new file mode 100644 index 0000000000000..23b2c3af80edd --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.js @@ -0,0 +1,13 @@ +//// [asyncArrowFunction10_es6.ts] + +var foo = async foo(): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncArrowFunction10_es6.js] +var foo = async, foo = () => { + // Legal to use 'await' in a type context. + var v; +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js new file mode 100644 index 0000000000000..78a2899d056e3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction1_es6.ts] + +var foo = async (): Promise => { +}; + +//// [asyncArrowFunction1_es6.js] +var foo = () => __awaiter(function *() { +}.apply(this), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols new file mode 100644 index 0000000000000..dc2ed671c464b --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts === + +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.types b/tests/baselines/reference/asyncArrowFunction1_es6.types new file mode 100644 index 0000000000000..3ecfdeb79191a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts === + +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => {} : () => Promise +>Promise : Promise + +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.js b/tests/baselines/reference/asyncArrowFunction2_es6.js new file mode 100644 index 0000000000000..9d7f1d10ea65a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction2_es6.ts] +var f = (await) => { +} + +//// [asyncArrowFunction2_es6.js] +var f = (await) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.symbols b/tests/baselines/reference/asyncArrowFunction2_es6.symbols new file mode 100644 index 0000000000000..dd8b4ea23908b --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts === +var f = (await) => { +>f : Symbol(f, Decl(asyncArrowFunction2_es6.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction2_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.types b/tests/baselines/reference/asyncArrowFunction2_es6.types new file mode 100644 index 0000000000000..98808d175f868 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts === +var f = (await) => { +>f : (await: any) => void +>(await) => {} : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt new file mode 100644 index 0000000000000..d0f56df51dab3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.js b/tests/baselines/reference/asyncArrowFunction3_es6.js new file mode 100644 index 0000000000000..9616336d76a82 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction3_es6.ts] +function f(await = await) { +} + +//// [asyncArrowFunction3_es6.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.js b/tests/baselines/reference/asyncArrowFunction4_es6.js new file mode 100644 index 0000000000000..eb89d98bbeb80 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction4_es6.ts] +var await = () => { +} + +//// [asyncArrowFunction4_es6.js] +var await = () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.symbols b/tests/baselines/reference/asyncArrowFunction4_es6.symbols new file mode 100644 index 0000000000000..1c0010407209e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts === +var await = () => { +>await : Symbol(await, Decl(asyncArrowFunction4_es6.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.types b/tests/baselines/reference/asyncArrowFunction4_es6.types new file mode 100644 index 0000000000000..e23ff7861055a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts === +var await = () => { +>await : () => void +>() => {} : () => void +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt new file mode 100644 index 0000000000000..fed2962053245 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,18): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,33): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts (6 errors) ==== + + var foo = async (await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.js b/tests/baselines/reference/asyncArrowFunction5_es6.js new file mode 100644 index 0000000000000..ed4035e61754c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -0,0 +1,9 @@ +//// [asyncArrowFunction5_es6.ts] + +var foo = async (await): Promise => { +} + +//// [asyncArrowFunction5_es6.js] +var foo = async(await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt new file mode 100644 index 0000000000000..3afce3a812759 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,27): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (1 errors) ==== + + var foo = async (a = await): Promise => { + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js new file mode 100644 index 0000000000000..186ecc4cf19ec --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction6_es6.ts] + +var foo = async (a = await): Promise => { +} + +//// [asyncArrowFunction6_es6.js] +var foo = (...arguments_1) => __awaiter(function *(a = yield ) { +}.apply(this, arguments_1), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt new file mode 100644 index 0000000000000..db7e634b47986 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (1 errors) ==== + + var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js new file mode 100644 index 0000000000000..b1859159c92c5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunction7_es6.ts] + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} + +//// [asyncArrowFunction7_es6.js] +var bar = () => __awaiter(function *() { + // 'await' here is an identifier, and not an await expression. + var foo = (...arguments_1) => __awaiter(function *(a = yield ) { + }.apply(this, arguments_1), Promise); +}.apply(this), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt new file mode 100644 index 0000000000000..7252805cdcac7 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts(3,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts (1 errors) ==== + + var foo = async (): Promise => { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js new file mode 100644 index 0000000000000..3f98f3a4f63c2 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -0,0 +1,10 @@ +//// [asyncArrowFunction8_es6.ts] + +var foo = async (): Promise => { + var v = { [await]: foo } +} + +//// [asyncArrowFunction8_es6.js] +var foo = () => __awaiter(function *() { + var v = { [yield ]: foo }; +}.apply(this), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt new file mode 100644 index 0000000000000..623095e8a5e33 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts (6 errors) ==== + var foo = async (a = await => await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js new file mode 100644 index 0000000000000..fb2f9d28a17c4 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction9_es6.ts] +var foo = async (a = await => await): Promise => { +} + +//// [asyncArrowFunction9_es6.js] +var foo = async(a = await => await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt new file mode 100644 index 0000000000000..6b80a53f5293e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2522: The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts (1 errors) ==== + class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + ~~~~~~~~~ +!!! error TS2522: The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js new file mode 100644 index 0000000000000..96926ba8f41b3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -0,0 +1,16 @@ +//// [asyncArrowFunctionCapturesArguments_es6.ts] +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} + + +//// [asyncArrowFunctionCapturesArguments_es6.js] +class C { + method() { + function other() { } + var fn = () => __awaiter(function *() { return yield other.apply(this, arguments); }.apply(this)); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js new file mode 100644 index 0000000000000..572c5fbe04668 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunctionCapturesThis_es6.ts] +class C { + method() { + var fn = async () => await this; + } +} + + +//// [asyncArrowFunctionCapturesThis_es6.js] +class C { + method() { + var fn = () => __awaiter(function *() { return yield this; }.apply(this)); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols new file mode 100644 index 0000000000000..ae516bb7fe3be --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 0)) + + method() { +>method : Symbol(method, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 9)) + + var fn = async () => await this; +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesThis_es6.ts, 2, 9)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types new file mode 100644 index 0000000000000..f3cd0f2d2dea2 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts === +class C { +>C : C + + method() { +>method : () => void + + var fn = async () => await this; +>fn : () => Promise +>async () => await this : () => Promise +>this : C + } +} + diff --git a/tests/baselines/reference/asyncClass_es6.errors.txt b/tests/baselines/reference/asyncClass_es6.errors.txt new file mode 100644 index 0000000000000..ee8a3a85dbc80 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncClass_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncClass_es6.ts (1 errors) ==== + async class C { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es6.js b/tests/baselines/reference/asyncClass_es6.js new file mode 100644 index 0000000000000..b5e1498f70c3f --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.js @@ -0,0 +1,7 @@ +//// [asyncClass_es6.ts] +async class C { +} + +//// [asyncClass_es6.js] +class C { +} diff --git a/tests/baselines/reference/asyncConstructor_es6.errors.txt b/tests/baselines/reference/asyncConstructor_es6.errors.txt new file mode 100644 index 0000000000000..6eb18cf41a199 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncConstructor_es6.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. + + +==== tests/cases/conformance/async/es6/asyncConstructor_es6.ts (1 errors) ==== + class C { + async constructor() { + ~~~~~ +!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es6.js b/tests/baselines/reference/asyncConstructor_es6.js new file mode 100644 index 0000000000000..a0cfa7709dfa4 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.js @@ -0,0 +1,11 @@ +//// [asyncConstructor_es6.ts] +class C { + async constructor() { + } +} + +//// [asyncConstructor_es6.js] +class C { + constructor() { + } +} diff --git a/tests/baselines/reference/asyncDeclare_es6.errors.txt b/tests/baselines/reference/asyncDeclare_es6.errors.txt new file mode 100644 index 0000000000000..65a4068e140e7 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/async/es6/asyncDeclare_es6.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. + + +==== tests/cases/conformance/async/es6/asyncDeclare_es6.ts (1 errors) ==== + declare async function foo(): Promise; + ~~~~~ +!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es6.js b/tests/baselines/reference/asyncDeclare_es6.js new file mode 100644 index 0000000000000..096f43a248a16 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.js @@ -0,0 +1,4 @@ +//// [asyncDeclare_es6.ts] +declare async function foo(): Promise; + +//// [asyncDeclare_es6.js] diff --git a/tests/baselines/reference/asyncEnum_es6.errors.txt b/tests/baselines/reference/asyncEnum_es6.errors.txt new file mode 100644 index 0000000000000..a50853fd8ea43 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/asyncEnum_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncEnum_es6.ts (1 errors) ==== + async enum E { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + Value + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es6.js b/tests/baselines/reference/asyncEnum_es6.js new file mode 100644 index 0000000000000..074de3dd0aee1 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.js @@ -0,0 +1,10 @@ +//// [asyncEnum_es6.ts] +async enum E { + Value +} + +//// [asyncEnum_es6.js] +var E; +(function (E) { + E[E["Value"] = 0] = "Value"; +})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt new file mode 100644 index 0000000000000..15ceb3e60c763 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== + async function foo(a = await => await): Promise { + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js new file mode 100644 index 0000000000000..141c0cbab55cd --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration10_es6.ts] +async function foo(a = await => await): Promise { +} + +//// [asyncFunctionDeclaration10_es6.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js new file mode 100644 index 0000000000000..39bf2c20e7956 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration11_es6.ts] +async function await(): Promise { +} + +//// [asyncFunctionDeclaration11_es6.js] +function await() { + return __awaiter(function *() { + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols new file mode 100644 index 0000000000000..b432029637399 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === +async function await(): Promise { +>await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.types b/tests/baselines/reference/asyncFunctionDeclaration11_es6.types new file mode 100644 index 0000000000000..65896e7b3b5fd --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === +async function await(): Promise { +>await : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt new file mode 100644 index 0000000000000..978492f0744c8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts (4 errors) ==== + var v = async function await(): Promise { } + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. + ~ +!!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js new file mode 100644 index 0000000000000..dae33682ce6ae --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration12_es6.ts] +var v = async function await(): Promise { } + +//// [asyncFunctionDeclaration12_es6.js] +var v = , await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt new file mode 100644 index 0000000000000..6cf65ca4e3a6f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts (1 errors) ==== + async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js new file mode 100644 index 0000000000000..9666fb5d7c4fb --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -0,0 +1,14 @@ +//// [asyncFunctionDeclaration13_es6.ts] +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncFunctionDeclaration13_es6.js] +function foo() { + return __awaiter(function *() { + // Legal to use 'await' in a type context. + var v; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js new file mode 100644 index 0000000000000..2f694f0269686 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -0,0 +1,11 @@ +//// [asyncFunctionDeclaration14_es6.ts] +async function foo(): Promise { + return; +} + +//// [asyncFunctionDeclaration14_es6.js] +function foo() { + return __awaiter(function *() { + return; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols new file mode 100644 index 0000000000000..5354c67a195f0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.types b/tests/baselines/reference/asyncFunctionDeclaration14_es6.types new file mode 100644 index 0000000000000..7727ffafaeb59 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js new file mode 100644 index 0000000000000..75cb74a68a53e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration1_es6.ts] +async function foo(): Promise { +} + +//// [asyncFunctionDeclaration1_es6.js] +function foo() { + return __awaiter(function *() { + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols new file mode 100644 index 0000000000000..241290a489999 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.types b/tests/baselines/reference/asyncFunctionDeclaration1_es6.types new file mode 100644 index 0000000000000..5cba25724f071 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.js b/tests/baselines/reference/asyncFunctionDeclaration2_es6.js new file mode 100644 index 0000000000000..1c54b9bc056f4 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration2_es6.ts] +function f(await) { +} + +//// [asyncFunctionDeclaration2_es6.js] +function f(await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols new file mode 100644 index 0000000000000..c709d7f7386de --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts === +function f(await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration2_es6.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration2_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.types b/tests/baselines/reference/asyncFunctionDeclaration2_es6.types new file mode 100644 index 0000000000000..9c9a19f3e763f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts === +function f(await) { +>f : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt new file mode 100644 index 0000000000000..a480bf3d2b8be --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.js b/tests/baselines/reference/asyncFunctionDeclaration3_es6.js new file mode 100644 index 0000000000000..7038858d2c8cd --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration3_es6.ts] +function f(await = await) { +} + +//// [asyncFunctionDeclaration3_es6.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.js b/tests/baselines/reference/asyncFunctionDeclaration4_es6.js new file mode 100644 index 0000000000000..8bfb7bf642f91 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration4_es6.ts] +function await() { +} + +//// [asyncFunctionDeclaration4_es6.js] +function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols new file mode 100644 index 0000000000000..cdbe1f5a8db9e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts === +function await() { +>await : Symbol(await, Decl(asyncFunctionDeclaration4_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.types b/tests/baselines/reference/asyncFunctionDeclaration4_es6.types new file mode 100644 index 0000000000000..537661e2c661e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts === +function await() { +>await : () => void +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt new file mode 100644 index 0000000000000..a6944e0c6e665 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (5 errors) ==== + async function foo(await): Promise { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js new file mode 100644 index 0000000000000..8d28c371465f8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration5_es6.ts] +async function foo(await): Promise { +} + +//// [asyncFunctionDeclaration5_es6.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt new file mode 100644 index 0000000000000..e719ed801e614 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (1 errors) ==== + async function foo(a = await): Promise { + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js new file mode 100644 index 0000000000000..2a3ffaa94dd70 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration6_es6.ts] +async function foo(a = await): Promise { +} + +//// [asyncFunctionDeclaration6_es6.js] +function foo() { + return __awaiter(function *(a = yield ) { + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt new file mode 100644 index 0000000000000..01643ffcdbb2f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,31): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (1 errors) ==== + async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js new file mode 100644 index 0000000000000..c22870b08fef0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -0,0 +1,17 @@ +//// [asyncFunctionDeclaration7_es6.ts] +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} + +//// [asyncFunctionDeclaration7_es6.js] +function bar() { + return __awaiter(function *() { + // 'await' here is an identifier, and not a yield expression. + function foo() { + return __awaiter(function *(a = yield ) { + }.apply(this, arguments), Promise); + } + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt new file mode 100644 index 0000000000000..c785ae41b170c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts (2 errors) ==== + var v = { [await]: foo } + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.js b/tests/baselines/reference/asyncFunctionDeclaration8_es6.js new file mode 100644 index 0000000000000..a363015f8abc8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration8_es6.ts] +var v = { [await]: foo } + +//// [asyncFunctionDeclaration8_es6.js] +var v = { [await]: foo }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt new file mode 100644 index 0000000000000..235ef165bed2e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts (1 errors) ==== + async function foo(): Promise { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js new file mode 100644 index 0000000000000..8b5ea4c4b5c4b --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -0,0 +1,11 @@ +//// [asyncFunctionDeclaration9_es6.ts] +async function foo(): Promise { + var v = { [await]: foo } +} + +//// [asyncFunctionDeclaration9_es6.js] +function foo() { + return __awaiter(function *() { + var v = { [yield ]: foo }; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncGetter_es6.errors.txt b/tests/baselines/reference/asyncGetter_es6.errors.txt new file mode 100644 index 0000000000000..5f5a9f6b1d7f9 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + + +==== tests/cases/conformance/async/es6/asyncGetter_es6.ts (2 errors) ==== + class C { + async get foo() { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + ~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es6.js b/tests/baselines/reference/asyncGetter_es6.js new file mode 100644 index 0000000000000..606f4d95dc7f6 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.js @@ -0,0 +1,11 @@ +//// [asyncGetter_es6.ts] +class C { + async get foo() { + } +} + +//// [asyncGetter_es6.js] +class C { + get foo() { + } +} diff --git a/tests/baselines/reference/asyncInterface_es6.errors.txt b/tests/baselines/reference/asyncInterface_es6.errors.txt new file mode 100644 index 0000000000000..c7519ba040e17 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncInterface_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncInterface_es6.ts (1 errors) ==== + async interface I { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es6.js b/tests/baselines/reference/asyncInterface_es6.js new file mode 100644 index 0000000000000..36314fa2141a7 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.js @@ -0,0 +1,5 @@ +//// [asyncInterface_es6.ts] +async interface I { +} + +//// [asyncInterface_es6.js] diff --git a/tests/baselines/reference/asyncModule_es6.errors.txt b/tests/baselines/reference/asyncModule_es6.errors.txt new file mode 100644 index 0000000000000..91e5e8ccdd3c5 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncModule_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncModule_es6.ts (1 errors) ==== + async module M { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es6.js b/tests/baselines/reference/asyncModule_es6.js new file mode 100644 index 0000000000000..e3e9306dbcbe6 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.js @@ -0,0 +1,5 @@ +//// [asyncModule_es6.ts] +async module M { +} + +//// [asyncModule_es6.js] diff --git a/tests/baselines/reference/asyncSetter_es6.errors.txt b/tests/baselines/reference/asyncSetter_es6.errors.txt new file mode 100644 index 0000000000000..e60e05cbc550e --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncSetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncSetter_es6.ts (1 errors) ==== + class C { + async set foo(value) { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es6.js b/tests/baselines/reference/asyncSetter_es6.js new file mode 100644 index 0000000000000..303e483f9a96c --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.js @@ -0,0 +1,11 @@ +//// [asyncSetter_es6.ts] +class C { + async set foo(value) { + } +} + +//// [asyncSetter_es6.js] +class C { + set foo(value) { + } +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js new file mode 100644 index 0000000000000..f92324dcdacbc --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression1_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p || a; + "after"; +} + +//// [awaitBinaryExpression1_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = (yield p) || a; + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols new file mode 100644 index 0000000000000..373086ecbac5f --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = await p || a; +>b : Symbol(b, Decl(awaitBinaryExpression1_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.types b/tests/baselines/reference/awaitBinaryExpression1_es6.types new file mode 100644 index 0000000000000..59370dda14b6e --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p || a; +>b : boolean +>await p || a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js new file mode 100644 index 0000000000000..e2d3b3ba46f4f --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression2_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p && a; + "after"; +} + +//// [awaitBinaryExpression2_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = (yield p) && a; + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols new file mode 100644 index 0000000000000..9331ad13ce58f --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = await p && a; +>b : Symbol(b, Decl(awaitBinaryExpression2_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.types b/tests/baselines/reference/awaitBinaryExpression2_es6.types new file mode 100644 index 0000000000000..c3f33bca2fafe --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p && a; +>b : boolean +>await p && a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js new file mode 100644 index 0000000000000..08e98d5dafee0 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression3_es6.ts] +declare var a: number; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p + a; + "after"; +} + +//// [awaitBinaryExpression3_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = (yield p) + a; + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols new file mode 100644 index 0000000000000..b1acda7013630 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts === +declare var a: number; +>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = await p + a; +>b : Symbol(b, Decl(awaitBinaryExpression3_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.types b/tests/baselines/reference/awaitBinaryExpression3_es6.types new file mode 100644 index 0000000000000..786eabadae47f --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts === +declare var a: number; +>a : number + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p + a; +>b : number +>await p + a : number +>p : any +>a : number + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js new file mode 100644 index 0000000000000..0eec5e990a544 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression4_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p, a; + "after"; +} + +//// [awaitBinaryExpression4_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = yield p, a; + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols new file mode 100644 index 0000000000000..c1a3bd903f4de --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = await p, a; +>b : Symbol(b, Decl(awaitBinaryExpression4_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 4, 20)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.types b/tests/baselines/reference/awaitBinaryExpression4_es6.types new file mode 100644 index 0000000000000..73126b7797d75 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p, a; +>b : boolean +>p : any +>a : any + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js new file mode 100644 index 0000000000000..d725d55404add --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -0,0 +1,19 @@ +//// [awaitBinaryExpression5_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var o: { a: boolean; }; + o.a = await p; + "after"; +} + +//// [awaitBinaryExpression5_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var o; + o.a = yield p; + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols new file mode 100644 index 0000000000000..cb74dcff7f62e --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var o: { a: boolean; }; +>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) + + o.a = await p; +>o.a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) +>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.types b/tests/baselines/reference/awaitBinaryExpression5_es6.types new file mode 100644 index 0000000000000..922e5887a770a --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var o: { a: boolean; }; +>o : { a: boolean; } +>a : boolean + + o.a = await p; +>o.a = await p : boolean +>o.a : boolean +>o : { a: boolean; } +>a : boolean +>p : any + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js new file mode 100644 index 0000000000000..3391274ae7a5d --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression1_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, a, a); + "after"; +} + +//// [awaitCallExpression1_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = fn(a, a, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols new file mode 100644 index 0000000000000..f9756da1768e3 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression1_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression1_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.types b/tests/baselines/reference/awaitCallExpression1_es6.types new file mode 100644 index 0000000000000..334175b7edbcd --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(a, a, a); +>b : void +>fn(a, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js new file mode 100644 index 0000000000000..fd7129e84182e --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression2_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(await p, a, a); + "after"; +} + +//// [awaitCallExpression2_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = fn(yield p, a, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols new file mode 100644 index 0000000000000..2e5b8761163be --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression2_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression2_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.types b/tests/baselines/reference/awaitCallExpression2_es6.types new file mode 100644 index 0000000000000..6c7f02a578a0e --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(await p, a, a); +>b : void +>fn(await p, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>p : any +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js new file mode 100644 index 0000000000000..4f0d55185e2d4 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression3_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, await p, a); + "after"; +} + +//// [awaitCallExpression3_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = fn(a, yield p, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols new file mode 100644 index 0000000000000..331fbeb8e6eed --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression3_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression3_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.types b/tests/baselines/reference/awaitCallExpression3_es6.types new file mode 100644 index 0000000000000..24d22db3c8c8f --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(a, await p, a); +>b : void +>fn(a, await p, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js new file mode 100644 index 0000000000000..7ec6c6ff90e27 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression4_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await pfn)(a, a, a); + "after"; +} + +//// [awaitCallExpression4_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = (yield pfn)(a, a, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols new file mode 100644 index 0000000000000..cc3407610b78f --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression4_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = (await pfn)(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression4_es6.ts, 8, 7)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.types b/tests/baselines/reference/awaitCallExpression4_es6.types new file mode 100644 index 0000000000000..0411546642796 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = (await pfn)(a, a, a); +>b : void +>(await pfn)(a, a, a) : void +>(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>pfn : any +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js new file mode 100644 index 0000000000000..f41d0ae994fdc --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression5_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, a, a); + "after"; +} + +//// [awaitCallExpression5_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = o.fn(a, a, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols new file mode 100644 index 0000000000000..0063434d0fb0e --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression5_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = o.fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression5_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression5_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.types b/tests/baselines/reference/awaitCallExpression5_es6.types new file mode 100644 index 0000000000000..5074c007743c3 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(a, a, a); +>b : void +>o.fn(a, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js new file mode 100644 index 0000000000000..d6c0e3707483d --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression6_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(await p, a, a); + "after"; +} + +//// [awaitCallExpression6_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = o.fn(yield p, a, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols new file mode 100644 index 0000000000000..9f99f55f26c6b --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = o.fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression6_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.types b/tests/baselines/reference/awaitCallExpression6_es6.types new file mode 100644 index 0000000000000..d18377cebbbc4 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(await p, a, a); +>b : void +>o.fn(await p, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>p : any +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js new file mode 100644 index 0000000000000..45e8a9fa64679 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression7_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, await p, a); + "after"; +} + +//// [awaitCallExpression7_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = o.fn(a, yield p, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols new file mode 100644 index 0000000000000..d9dd6535bc292 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = o.fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression7_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.types b/tests/baselines/reference/awaitCallExpression7_es6.types new file mode 100644 index 0000000000000..b213a75dcd6a2 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(a, await p, a); +>b : void +>o.fn(a, await p, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js new file mode 100644 index 0000000000000..3ffac0006aecb --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression8_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await po).fn(a, a, a); + "after"; +} + +//// [awaitCallExpression8_es6.js] +function func() { + return __awaiter(function *() { + "before"; + var b = (yield po).fn(a, a, a); + "after"; + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols new file mode 100644 index 0000000000000..1a2097d041d84 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression8_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) + + "before"; + var b = (await po).fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression8_es6.ts, 8, 7)) +>(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.types b/tests/baselines/reference/awaitCallExpression8_es6.types new file mode 100644 index 0000000000000..37511a7e3d790 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.types @@ -0,0 +1,57 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = (await po).fn(a, a, a); +>b : void +>(await po).fn(a, a, a) : void +>(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>po : any +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 94e0b94b002be..c29c41bff20f9 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1355, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1366, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index 033ad46ece1b8..6a4eb82af97e9 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index d23b624a023f5..22340c6aa60d3 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 18e1063f1e639..611db6485b906 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 6885b359416aa..7a3c26204242a 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index ae6be6f7951f7..c9658b4d90d83 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index c8bf211897a49..df5ab202dfcbc 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index cc867dd2c72ef..c4fc2e434e857 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index 833ea1d6875e7..bcd19f1a4d414 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1464, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 1464, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 2c08338ce73b3..a61af49253804 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 6be3c83964adc..c2d2d07841559 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 97200f93f3589..251a5b28fcae2 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index bbe3504294c7e..0b6b6f23cc0d8 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 4f15b54135628..cc4fcf55a7c84 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 0f409605e2806..8c7455a2dbc33 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 44cc83143af28..dae7d4bae7f32 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 0218a8b9995be..34766b1bc8c11 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 82918a19986fb..aa44808cd736c 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index e4324b05779a5..caf0356df220f 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 93f6c4f7dd6fe..73455ff17e671 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index fab42d9172459..bfbe035730c89 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index 1cd3538f98747..ed6ecb128f7fb 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index 9c6afa04adb77..adcd2ae376000 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 9fda4cb4e0a64..2f4a85111471d 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index c176e1aca0cf1..6813cd4eee548 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index 27aed0777ba7f..e8be8da6f9ca6 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1674, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index c6025123179d6..02f2ad6e8ef52 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 07b1fb52af845..9bbe4bfb983f7 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 001cb99b4865a..1a8634862ea20 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index 7085fd224f408..3c8a8c1ba5221 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 09a6984cb3cb7..a28e682c9ed88 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 4ee65a10825de..46087c2f8bb6d 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 0f50713b43d6c..e4c5de1770433 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index aa5ce5783a011..2b0c26918e413 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 01cfba0f09efb..90adcfeba92cf 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index 76d94dc29233b..43c6d7135e08d 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1674, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index f53e8266baaab..3c1cf17480d64 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index b128803aa50f7..d1eb5420ef119 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1674, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index db8da1bac9d2e..42c7e7e626ea8 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index bdc200c25ec92..8a7abd3f19589 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index c49ea74dc23f2..03aca3c69b36e 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index e7fbdac226482..e8c6571943e25 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index 54ac770c5dfcf..d695457621f5d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 8b24ba5d1b766..58ed5ea493530 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index d43a7f9b4fca8..ac81fdea2618e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 9d86858eb8eb0..da79720409de3 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 54d674ea0a83d..9b0b706077d60 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 51fdb40efd49e..f13748e9996d9 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index 11b6d8de94fcd..cb4ff68a63766 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index b2ffc2c89d222..34f550b750b9d 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index e896ebbd2a281..5257941831b89 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 1859c954ba479..77770a62bd575 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index a91a8227ae496..3e912a18a2fdb 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index dee98ed1e77bf..dcf4a037db2ff 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index cffbded17e64b..f706a35e3b5af 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index f24cfe2b783fd..6b17c421a0731 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 375bcf2174ab7..e620614d829eb 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index 90290569e0792..3cbae021c32e5 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index 66f540a8caeaf..9e6b00fbc45a8 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index 5927b8a6a298f..610a6bae9cd61 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 3c214bd9c25a1..e0ba5ffc72a78 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index d3a3a31322352..712b233a744f4 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index d552300b70ece..3a24de2f0e331 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 7f5fc3cf51baf..5580b833c0814 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index fe60e2ecc3103..10c95ed620bc9 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index b044c5264d85a..42f6b86686737 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 797b422c7fc77..13331a49dc355 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index deaf1c1bb62d6..2b6984b6baef0 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index f8b758cbf6879..bff61ccc01476 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 246ca2f085148..1b0026c5ea4bb 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index 4531b13dca132..358819f47b393 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index 6027f5e797e0d..fe630f8f82d1f 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index f7700e3b777b2..d87416cd43a6c 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index bc23c468a22cd..4597eb81c0f22 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index a0274f2c7622d..d3295b6507e3d 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index c6bb74bef3103..ea698562ed2be 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index 04c76275b55ed..714b771b67e3f 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols index 544813c305638..f2061b3bb2cd0 100644 --- a/tests/baselines/reference/symbolProperty21.symbols +++ b/tests/baselines/reference/symbolProperty21.symbols @@ -5,15 +5,15 @@ interface I { >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) >T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) [Symbol.isConcatSpreadable]: U; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) } @@ -34,18 +34,18 @@ foo({ >foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) [Symbol.unscopables]: true ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) }); diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index e9f6761e121ff..d1bee54bd7b69 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index d220f80c0f75a..94dc416010e09 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 819b93e614776..0850ec9cdaa59 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 7ead7b14b345d..ed56e55cca613 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index 9f57cd1e2e38a..e5cdbb0ea6101 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index a6594f5146b20..8a0d692de2281 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index 1f0fdaf91a7db..246d0952c8901 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index d50401a637ac0..2872f6cb13493 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 4c3d2595c1383..1f691f8827d4c 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1233, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1233, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index a759e09588e3f..e9bda77fd7152 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index ee785ae606d24..69a695e6c5bbf 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 825f73ebcd101..e045d35f13fce 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index e76ad43f43d1c..077199e496904 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1196, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1207, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index caca4686bbf48..a76ab0418cc47 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 4e0ce4203881d..e98cf96380723 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index cedcfe69a9f0b..8b0e62e406890 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 269a8412d95ac..a1a4d1d50dfb6 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index 4bf91a6112e3d..6c4001fa4c85a 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1219, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1219, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 1d87ae6a1a415..7a54b0efcbe72 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index 0cfe0d854beaf..a6e319c0dfa7e 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 27b72cc54f1cb..ef9f533bb58e3 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1445, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2381, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2381, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2392, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2392, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2671, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2671, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2682, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2682, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3251, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3251, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3262, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3262, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3541, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3541, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3552, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3552, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3831, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3831, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3842, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3842, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4121, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4121, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4132, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4132, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4411, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4411, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4422, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4422, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4701, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4701, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4712, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4712, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2961, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2961, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2972, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2972, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1445, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1445, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts new file mode 100644 index 0000000000000..0959ed6c561e8 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true + +var foo = async foo(): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts new file mode 100644 index 0000000000000..83e7413c5279a --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true + +var foo = async (): Promise => { +}; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts new file mode 100644 index 0000000000000..bf39735d4603f --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +var f = (await) => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts new file mode 100644 index 0000000000000..4ae27c596f1ab --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts new file mode 100644 index 0000000000000..51b34abeca1aa --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +var await = () => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts new file mode 100644 index 0000000000000..174a619bdf9f9 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true + +var foo = async (await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts new file mode 100644 index 0000000000000..dace96c4933da --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true + +var foo = async (a = await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts new file mode 100644 index 0000000000000..b1fd5cc030d97 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts new file mode 100644 index 0000000000000..5d53338b1bd78 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true + +var foo = async (): Promise => { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts new file mode 100644 index 0000000000000..da041fe472b30 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +var foo = async (a = await => await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts new file mode 100644 index 0000000000000..8dab2c0408630 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts new file mode 100644 index 0000000000000..f2c507cbdd667 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/cases/conformance/async/es6/asyncClass_es6.ts b/tests/cases/conformance/async/es6/asyncClass_es6.ts new file mode 100644 index 0000000000000..22ffe997b03cd --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncClass_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async class C { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncConstructor_es6.ts b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts new file mode 100644 index 0000000000000..d769fad039525 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +class C { + async constructor() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncDeclare_es6.ts b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts new file mode 100644 index 0000000000000..5e0fb536b395f --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts @@ -0,0 +1,3 @@ +// @target: ES6 +// @noEmitHelpers: true +declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncEnum_es6.ts b/tests/cases/conformance/async/es6/asyncEnum_es6.ts new file mode 100644 index 0000000000000..4fad7923a8c93 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncEnum_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +async enum E { + Value +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncGetter_es6.ts b/tests/cases/conformance/async/es6/asyncGetter_es6.ts new file mode 100644 index 0000000000000..79fde60fdc4bb --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncGetter_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +class C { + async get foo() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncInterface_es6.ts b/tests/cases/conformance/async/es6/asyncInterface_es6.ts new file mode 100644 index 0000000000000..5d5497d3cd4bf --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncInterface_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async interface I { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncModule_es6.ts b/tests/cases/conformance/async/es6/asyncModule_es6.ts new file mode 100644 index 0000000000000..aa4c295d0e357 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncModule_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async module M { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncSetter_es6.ts b/tests/cases/conformance/async/es6/asyncSetter_es6.ts new file mode 100644 index 0000000000000..8eedcbb5288a2 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncSetter_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +class C { + async set foo(value) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts new file mode 100644 index 0000000000000..46060f309b241 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p || a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts new file mode 100644 index 0000000000000..362f1ecc4463f --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p && a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts new file mode 100644 index 0000000000000..d3b02033252e1 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: number; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p + a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts new file mode 100644 index 0000000000000..eba3be31acfbc --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p, a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts new file mode 100644 index 0000000000000..71b173f9e73a7 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var o: { a: boolean; }; + o.a = await p; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts new file mode 100644 index 0000000000000..d0442f0968dc4 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts new file mode 100644 index 0000000000000..6de07ef12ffee --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(await p, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts new file mode 100644 index 0000000000000..2cc0b7b12d071 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, await p, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts new file mode 100644 index 0000000000000..8e349fbc5c329 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await pfn)(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts new file mode 100644 index 0000000000000..bbe81ac94b110 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts new file mode 100644 index 0000000000000..09e88f5acbcdd --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(await p, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts new file mode 100644 index 0000000000000..fe0182da4aa1b --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, await p, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts new file mode 100644 index 0000000000000..e3280eb7c10ff --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await po).fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts new file mode 100644 index 0000000000000..aab1f0013ecf9 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(a = await => await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts new file mode 100644 index 0000000000000..747d20d7ea850 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async function await(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts new file mode 100644 index 0000000000000..bbd7725036512 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts @@ -0,0 +1,3 @@ +// @target: ES6 +// @noEmitHelpers: true +var v = async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts new file mode 100644 index 0000000000000..8670fa0281165 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts new file mode 100644 index 0000000000000..ba70c61b49241 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(): Promise { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts new file mode 100644 index 0000000000000..289a65bb74fe1 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts new file mode 100644 index 0000000000000..25a153b4a3412 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +function f(await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts new file mode 100644 index 0000000000000..4ae27c596f1ab --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts new file mode 100644 index 0000000000000..5d1ec389da366 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +function await() { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts new file mode 100644 index 0000000000000..eb3cd1db55675 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts new file mode 100644 index 0000000000000..89b0445fd2efd --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(a = await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts new file mode 100644 index 0000000000000..5a964695da5e5 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts new file mode 100644 index 0000000000000..764b0f3fb8a79 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts @@ -0,0 +1,3 @@ +// @target: ES6 +// @noEmitHelpers: true +var v = { [await]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts new file mode 100644 index 0000000000000..7671764ad2add --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +async function foo(): Promise { + var v = { [await]: foo } +} \ No newline at end of file From 80edb2de4a058ccd8594d8faad5f8e1f4cbe8962 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 7 May 2015 11:13:45 -0700 Subject: [PATCH 009/250] Bug fixes and baselines --- src/compiler/parser.ts | 58 +++++++++---------- src/compiler/types.ts | 4 +- tests/baselines/reference/APISample_linter.js | 20 +++---- .../FunctionDeclaration10_es6.errors.txt | 20 ++----- .../FunctionDeclaration6_es6.errors.txt | 4 +- .../FunctionDeclaration7_es6.errors.txt | 4 +- .../asyncArrowFunction6_es6.errors.txt | 6 +- .../reference/asyncArrowFunction6_es6.js | 2 +- .../asyncArrowFunction7_es6.errors.txt | 6 +- .../reference/asyncArrowFunction7_es6.js | 2 +- .../asyncArrowFunction9_es6.errors.txt | 23 -------- .../reference/asyncArrowFunction9_es6.js | 5 +- .../reference/asyncArrowFunction9_es6.symbols | 8 +++ .../reference/asyncArrowFunction9_es6.types | 10 ++++ .../asyncFunctionDeclaration10_es6.errors.txt | 26 --------- .../asyncFunctionDeclaration10_es6.js | 6 +- .../asyncFunctionDeclaration10_es6.symbols | 8 +++ .../asyncFunctionDeclaration10_es6.types | 9 +++ .../asyncFunctionDeclaration6_es6.errors.txt | 6 +- .../asyncFunctionDeclaration6_es6.js | 2 +- .../asyncFunctionDeclaration7_es6.errors.txt | 6 +- .../asyncFunctionDeclaration7_es6.js | 2 +- 22 files changed, 104 insertions(+), 133 deletions(-) delete mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.types delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.types diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a22ec28ecbcb7..db6a00ec9aa81 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -592,7 +592,7 @@ module ts { // no need to do anything special as we are already in all of the requested contexts return func(); } - + function allowInAnd(func: () => T): T { return doOutsideOfContext(ParserContextFlags.DisallowIn, func); } @@ -621,12 +621,16 @@ module ts { return doOutsideOfContext(ParserContextFlags.Await, func); } + function doInYieldAndAwaitContext(func: () => T): T { + return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); + } + function doOutsideOfYieldAndAwaitContext(func: () => T): T { return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); } function inContext(flags: ParserContextFlags) { - return (contextFlags & flags) === flags; + return (contextFlags & flags) !== 0; } function inYieldContext() { @@ -957,8 +961,8 @@ module ts { // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = inGeneratorParameterOrAsyncParameterContext() - ? doOutsideOfYieldAndAwaitContext(parseExpression) - : parseExpression(); + ? doOutsideOfYieldAndAwaitContext(allowInAndParseExpression) + : allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); @@ -1857,8 +1861,8 @@ module ts { function parseParameter(): ParameterDeclaration { let node = createNode(SyntaxKind.Parameter); node.decorators = parseDecorators(); - setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); + setModifiers(node, parseModifiers()); // FormalParameter[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.1 // BindingElement[?Yield,?GeneratorParameter,?Await,?AsyncParameter] @@ -1901,7 +1905,6 @@ module ts { // [+GeneratorParameter] BindingIdentifier[Yield] Initializer[In]opt // [+AsyncParameter] BindingIdentifier[Await] Initializer[In]opt // [~GeneratorParameter,~AsyncParameter] BindingIdentifier[?Yield,?Await] Initializer[In,?Yield,?Await]opt - let parseInitializer = inParameter ? parseParameterInitializer : parseNonParameterInitializer; return inGeneratorParameterOrAsyncParameterContext() ? doOutsideOfYieldAndAwaitContext(parseInitializer) @@ -1957,27 +1960,19 @@ module ts { let savedGeneratorParameterContext = inGeneratorParameterContext(); let savedAwaitContext = inAwaitContext(); let savedAsyncParameterContext = inAsyncParameterContext(); - - if (yieldAndGeneratorParameterContext) { - setYieldContext(true); - } + setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - - if (awaitAndAsyncParameterContext) { - setAwaitContext(true); - } - + setAwaitContext(awaitAndAsyncParameterContext); setAsyncParameterContext(awaitAndAsyncParameterContext); - + let result = parseDelimitedList(ParsingContext.Parameters, parseParameter); - + setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); - setAwaitContext(savedAwaitContext); setAsyncParameterContext(savedAsyncParameterContext); - + if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. @@ -1992,7 +1987,7 @@ module ts { // then just return an empty set of parameters. return requireCompleteParameterList ? undefined : createMissingList(); } - + function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. @@ -2368,7 +2363,7 @@ module ts { function parseType(): TypeNode { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(ParserContextFlags.ContextParameterFlags, parseTypeWorker); + return doOutsideOfContext(ParserContextFlags.AllParameterFlags, parseTypeWorker); } function parseTypeWorker(): TypeNode { @@ -2455,6 +2450,10 @@ module ts { token !== SyntaxKind.AtToken && isStartOfExpression(); } + + function allowInAndParseExpression(): Expression { + return allowInAnd(parseExpression); + } function parseExpression(): Expression { // Expression[in]: @@ -3449,20 +3448,15 @@ module ts { let node = createNode(SyntaxKind.FunctionExpression); setModifiers(node, parseModifiers()); parseExpected(SyntaxKind.FunctionKeyword); - node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); + node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - let savedYieldContext = inYieldContext(); let isGenerator = node.asteriskToken != undefined; - setYieldContext(isGenerator); - - let savedAwaitContext = inAwaitContext(); let isAsync = isAsyncFunctionLike(node); - setAwaitContext(isAsync); - - node.name = parseOptionalIdentifier(); - - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f256c63056f4b..86b4113eecc9c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -359,7 +359,9 @@ module ts { ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | AsyncParameter | Await, // Context flags passed as part of the modified ES6 grammar. - ContextParameterFlags = Yield | GeneratorParameter | AsyncParameter | Await, + YieldAndGeneratorParameterFlags = Yield | GeneratorParameter, + AwaitAndAsyncParameterFlags = Await | AsyncParameter, + AllParameterFlags = YieldAndGeneratorParameterFlags | AwaitAndAsyncParameterFlags, // Context flags computed by aggregating child flags upwards. diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index cd2df23ffbf4f..5c2a8953a6123 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - if (node.statement.kind !== 180 /* Block */) { + case 190 /* ForStatement */: + case 191 /* ForInStatement */: + case 189 /* WhileStatement */: + case 188 /* DoStatement */: + if (node.statement.kind !== 183 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 184 /* IfStatement */: + case 187 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 180 /* Block */) { + if (ifStatement.thenStatement.kind !== 183 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 180 /* Block */ && - ifStatement.elseStatement.kind !== 184 /* IfStatement */) { + ifStatement.elseStatement.kind !== 183 /* Block */ && + ifStatement.elseStatement.kind !== 187 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 170 /* BinaryExpression */: + case 173 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 6efd10dce099f..8c6b09c82d6bd 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,20 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== function * foo(a = yield => yield) { - ~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~~ -!!! error TS1005: ',' expected. - ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. - ~ -!!! error TS1005: ';' expected. + ~ +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 13f69a47653b1..b5ea3f494a74b 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,1 ~ !!! error TS9001: Generators are not currently supported. ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. +!!! error TS2304: Cannot find name 'yield'. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 8b15522b136c1..f129d3fa30b45 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== @@ -12,6 +12,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,2 ~ !!! error TS9001: Generators are not currently supported. ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. +!!! error TS2304: Cannot find name 'yield'. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt index 3afce3a812759..c5a34f513b029 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,27): error TS1109: Expression expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,22): error TS2304: Cannot find name 'await'. ==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (1 errors) ==== var foo = async (a = await): Promise => { - ~ -!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js index 186ecc4cf19ec..e4da75e3cd157 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.js +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -4,5 +4,5 @@ var foo = async (a = await): Promise => { } //// [asyncArrowFunction6_es6.js] -var foo = (...arguments_1) => __awaiter(function *(a = yield ) { +var foo = (...arguments_1) => __awaiter(function *(a = await) { }.apply(this, arguments_1), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt index db7e634b47986..823d779c601c5 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,29): error TS1109: Expression expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,24): error TS2304: Cannot find name 'await'. ==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts( var bar = async (): Promise => { // 'await' here is an identifier, and not an await expression. var foo = async (a = await): Promise => { - ~ -!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js index b1859159c92c5..9bf3fdc480f0a 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.js +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -9,6 +9,6 @@ var bar = async (): Promise => { //// [asyncArrowFunction7_es6.js] var bar = () => __awaiter(function *() { // 'await' here is an identifier, and not an await expression. - var foo = (...arguments_1) => __awaiter(function *(a = yield ) { + var foo = (...arguments_1) => __awaiter(function *(a = await) { }.apply(this, arguments_1), Promise); }.apply(this), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt deleted file mode 100644 index 623095e8a5e33..0000000000000 --- a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected. - - -==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts (6 errors) ==== - var foo = async (a = await => await): Promise => { - ~~~~~ -!!! error TS2304: Cannot find name 'async'. - ~ -!!! error TS2304: Cannot find name 'a'. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. - ~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS1109: Expression expected. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js index fb2f9d28a17c4..b78a49afdbb76 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -3,6 +3,5 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es6.js] -var foo = async(a = await => await), Promise = ; -{ -} +var foo = (...arguments_1) => __awaiter(function *(a = await => await) { +}.apply(this, arguments_1), Promise); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.symbols b/tests/baselines/reference/asyncArrowFunction9_es6.symbols new file mode 100644 index 0000000000000..8db4592f0e13a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts === +var foo = async (a = await => await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction9_es6.ts, 0, 3)) +>a : Symbol(a, Decl(asyncArrowFunction9_es6.ts, 0, 17)) +>await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) +>await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.types b/tests/baselines/reference/asyncArrowFunction9_es6.types new file mode 100644 index 0000000000000..9f6244c4a0eed --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts === +var foo = async (a = await => await): Promise => { +>foo : (a?: (await: any) => any) => Promise +>async (a = await => await): Promise => {} : (a?: (await: any) => any) => Promise +>a : (await: any) => any +>await => await : (await: any) => any +>await : any +>await : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt deleted file mode 100644 index 15ceb3e60c763..0000000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. - - -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== - async function foo(a = await => await): Promise { - ~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~~ -!!! error TS1109: Expression expected. - ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS1109: Expression expected. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 141c0cbab55cd..e85492bee709b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -3,5 +3,7 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es6.js] -await; -Promise < void > {}; +function foo() { + return __awaiter(function *(a = await => await) { + }.apply(this, arguments), Promise); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols new file mode 100644 index 0000000000000..d4f4dcedcd032 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === +async function foo(a = await => await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es6.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) +>await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) +>await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.types b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types new file mode 100644 index 0000000000000..0018b994e0026 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === +async function foo(a = await => await): Promise { +>foo : (a?: (await: any) => any) => Promise +>a : (await: any) => any +>await => await : (await: any) => any +>await : any +>await : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt index e719ed801e614..e89029e7c5f10 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,29): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,24): error TS2304: Cannot find name 'await'. ==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (1 errors) ==== async function foo(a = await): Promise { - ~ -!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js index 2a3ffaa94dd70..663e02604ead1 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -4,6 +4,6 @@ async function foo(a = await): Promise { //// [asyncFunctionDeclaration6_es6.js] function foo() { - return __awaiter(function *(a = yield ) { + return __awaiter(function *(a = await) { }.apply(this, arguments), Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt index 01643ffcdbb2f..b29fed652d866 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,31): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,26): error TS2304: Cannot find name 'await'. ==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (1 errors) ==== async function bar(): Promise { // 'await' here is an identifier, and not a yield expression. async function foo(a = await): Promise { - ~ -!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js index c22870b08fef0..fb913e3f6f435 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -10,7 +10,7 @@ function bar() { return __awaiter(function *() { // 'await' here is an identifier, and not a yield expression. function foo() { - return __awaiter(function *(a = yield ) { + return __awaiter(function *(a = await) { }.apply(this, arguments), Promise); } }.apply(this, arguments), Promise); From bca21ecf48bc3642c8174c0b258fc76fd427ef24 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 7 May 2015 18:30:38 -0700 Subject: [PATCH 010/250] Updated baselines --- .../reference/arrayLiterals2ES6.symbols | 6 +- .../reference/asyncArrowFunction1_es6.symbols | 2 +- .../reference/asyncArrowFunction9_es6.symbols | 2 +- .../asyncFunctionDeclaration10_es6.symbols | 2 +- .../asyncFunctionDeclaration11_es6.symbols | 2 +- .../asyncFunctionDeclaration14_es6.symbols | 2 +- .../asyncFunctionDeclaration1_es6.symbols | 2 +- .../awaitBinaryExpression1_es6.symbols | 4 +- .../awaitBinaryExpression2_es6.symbols | 4 +- .../awaitBinaryExpression3_es6.symbols | 4 +- .../awaitBinaryExpression4_es6.symbols | 4 +- .../awaitBinaryExpression5_es6.symbols | 4 +- .../awaitCallExpression1_es6.symbols | 8 +- .../awaitCallExpression2_es6.symbols | 8 +- .../awaitCallExpression3_es6.symbols | 8 +- .../awaitCallExpression4_es6.symbols | 8 +- .../awaitCallExpression5_es6.symbols | 8 +- .../awaitCallExpression6_es6.symbols | 8 +- .../awaitCallExpression7_es6.symbols | 8 +- .../awaitCallExpression8_es6.symbols | 8 +- .../reference/callWithSpreadES6.symbols | 2 +- ...tructuringParameterDeclaration3ES5.symbols | 16 +- ...tructuringParameterDeclaration3ES6.symbols | 16 +- ...owFunctionWhenUsingArguments14_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments15_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments16_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments17_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments18_ES6.symbols | 2 +- tests/baselines/reference/for-of13.symbols | 4 +- tests/baselines/reference/for-of18.symbols | 6 +- tests/baselines/reference/for-of19.symbols | 6 +- tests/baselines/reference/for-of20.symbols | 6 +- tests/baselines/reference/for-of21.symbols | 6 +- tests/baselines/reference/for-of22.symbols | 6 +- tests/baselines/reference/for-of23.symbols | 6 +- tests/baselines/reference/for-of25.symbols | 6 +- tests/baselines/reference/for-of26.symbols | 6 +- tests/baselines/reference/for-of27.symbols | 6 +- tests/baselines/reference/for-of28.symbols | 6 +- tests/baselines/reference/for-of37.symbols | 2 +- tests/baselines/reference/for-of38.symbols | 2 +- tests/baselines/reference/for-of40.symbols | 2 +- tests/baselines/reference/for-of44.symbols | 2 +- tests/baselines/reference/for-of45.symbols | 2 +- tests/baselines/reference/for-of50.symbols | 2 +- tests/baselines/reference/for-of57.symbols | 2 +- .../reference/iterableArrayPattern1.symbols | 8 +- .../reference/iterableArrayPattern11.symbols | 6 +- .../reference/iterableArrayPattern12.symbols | 6 +- .../reference/iterableArrayPattern13.symbols | 6 +- .../reference/iterableArrayPattern2.symbols | 8 +- .../reference/iterableArrayPattern3.symbols | 6 +- .../reference/iterableArrayPattern30.symbols | 2 +- .../reference/iterableArrayPattern4.symbols | 6 +- .../reference/iterableArrayPattern9.symbols | 6 +- .../iterableContextualTyping1.symbols | 2 +- .../reference/iteratorSpreadInArray.symbols | 8 +- .../reference/iteratorSpreadInArray11.symbols | 2 +- .../reference/iteratorSpreadInArray2.symbols | 14 +- .../reference/iteratorSpreadInArray3.symbols | 8 +- .../reference/iteratorSpreadInArray4.symbols | 8 +- .../reference/iteratorSpreadInArray7.symbols | 8 +- .../reference/iteratorSpreadInCall11.symbols | 8 +- .../reference/iteratorSpreadInCall12.symbols | 14 +- .../reference/iteratorSpreadInCall3.symbols | 8 +- .../reference/iteratorSpreadInCall5.symbols | 14 +- .../reference/parserSymbolProperty1.symbols | 6 +- .../reference/parserSymbolProperty2.symbols | 6 +- .../reference/parserSymbolProperty3.symbols | 6 +- .../reference/parserSymbolProperty4.symbols | 6 +- .../reference/parserSymbolProperty5.symbols | 6 +- .../reference/parserSymbolProperty6.symbols | 6 +- .../reference/parserSymbolProperty7.symbols | 6 +- .../reference/parserSymbolProperty8.symbols | 6 +- .../reference/parserSymbolProperty9.symbols | 6 +- .../promiseVoidErrorCallback.symbols | 16 +- .../reference/symbolDeclarationEmit1.symbols | 6 +- .../reference/symbolDeclarationEmit10.symbols | 12 +- .../reference/symbolDeclarationEmit11.symbols | 24 +- .../reference/symbolDeclarationEmit13.symbols | 12 +- .../reference/symbolDeclarationEmit14.symbols | 12 +- .../reference/symbolDeclarationEmit2.symbols | 6 +- .../reference/symbolDeclarationEmit3.symbols | 18 +- .../reference/symbolDeclarationEmit4.symbols | 12 +- .../reference/symbolDeclarationEmit5.symbols | 6 +- .../reference/symbolDeclarationEmit6.symbols | 6 +- .../reference/symbolDeclarationEmit7.symbols | 6 +- .../reference/symbolDeclarationEmit8.symbols | 6 +- .../reference/symbolDeclarationEmit9.symbols | 6 +- .../reference/symbolProperty11.symbols | 6 +- .../reference/symbolProperty13.symbols | 12 +- .../reference/symbolProperty14.symbols | 12 +- .../reference/symbolProperty15.symbols | 6 +- .../reference/symbolProperty16.symbols | 12 +- .../reference/symbolProperty18.symbols | 36 +- .../reference/symbolProperty19.symbols | 24 +- .../reference/symbolProperty2.symbols | 2 +- .../reference/symbolProperty20.symbols | 24 +- .../reference/symbolProperty21.symbols | 30 +- .../reference/symbolProperty22.symbols | 12 +- .../reference/symbolProperty23.symbols | 12 +- .../reference/symbolProperty26.symbols | 12 +- .../reference/symbolProperty27.symbols | 12 +- .../reference/symbolProperty28.symbols | 12 +- .../reference/symbolProperty4.symbols | 6 +- .../reference/symbolProperty40.symbols | 30 +- .../reference/symbolProperty41.symbols | 30 +- .../reference/symbolProperty45.symbols | 12 +- .../reference/symbolProperty5.symbols | 18 +- .../reference/symbolProperty50.symbols | 6 +- .../reference/symbolProperty51.symbols | 6 +- .../reference/symbolProperty55.symbols | 12 +- .../reference/symbolProperty56.symbols | 6 +- .../reference/symbolProperty57.symbols | 8 +- .../reference/symbolProperty6.symbols | 24 +- .../reference/symbolProperty8.symbols | 12 +- .../baselines/reference/symbolType11.symbols | 6 +- .../baselines/reference/symbolType16.symbols | 2 +- ...teStringWithEmbeddedNewOperatorES6.symbols | 2 +- tests/baselines/reference/typedArrays.symbols | 330 +++++++++--------- 120 files changed, 654 insertions(+), 654 deletions(-) diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index 30f541751a151..f4b223379daf0 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index dc2ed671c464b..405121287a6ba 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) }; diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.symbols b/tests/baselines/reference/asyncArrowFunction9_es6.symbols index 8db4592f0e13a..7c50a463248e5 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction9_es6.symbols @@ -4,5 +4,5 @@ var foo = async (a = await => await): Promise => { >a : Symbol(a, Decl(asyncArrowFunction9_es6.ts, 0, 17)) >await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) >await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols index d4f4dcedcd032..76ed959e0af1f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols @@ -4,5 +4,5 @@ async function foo(a = await => await): Promise { >a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) >await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) >await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index b432029637399..ec47746020290 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index 5354c67a195f0..0cbcb69685c93 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index 241290a489999..9631076c0842f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index 373086ecbac5f..6df30c99fa59e 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = await p || a; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index 9331ad13ce58f..af1c2e3395ad8 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = await p && a; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index b1acda7013630..6983f2c73ab57 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,11 +4,11 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = await p + a; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index c1a3bd903f4de..42f6730ad66aa 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = await p, a; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index cb74dcff7f62e..4f5d853c68f96 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var o: { a: boolean; }; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index f9756da1768e3..4065e1e0e0200 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index 2e5b8761163be..a4b36cbc13c16 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 331fbeb8e6eed..184c80fde62c3 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index cc3407610b78f..f8a7bbe037b85 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = (await pfn)(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index 0063434d0fb0e..58a0553533efe 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index 9f99f55f26c6b..48262825ed9cc 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = o.fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index d9dd6535bc292..85f172d03e425 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = o.fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index 1a2097d041d84..a1b9798b4c2db 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) "before"; var b = (await po).fn(a, a, a); diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index c29c41bff20f9..c642152ebc39b 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1366, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1367, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index 6a4eb82af97e9..acb0e91ab3efa 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index 22340c6aa60d3..08a61e4fb0c38 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1450, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 611db6485b906..7e69e1c51ae31 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1706, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 7a3c26204242a..083b2713d1888 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1706, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index c9658b4d90d83..403bf7d4946e8 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1706, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index df5ab202dfcbc..ed79ccc0e5dee 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1706, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index c4fc2e434e857..15baf6aca1cf0 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1705, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1706, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index bcd19f1a4d414..bc4595f73cf00 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1464, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1464, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1465, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 1465, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index a61af49253804..f5688d73566c7 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index c2d2d07841559..182d45a3369bb 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 251a5b28fcae2..4697f3283a629 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 0b6b6f23cc0d8..fcaf9b069dc04 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index cc4fcf55a7c84..f72094cdf4f5f 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 8c7455a2dbc33..205a57d2c0781 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index dae7d4bae7f32..6ff68dea5d45c 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 34766b1bc8c11..19e917e7190be 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index aa44808cd736c..edf8ab0a84c81 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index caf0356df220f..d569ffae2f6dc 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 73455ff17e671..17c30514ffca8 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1879, 1), Decl(lib.d.ts, 1901, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index bfbe035730c89..118d687659fe2 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1879, 1), Decl(lib.d.ts, 1901, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index ed6ecb128f7fb..b916ffc3bf53a 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1879, 1), Decl(lib.d.ts, 1901, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index adcd2ae376000..2c4ebb582f9f2 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 2f4a85111471d..83ab93a9b6080 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1879, 1), Decl(lib.d.ts, 1901, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index 6813cd4eee548..f11290b987922 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1879, 1), Decl(lib.d.ts, 1901, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index e8be8da6f9ca6..9f3862e10172d 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1674, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1675, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index 02f2ad6e8ef52..d7877b5947abb 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 9bbe4bfb983f7..a4dae0104c85a 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 1a8634862ea20..124fc600b068c 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index 3c8a8c1ba5221..43641993f344e 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index a28e682c9ed88..ded5eea872675 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 46087c2f8bb6d..85ecd34218b2f 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index e4c5de1770433..db22e31429e5d 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1878, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1879, 1), Decl(lib.d.ts, 1901, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 2b0c26918e413..b6b569d15c616 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 90adcfeba92cf..0722765c4de1b 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index 43c6d7135e08d..0270830ca793e 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1674, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1675, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index 3c1cf17480d64..e7085745aa7f1 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index d1eb5420ef119..8d276ae555428 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1674, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1675, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index 42c7e7e626ea8..7bc6808d849a9 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index 8a7abd3f19589..bded5309f83ed 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index 03aca3c69b36e..0dbe4711e95ee 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index e8c6571943e25..50725a3f99f89 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index d695457621f5d..ac52c5d172abb 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 58ed5ea493530..8ac205edcc579 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index ac81fdea2618e..12e4bd1bb9ba7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index da79720409de3..06226958069e4 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 9b0b706077d60..72d4ad96aac92 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index f13748e9996d9..77eb6c610593a 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index cb4ff68a63766..5f7f13956a824 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index 34f550b750b9d..94701b8908a13 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index 5257941831b89..b91cd771c5d28 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 77770a62bd575..4762fb4fd7002 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index 3e912a18a2fdb..0eb96fa03b039 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index dcf4a037db2ff..cc11d61259e84 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index f706a35e3b5af..eae90071b65d8 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index 78faacdb1f14a..d9e329885aab2 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4854, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index 6b17c421a0731..0b0e820404bdc 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index e620614d829eb..5ed853abd19fd 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index 3cbae021c32e5..44115a3e7309b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index 9e6b00fbc45a8..a0aa4e1142a1f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index 610a6bae9cd61..0acef2d8a7180 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index e0ba5ffc72a78..bfcf6243d9e47 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index 712b233a744f4..fcfcd0efe1400 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index 3a24de2f0e331..28d4602b181c6 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 5580b833c0814..c8a7ab36e94b8 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index 10c95ed620bc9..d535c8ce1ec89 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index 42f6b86686737..0860dae4a277f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 13331a49dc355..21faad440290a 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index 2b6984b6baef0..9212123105def 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index bff61ccc01476..952846d768d91 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 1b0026c5ea4bb..3b5685d1d7738 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index 358819f47b393..b47ae5d912dde 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index fe630f8f82d1f..ac05eb6195e74 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index d87416cd43a6c..c45b22056af9c 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index 4597eb81c0f22..40c5a86c0e91c 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index d3295b6507e3d..909c6394ec267 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index ea698562ed2be..9d618e7751f87 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index 714b771b67e3f..b12874d028bf0 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols index f2061b3bb2cd0..b0632e2eaaebb 100644 --- a/tests/baselines/reference/symbolProperty21.symbols +++ b/tests/baselines/reference/symbolProperty21.symbols @@ -5,15 +5,15 @@ interface I { >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) >T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) [Symbol.isConcatSpreadable]: U; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) } @@ -34,18 +34,18 @@ foo({ >foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1241, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) [Symbol.unscopables]: true ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) }); diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index d1bee54bd7b69..4c8ec1aa7f5d2 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index 94dc416010e09..a8ebaf9534590 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 0850ec9cdaa59..b5c726712e4d2 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index ed56e55cca613..039963b02aad7 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index e5cdbb0ea6101..6ba9c126943c5 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index 8a0d692de2281..99961ec662981 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index 246d0952c8901..62acefd45c242 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index 2872f6cb13493..1635419694d01 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 1f691f8827d4c..67fce3aefab3e 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1233, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1233, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1234, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1234, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index e9bda77fd7152..4dc58d689d8ac 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index 69a695e6c5bbf..9201435c09eb1 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index e045d35f13fce..199c51e65a3aa 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index 077199e496904..95521c7e7149a 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1207, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1208, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index a76ab0418cc47..97f9966e19613 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index e98cf96380723..bc1497aaa1479 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index 8b0e62e406890..0dbda66432f52 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1247, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1289, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index a1a4d1d50dfb6..07f572b03bc36 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1295, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1283, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index 6c4001fa4c85a..11be00dba4076 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1219, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1219, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1220, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1220, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 7a54b0efcbe72..7791f4ee2ba96 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1197, 53), Decl(lib.d.ts, 1303, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index a6e319c0dfa7e..7feac825ac9d1 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1549, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1550, 1)) diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index ef9f533bb58e3..66499f844d343 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1445, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1446, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2392, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2392, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2393, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2393, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2682, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2682, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2683, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2683, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3262, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3262, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3263, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3263, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3552, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3552, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3553, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3553, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3842, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3842, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3843, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3843, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4132, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4132, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4133, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4133, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4422, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4422, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4423, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4423, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4712, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4712, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4713, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4713, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2972, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2972, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2973, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2973, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1445, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1446, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1445, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1446, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2118, 42), Decl(lib.d.ts, 2408, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2398, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2119, 42), Decl(lib.d.ts, 2409, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2399, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2408, 44), Decl(lib.d.ts, 2698, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2688, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2409, 44), Decl(lib.d.ts, 2699, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2689, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2988, 60), Decl(lib.d.ts, 3278, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3268, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2989, 60), Decl(lib.d.ts, 3279, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3269, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3278, 46), Decl(lib.d.ts, 3568, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3558, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3279, 46), Decl(lib.d.ts, 3569, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3559, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3568, 48), Decl(lib.d.ts, 3858, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3848, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3569, 48), Decl(lib.d.ts, 3859, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3849, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3858, 46), Decl(lib.d.ts, 4148, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4138, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3859, 46), Decl(lib.d.ts, 4149, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4139, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4148, 48), Decl(lib.d.ts, 4438, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4428, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4149, 48), Decl(lib.d.ts, 4439, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4429, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4438, 50), Decl(lib.d.ts, 4728, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4718, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4439, 50), Decl(lib.d.ts, 4729, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4719, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2698, 46), Decl(lib.d.ts, 2988, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2978, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2699, 46), Decl(lib.d.ts, 2989, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2979, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) From 655f2ec74eb07cd3a5e3f1717da521b27a71a879 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 8 May 2015 16:51:35 -0700 Subject: [PATCH 011/250] Cleanup and PR feedback --- src/compiler/checker.ts | 210 ++++++++++++------ .../diagnosticInformationMap.generated.ts | 6 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/parser.ts | 50 +++-- src/compiler/types.ts | 14 +- 5 files changed, 187 insertions(+), 95 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0529b8012bfc6..d759eb1fc1aac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7303,7 +7303,9 @@ module ts { if (globalPromiseType !== emptyObjectType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); - return createTypeReference(globalPromiseType, [promisedType]); + if (promisedType !== unknownType) { + return createTypeReference(globalPromiseType, [promisedType]); + } } error(location, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); @@ -7319,17 +7321,23 @@ module ts { let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = isAsync - ? checkAwaitedExpressionCached(func.body, contextualMapper) - : checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + type = checkAwaitedExpressionCached(func.body, contextualMapper); + } + else { + type = checkExpressionCached(func.body, contextualMapper); + } } else { // Aggregate the types of expressions within all the return statements. let types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); if (types.length === 0) { - return isAsync - ? createPromiseType(voidType, func) - : voidType; + if (isAsync) { + return createPromiseType(voidType, func); + } + else { + return voidType; + } } // When return statements are contextually typed we allow the return type to be a union type. Otherwise we require the @@ -7340,14 +7348,18 @@ module ts { return unknownType; } } + if (!contextualSignature) { reportErrorsFromWidening(func, type); } let widenedType = getWidenedType(type); - return isAsync - ? createPromiseType(widenedType, func) - : widenedType; + if (isAsync) { + return createPromiseType(widenedType, func); + } + else { + return widenedType; + } } /// Returns a set of types relating to every return expression relating to a function block. @@ -7357,9 +7369,14 @@ module ts { forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { - let type = isAsync - ? checkAwaitedExpressionCached(expr, contextualMapper) - : checkExpressionCached(expr, contextualMapper); + let type: Type; + if (isAsync) { + type = checkAwaitedExpressionCached(expr, contextualMapper); + } + else { + type = checkExpressionCached(expr, contextualMapper); + } + if (!contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -7495,10 +7512,12 @@ module ts { else { let exprType = checkExpression(node.body); if (returnType) { - checkTypeAssignableTo( - isAsync ? getAwaitedType(exprType) : exprType, - isAsync ? promisedType : returnType, - node.body); + if (isAsync) { + checkTypeAssignableTo(getAwaitedType(exprType, node.body), promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } checkFunctionExpressionBodies(node.body); } @@ -7619,8 +7638,8 @@ module ts { grammarErrorOnFirstToken(node, Diagnostics.await_expression_must_be_contained_within_an_async_function); } - var operandType = checkExpression(node.expression); - return getAwaitedType(operandType); + let operandType = checkExpression(node.expression); + return getAwaitedType(operandType, node); } function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { @@ -8322,13 +8341,14 @@ module ts { break; } } + if (isAsyncFunctionLike(node)) { var promiseConstructor = getPromiseConstructor(node); if (promiseConstructor) { var promiseIdentifier = getFirstIdentifier(promiseConstructor); var promiseName = promiseIdentifier.text; - var typeSymbol = resolveName(node, promiseName, SymbolFlags.Type | SymbolFlags.Module, undefined, undefined); - var valueSymbol = resolveName(node, promiseName, SymbolFlags.Value, undefined, undefined); + var typeSymbol = resolveName(node, promiseName, SymbolFlags.Type | SymbolFlags.Module, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var valueSymbol = resolveName(node, promiseName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (typeSymbol !== valueSymbol) { var valueLinks = getNodeLinks(valueSymbol.valueDeclaration); if (!(valueLinks.flags & NodeCheckFlags.PromiseCollision)) { @@ -8932,8 +8952,28 @@ module ts { } } + function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) { + if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + + error(location, message); + } + + return false; + } + + return true; + } + + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" argument of the "onfulfilled" callback. + */ function getPromisedType(type: Type): Type { - // the "promised type" of a type is the type of the "value" argument of the "onfulfilled" callback. let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); if (globalPromiseLikeType !== emptyObjectType && isTypeAssignableTo(type, globalPromiseLikeType)) { let thenProp = getPropertyOfType(type, "then"); @@ -8954,67 +8994,100 @@ module ts { } return getUnionType(awaitedTypes); - } + } } - - return emptyObjectType; - } - function getAwaitedType(type: Type): Type { - // The "awaited type" of an expression is its "promised type" if the expression is a `Promise`; otherwise, it is the type of the expression. - + return unknownType; + } + + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type: Type, location?: Node): Type { let promisedType = getPromisedType(type); - if (promisedType === emptyObjectType) { - return type; + if (promisedType === unknownType) { + // if we got the unknown type, the type wasn't a promise. We need to check to + // ensure it is not a thenable. + if (checkNonThenableType(type, location)) { + return type; + } + + return unknownType; } - - // if we have a bad actor in the form of a promise whose promised type is the same promise, return the empty type. - // if this were the actual case in the JavaScript, this Promise would never resolve. - if (promisedType === type) { - return emptyObjectType; + else if (promisedType === type) { + // if we have a bad actor in the form of a promise whose promised type is the same + // promise, return the unknown type as we cannot guess the shape. + // if this were the actual case in the JavaScript, this Promise would never resolve. + if (location) { + error(location, Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member); + } + + return unknownType; } - // unwrap any nested promises + // `seen` keeps track of types we've tried to await to avoid cycles. + // This is to protect against a bad actor with a mutually recursive promised type: + // + // declare class PromiseA { + // then(onfulfilled: (value: PromiseB) => any, onrejected?); + // } + // declare class PromiseB { + // then(onfulfilled: (value: PromiseA) => any, onrejected?); + // } + // let seen: boolean[]; + + // unwrap any nested promises while (true) { let nestedPromisedType = getPromisedType(promisedType); - if (nestedPromisedType === emptyObjectType) { - // if this could not be unwrapped further, return the promised type - return promisedType; + if (nestedPromisedType === unknownType) { + // this type could not be unwrapped further. We need to check to + // ensure it is not a thenable + if (checkNonThenableType(promisedType, location)) { + return promisedType; + } + + return unknownType; } if (!seen) { - // `seen` keeps track of types we've tried to await to avoid cycles seen = []; seen[type.id] = true; seen[promisedType.id] = true; } else if (seen[nestedPromisedType.id]) { - // if we've already seen this type, this is a promise that would never resolve. As above, we return the empty type. - return emptyObjectType; + // if we've already seen this type, this is a promise that + // would never resolve. As above, we return the unknown type. + if (location) { + error(location, Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member); + } + + return unknownType; } seen[nestedPromisedType.id] = true; promisedType = nestedPromisedType; } - - return promisedType; - - // if we didn't get a promised type, check the type does not have a callable then member. - if (isTypeAssignableTo(type, getGlobalThenableType())) { - error(null, Diagnostics.Type_for_await_does_not_have_a_valid_callable_then_member); - return emptyObjectType; - } - - // if the type was not a "promise" or a "thenable", return the type. - return type; } - function checkAsyncFunctionReturnType(node: SignatureDeclaration, returnType: Type): Type { - // This checks that an async function has a valid Promise-compatible return type, and returns the *awaited type* of the promise. - // An async function has a valid Promise-compatible return type if the resolved value of the return type has a construct - // signature that takes in an `initializer` function that in turn supplies a `resolve` function as one of its arguments - // and results in an object with a callable `then` signature. + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node: SignatureDeclaration, returnType: Type): Type { let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType !== emptyObjectType) { if (!returnType) { @@ -9022,23 +9095,24 @@ module ts { } // get the constructor type of the return type - var declaredType = returnType.symbol ? getTypeOfSymbol(returnType.symbol) : emptyObjectType; + let declaredType = returnType.symbol ? getTypeOfSymbol(returnType.symbol) : emptyObjectType; if (isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { - var promisedType = getPromisedType(returnType); - if (promisedType !== emptyObjectType) { + let promisedType = getPromisedType(returnType); + if (promisedType !== unknownType) { // unwrap the promised type - var promiseConstructor = getPromiseConstructor(node); + let promiseConstructor = getPromiseConstructor(node); if (promiseConstructor) { - emitAwaiter = true; checkExpressionOrQualifiedName(promiseConstructor); - return getAwaitedType(promisedType); } + + emitAwaiter = true; + return getAwaitedType(promisedType, node); } } } error(node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return emptyObjectType; + return unknownType; } /** Check a decorator */ @@ -12351,9 +12425,11 @@ module ts { let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - let thenableType = createObjectType(TypeFlags.ObjectType); + let thenableType = createObjectType(TypeFlags.Anonymous); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; return thenableType; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index ec2bca8a7ce24..4a4ae96110907 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -50,7 +50,7 @@ module ts { A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, - Type_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Type for 'await' does not have a valid callable 'then' member." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, @@ -381,11 +381,11 @@ module ts { An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression." }, - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, - Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 600c928a0ddf5..feb7730a8a317 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -187,7 +187,7 @@ "category": "Error", "code": 1057 }, - "Type for 'await' does not have a valid callable 'then' member.": { + "Operand for 'await' does not have a valid callable 'then' member.": { "category": "Error", "code": 1058 }, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index db6a00ec9aa81..f4ac24c5fc821 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -568,11 +568,15 @@ module ts { } function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { - let setContextFlags = context & contextFlags; - if (setContextFlags) { - setContextFlag(false, setContextFlags); + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + let contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); let result = func(); - setContextFlag(true, setContextFlags); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); return result; } @@ -581,11 +585,15 @@ module ts { } function doInsideOfContext(context: ParserContextFlags, func: () => T): T { - let unsetContextFlags = context & ~contextFlags; - if (unsetContextFlags) { - setContextFlag(true, unsetContextFlags); + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable + let contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); let result = func(); - setContextFlag(false, unsetContextFlags); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); return result; } @@ -1013,6 +1021,11 @@ module ts { } function canFollowModifier(isArrowFunction?: boolean): boolean { + // Arrow functions can have an `async` modifier, but the rules for what can follow that modifier + // differ from the rules for any other declaration. + // The `async` modifier on an async function can only be followed by an open parenthesis, + // or a less than token (in the case of a generic arrow function). + // In addition, the `async` modifier must appear on the same line as the following token. if (isArrowFunction) { if (scanner.hasPrecedingLineBreak()) { return false; @@ -1898,12 +1911,12 @@ module ts { function parseBindingElementInitializer(inParameter: boolean) { // BindingElement[Yield,GeneratorParameter,Await,AsyncParameter] : - // [+GeneratorParameter] BindingPattern[?Yield,?Await,GeneratorParameter] Initializer[In]opt - // [+AsyncParameter] BindingPattern[?Yield,?Await,AsyncParameter] Initializer[In]opt + // [+GeneratorParameter] BindingPattern[?Yield,?Await,?AsyncParameter,GeneratorParameter] Initializer[In]opt + // [+AsyncParameter] BindingPattern[?Yield,?GeneratorParameter,?Await,AsyncParameter] Initializer[In]opt // [~GeneratorParameter,~AsyncParameter] BindingPattern[?Yield,?Await] Initializer[In,?Yield,?Await]opt // SingleNameBinding[Yield,GeneratorParameter,Await,AsyncParameter] : - // [+GeneratorParameter] BindingIdentifier[Yield] Initializer[In]opt - // [+AsyncParameter] BindingIdentifier[Await] Initializer[In]opt + // [+GeneratorParameter] BindingIdentifier[Yield, ?Await] Initializer[In]opt + // [+AsyncParameter] BindingIdentifier[Await, ?Yield] Initializer[In]opt // [~GeneratorParameter,~AsyncParameter] BindingIdentifier[?Yield,?Await] Initializer[In,?Yield,?Await]opt let parseInitializer = inParameter ? parseParameterInitializer : parseNonParameterInitializer; return inGeneratorParameterOrAsyncParameterContext() @@ -2425,9 +2438,9 @@ module ts { case SyntaxKind.LessThanToken: case SyntaxKind.AwaitKeyword: case SyntaxKind.YieldKeyword: - // Yield always starts an expression. Either it is an identifier (in which case + // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in - // a generator, or in strict mode (or both)) and it started a yield expression. + // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. return true; default: // Error tolerance. If we see the start of some binary operator, we consider @@ -3317,6 +3330,9 @@ module ts { case SyntaxKind.OpenBraceToken: return parseObjectLiteralExpression(); case SyntaxKind.AsyncKeyword: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } @@ -3450,7 +3466,7 @@ module ts { parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - let isGenerator = node.asteriskToken != undefined; + let isGenerator = !!node.asteriskToken; let isAsync = isAsyncFunctionLike(node); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : @@ -4092,7 +4108,7 @@ module ts { parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); - let isGenerator = node.asteriskToken != undefined; + let isGenerator = !!node.asteriskToken; let isAsync = isAsyncFunctionLike(node); fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList:*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); @@ -4116,7 +4132,7 @@ module ts { method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - let isGenerator = asteriskToken != undefined; + let isGenerator = !!asteriskToken; let isAsync = isAsyncFunctionLike(method); fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList:*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86b4113eecc9c..29206c53f39a5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -344,16 +344,16 @@ module ts { // If this node was parsed as part of a decorator Decorator = 1 << 4, - // If the parser encountered an error when parsing the code that created this node. Note - // the parser only sets this directly on the node it creates right after encountering the - // error. - ThisNodeHasError = 1 << 5, - // If this node was parsed in the parameters of an async function. - AsyncParameter = 1 << 6, + AsyncParameter = 1 << 5, // If this node was parsed in the 'await' context created when parsing an async function. - Await = 1 << 7, + Await = 1 << 6, + + // If the parser encountered an error when parsing the code that created this node. Note + // the parser only sets this directly on the node it creates right after encountering the + // error. + ThisNodeHasError = 1 << 7, // Context flags set directly by the parser. ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | AsyncParameter | Await, From 239166643592ddaa4708094d9d9aa5daa70e4614 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 8 May 2015 17:07:48 -0700 Subject: [PATCH 012/250] Updated declaration and symbol baselines --- src/lib/es6.d.ts | 1 + tests/baselines/reference/asyncArrowFunction1_es6.symbols | 2 +- tests/baselines/reference/asyncArrowFunction9_es6.symbols | 2 +- .../reference/asyncFunctionDeclaration10_es6.symbols | 2 +- .../reference/asyncFunctionDeclaration11_es6.symbols | 2 +- .../reference/asyncFunctionDeclaration14_es6.symbols | 2 +- .../reference/asyncFunctionDeclaration1_es6.symbols | 2 +- .../reference/awaitBinaryExpression1_es6.symbols | 4 ++-- .../reference/awaitBinaryExpression2_es6.symbols | 4 ++-- .../reference/awaitBinaryExpression3_es6.symbols | 4 ++-- .../reference/awaitBinaryExpression4_es6.symbols | 4 ++-- .../reference/awaitBinaryExpression5_es6.symbols | 4 ++-- .../baselines/reference/awaitCallExpression1_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression2_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression3_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression4_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression5_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression6_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression7_es6.symbols | 8 ++++---- .../baselines/reference/awaitCallExpression8_es6.symbols | 8 ++++---- .../baselines/reference/promiseVoidErrorCallback.symbols | 8 ++++---- 21 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 2c1db00de9b8e..b6b8d8fc13b18 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -3591,6 +3591,7 @@ interface Promise { * @returns A Promise for the completion of the callback. */ catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; [Symbol.toStringTag]: string; } diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index 405121287a6ba..3540c6d24982e 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) }; diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.symbols b/tests/baselines/reference/asyncArrowFunction9_es6.symbols index 7c50a463248e5..66612c3483077 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction9_es6.symbols @@ -4,5 +4,5 @@ var foo = async (a = await => await): Promise => { >a : Symbol(a, Decl(asyncArrowFunction9_es6.ts, 0, 17)) >await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) >await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols index 76ed959e0af1f..cc3870c6d71fe 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols @@ -4,5 +4,5 @@ async function foo(a = await => await): Promise { >a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) >await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) >await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index ec47746020290..58fe50df2cf41 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index 0cbcb69685c93..a88f3f752e096 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index 9631076c0842f..ee10e306a4218 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index 6df30c99fa59e..b33c26f7707a0 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = await p || a; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index af1c2e3395ad8..f36bc7f2019fe 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = await p && a; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index 6983f2c73ab57..543a6e8659d3c 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,11 +4,11 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = await p + a; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index 42f6730ad66aa..142655b999707 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = await p, a; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index 4f5d853c68f96..f883da2cd16ce 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var o: { a: boolean; }; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index 4065e1e0e0200..1e7f17daa7cee 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index a4b36cbc13c16..ad053c6a75f6c 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 184c80fde62c3..ad6ec4b11a0b7 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index f8a7bbe037b85..1ef5577411435 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = (await pfn)(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index 58a0553533efe..11232eeb38ca6 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index 48262825ed9cc..06ec12c99d3c5 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = o.fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index 85f172d03e425..91cce6e9a336f 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = o.fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index a1b9798b4c2db..2decfda811e8a 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) "before"; var b = (await po).fn(a, a, a); diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index d9e329885aab2..aa6b1b642ceec 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4838, 39), Decl(lib.d.ts, 4845, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4856, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4838, 39), Decl(lib.d.ts, 4845, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } From 39a6cce78910ef410889f6993408720f4c2284df Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 8 May 2015 21:37:43 -0700 Subject: [PATCH 013/250] Cleaned up diagnostic messages --- src/compiler/checker.ts | 5 ++- .../diagnosticInformationMap.generated.ts | 11 +----- src/compiler/diagnosticMessages.json | 38 +------------------ 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d759eb1fc1aac..650a65119b65c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7635,7 +7635,7 @@ module ts { function checkAwaitExpression(node: AwaitExpression): Type { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Await)) { - grammarErrorOnFirstToken(node, Diagnostics.await_expression_must_be_contained_within_an_async_function); + grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); } let operandType = checkExpression(node.expression); @@ -10069,6 +10069,9 @@ module ts { if (node.parserContextFlags & ParserContextFlags.StrictMode) { grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); } + else if (node.parserContextFlags & ParserContextFlags.Await) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } } checkExpression(node.expression); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 4a4ae96110907..f466d6bfe41d2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -181,16 +181,7 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - _0_modifier_cannot_be_used_with_a_generator: { code: 1301, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a generator." }, - _0_modifier_cannot_be_used_with_a_module_declaration: { code: 1302, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a module declaration." }, - _0_modifier_cannot_be_used_with_an_enum_declaration: { code: 1303, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with an enum declaration." }, - _0_modifier_cannot_be_used_with_an_export_assignment_declaration: { code: 1304, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with an export assignment declaration." }, - _0_modifier_cannot_be_used_on_a_variable_statement: { code: 1305, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used on a variable statement." }, - _0_modifier_cannot_be_used_with_a_type_declaration: { code: 1306, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a type declaration." }, - _0_modifier_cannot_be_used_with_a_parameter_declaration: { code: 1307, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a parameter declaration." }, - await_expression_must_be_contained_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression must be contained within an async function." }, - _0_modifier_cannot_be_used_on_an_object_literal_element: { code: 1309, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used on an object literal element." }, - _0_expression_is_not_allowed_in_an_initializer: { code: 1310, category: DiagnosticCategory.Error, key: "'{0}' expression is not allowed in an initializer." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index feb7730a8a317..aa8ec55f522c6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -712,46 +712,10 @@ "category": "Error", "code": 1300 }, - "'{0}' modifier cannot be used with a generator.": { - "category": "Error", - "code": 1301 - }, - "'{0}' modifier cannot be used with a module declaration.": { - "category": "Error", - "code": 1302 - }, - "'{0}' modifier cannot be used with an enum declaration.": { - "category": "Error", - "code": 1303 - }, - "'{0}' modifier cannot be used with an export assignment declaration.": { - "category": "Error", - "code": 1304 - }, - "'{0}' modifier cannot be used on a variable statement.": { - "category": "Error", - "code": 1305 - }, - "'{0}' modifier cannot be used with a type declaration.": { - "category": "Error", - "code": 1306 - }, - "'{0}' modifier cannot be used with a parameter declaration.": { - "category": "Error", - "code": 1307 - }, - "'await' expression must be contained within an async function.": { + "'await' expression is only allowed within an async function.": { "category": "Error", "code": 1308 }, - "'{0}' modifier cannot be used on an object literal element.": { - "category": "Error", - "code": 1309 - }, - "'{0}' expression is not allowed in an initializer.": { - "category": "Error", - "code": 1310 - }, "Async functions are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1311 From daa77935e31cb728401cc0a44881daba248a8d0f Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 8 May 2015 21:40:56 -0700 Subject: [PATCH 014/250] Additional clean up of diagnostic messages --- src/compiler/diagnosticInformationMap.generated.ts | 1 - src/compiler/diagnosticMessages.json | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f466d6bfe41d2..2beb3fd5cd160 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -519,7 +519,6 @@ module ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Emit_async_functions_when_ECMAScript_target_version_is_lower_than_ES6: { code: 6063, category: DiagnosticCategory.Message, key: "Emit async functions when ECMAScript target version is lower than 'ES6'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index aa8ec55f522c6..3c1f3405db803 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2068,10 +2068,6 @@ "category": "Error", "code": 6062 }, - "Emit async functions when ECMAScript target version is lower than 'ES6'.": { - "category": "Message", - "code": 6063 - }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", From 2ee5beb3786e198e3d6cb1b9801958b2fe802257 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 8 May 2015 22:15:54 -0700 Subject: [PATCH 015/250] PR feedback --- src/compiler/parser.ts | 37 +++++++++++++++++-------------------- src/compiler/types.ts | 10 +++++----- src/compiler/utilities.ts | 2 +- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f4ac24c5fc821..ed7ecd6c9f61b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -983,25 +983,22 @@ module ts { } function nextTokenCanFollowModifierForArrowFunction() { - return nextTokenCanFollowModifier(/*isArrowFunction*/ true); + nextToken(); + return canFollowModifierForArrowFunction(); } - function nextTokenCanFollowModifier(isArrowFunction?: boolean) { + function nextTokenCanFollowModifier() { nextToken(); - return canFollowModifier(isArrowFunction); + return canFollowModifier(); } function parseAnyContextualModifier(isArrowFunction?: boolean): boolean { return isModifier(token) && tryParse(isArrowFunction - ? nextTokenCanFollowContextualModifierForArrowFunction + ? nextTokenCanFollowModifierForArrowFunction : nextTokenCanFollowContextualModifier); } - function nextTokenCanFollowContextualModifierForArrowFunction() { - return nextTokenCanFollowContextualModifier(/*isArrowFunction*/ true); - } - - function nextTokenCanFollowContextualModifier(isArrowFunction?: boolean) { + function nextTokenCanFollowContextualModifier() { if (token === SyntaxKind.ConstKeyword) { // 'const' is only a modifier if followed by 'enum'. return nextToken() === SyntaxKind.EnumKeyword; @@ -1017,24 +1014,24 @@ module ts { return nextTokenIsClassOrFunction(); } nextToken(); - return canFollowModifier(isArrowFunction); + return canFollowModifier(); } - - function canFollowModifier(isArrowFunction?: boolean): boolean { + + function canFollowModifierForArrowFunction(): boolean { // Arrow functions can have an `async` modifier, but the rules for what can follow that modifier // differ from the rules for any other declaration. // The `async` modifier on an async function can only be followed by an open parenthesis, // or a less than token (in the case of a generic arrow function). // In addition, the `async` modifier must appear on the same line as the following token. - if (isArrowFunction) { - if (scanner.hasPrecedingLineBreak()) { - return false; - } - - return token === SyntaxKind.OpenParenToken - || token === SyntaxKind.LessThanToken; + if (scanner.hasPrecedingLineBreak()) { + return false; } - + + return token === SyntaxKind.OpenParenToken + || token === SyntaxKind.LessThanToken; + } + + function canFollowModifier(): boolean { return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.AsteriskToken diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 29206c53f39a5..0b5df05ff0058 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -344,11 +344,11 @@ module ts { // If this node was parsed as part of a decorator Decorator = 1 << 4, - // If this node was parsed in the parameters of an async function. - AsyncParameter = 1 << 5, - // If this node was parsed in the 'await' context created when parsing an async function. - Await = 1 << 6, + Await = 1 << 5, + + // If this node was parsed in the parameters of an async function. + AsyncParameter = 1 << 6, // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the @@ -356,7 +356,7 @@ module ts { ThisNodeHasError = 1 << 7, // Context flags set directly by the parser. - ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | AsyncParameter | Await, + ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | Await | AsyncParameter, // Context flags passed as part of the modified ES6 grammar. YieldAndGeneratorParameterFlags = Yield | GeneratorParameter, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 805bc877fee3a..b8aa89aca525f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1101,7 +1101,7 @@ module ts { } export function isAsyncFunctionLike(node: Node): boolean { - return isFunctionLike(node) && !isAccessor(node) && (node.flags & NodeFlags.Async) === NodeFlags.Async; + return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node); } /** From 3d0991d27d1653943c10081d3687733a221826e0 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 10:50:40 -0700 Subject: [PATCH 016/250] Better name for bitmask in ParserContextFlags --- src/compiler/parser.ts | 28 +++++++--------------------- src/compiler/types.ts | 4 +++- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index db6a00ec9aa81..7b293adadc256 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2363,7 +2363,7 @@ module ts { function parseType(): TypeNode { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(ParserContextFlags.AllParameterFlags, parseTypeWorker); + return doOutsideOfContext(ParserContextFlags.TypeExcludesFlags, parseTypeWorker); } function parseTypeWorker(): TypeNode { @@ -4363,15 +4363,9 @@ module ts { node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause:*/ true); if (parseExpected(SyntaxKind.OpenBraceToken)) { - // ClassTail[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.5 - // [~GeneratorParameter,~AsyncParameter]ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - // [+AsyncParameter] ClassHeritageopt { ClassBodyopt } - - node.members = inGeneratorParameterOrAsyncParameterContext() - ? doOutsideOfYieldAndAwaitContext(parseClassMembers) - : parseClassMembers(); - + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -4384,24 +4378,16 @@ module ts { } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { - // ClassTail[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.5 - // [~GeneratorParameter,~AsyncParameter]ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - // [+AsyncParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterOrAsyncParameterContext() - ? doOutsideOfYieldAndAwaitContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(ParsingContext.HeritageClauses, /*checkForStrictMode:*/ false, parseHeritageClause); } return undefined; } - function parseHeritageClausesWorker() { - return parseList(ParsingContext.HeritageClauses, /*checkForStrictMode:*/ false, parseHeritageClause); - } - function parseHeritageClause() { if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) { let node = createNode(SyntaxKind.HeritageClause); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86b4113eecc9c..4de0f7fd98cc6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -361,7 +361,9 @@ module ts { // Context flags passed as part of the modified ES6 grammar. YieldAndGeneratorParameterFlags = Yield | GeneratorParameter, AwaitAndAsyncParameterFlags = Await | AsyncParameter, - AllParameterFlags = YieldAndGeneratorParameterFlags | AwaitAndAsyncParameterFlags, + + // Exclude these flags when parsing a Type + TypeExcludesFlags = YieldAndGeneratorParameterFlags | AwaitAndAsyncParameterFlags, // Context flags computed by aggregating child flags upwards. From 9a6d308203f7bc8cc73f6ecb00ae1dbd5fc14267 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 11:15:51 -0700 Subject: [PATCH 017/250] Simplified parenthesis check for await as yield. --- src/compiler/emitter.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e31989e672688..ba4b1010dbac2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1381,14 +1381,13 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { } function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) { - for (let current: Node = node; isExpression(current.parent); current = current.parent) { - if (current.parent.kind === SyntaxKind.BinaryExpression) { - if ((current.parent).left === current) { - return true; - } - } + if (node.parent.kind === SyntaxKind.BinaryExpression && !isAssignmentOperator((node.parent).operatorToken.kind)) { + return true; } - + else if (node.parent.kind === SyntaxKind.ConditionalExpression && (node.parent).condition === node) { + return true; + } + return false; } From 117b07bbf9da51615405131adb06ed39d8c072bf Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 11:36:44 -0700 Subject: [PATCH 018/250] Added comments for emitAsyncSignatureAndBodyForES6 --- src/compiler/emitter.ts | 65 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ba4b1010dbac2..c7a0b1c27a7bc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3324,12 +3324,60 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { emitSignatureParameters(node); } - function emitAsyncSignatureAndBodyForES6(node: FunctionLikeDeclaration) { + function emitAsyncSignatureAndBodyForES6(node: FunctionLikeDeclaration) { let promiseConstructor = resolver.getPromiseConstructor(node); - let resolve = makeUniqueName("resolve"); let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; let args: string; + + // An async function is emit as an outer function that calls an inner + // generator function. Any arguments of the outer function must be + // evaluated in the context of the generator function, to ensure the correct + // environment and bindings for things like binding patterns in the + // argument list. + // + // For async function declarations and function expressions, we want to + // pass the `arguments` object of the outer function to the inner generator + // function in the event the async function directly manipulates the `arguments` + // object. + // + // For async arrow functions, the `arguments` object is not bound to the arrow + // but its containing function. In that case, we must collect all of the passed + // arguments into an array which we then pass to the inner generator function to + // ensure the correct environment for any binding patterns. + // + // Async arrow functions do not have access to the lexical `arguments` of its + // lexical container. + // + // The emit for an async arrow without parameters will look something like this: + // + // let a = async () => await b; + // + // let a = () => __awaiter(function* () { + // return yield b; + // }.apply(this)); + // + // The emit for an async arrow with parameters will look something like this: + // + // let a = async (b) => await b; + // + // let a = (...arguments_1) => __awaiter(function* (b) { + // return yield b; + // }).apply(this, arguments_1); + // + // The emit for an async function expression will look something like this: + // + // let a = async function () { + // return await b; + // } + // + // let a = function () { + // return __awaiter(function* () { + // return yield b; + // }.apply(this, arguments)); + // } + // if (isArrowFunction) { + // Emit the outer signature for the async arrow if (node.parameters.length) { args = makeUniqueName("arguments"); write(`(...${args}) => `); @@ -3339,6 +3387,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { } } else { + // Emit the outer signature for the async function expression or declaration args = "arguments"; write("() {"); increaseIndent(); @@ -3346,29 +3395,37 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { write("return "); } + // Emit the call to __awaiter write("__awaiter(function *"); + // Emit the signature and body for the inner generator function emitSignatureParameters(node); emitFunctionBody(node); + + // Emit the call to `apply` to ensure the correct `this` and arguments. write(".apply(this"); if (args) { write(`, ${args}`); } write(")"); + + // If the function has an explicit type annotation for a promise, emit the + // constructor. if (promiseConstructor) { write(", "); emit(promiseConstructor); } write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body if (!isArrowFunction) { write(";"); decreaseIndent(); writeLine(); write("}"); - } + } } - + function emitFunctionBody(node: FunctionLikeDeclaration) { if (!node.body) { // There can be no body when there are parse errors. Just emit an empty block From 379704ff4faf2dc4e33a950869b608c18fa586ea Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 13:18:54 -0700 Subject: [PATCH 019/250] Cleaned up checker, added comments to parser based on PR feedback. --- src/compiler/checker.ts | 197 ++++++++++++++++++++++------------------ src/compiler/parser.ts | 10 +- 2 files changed, 116 insertions(+), 91 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1a256809f1033..85b63ad0d7a48 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -120,6 +120,7 @@ module ts { let getGlobalPropertyDecoratorType: () => ObjectType; let getGlobalMethodDecoratorType: () => ObjectType; let getGlobalPromiseType: () => ObjectType; + let tryGetGlobalPromiseType: () => ObjectType; let getGlobalPromiseLikeType: () => ObjectType; let getInstantiatedGlobalPromiseLikeType: () => ObjectType; let getGlobalPromiseConstructorLikeType: () => ObjectType; @@ -3501,6 +3502,10 @@ module ts { function getGlobalType(name: string, arity = 0): ObjectType { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + + function tryGetGlobalType(name: string, arity = 0): ObjectType { + return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); @@ -7296,7 +7301,7 @@ module ts { } } - function createPromiseType(promisedType: Type, location: Node): Type { + function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument let globalPromiseType = getGlobalPromiseType(); if (globalPromiseType !== emptyObjectType) { @@ -7307,8 +7312,7 @@ module ts { } } - error(location, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; + return undefined; } function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { @@ -7321,6 +7325,11 @@ module ts { let type: Type; if (func.body.kind !== SyntaxKind.Block) { if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is not the return type of the consise body, rather it + // is the awaited type of the consise body, which we will wrap in the native Promise type + // later in this function. type = checkAwaitedExpressionCached(func.body, contextualMapper); } else { @@ -7332,7 +7341,14 @@ module ts { let types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); if (types.length === 0) { if (isAsync) { - return createPromiseType(voidType, func); + // For an async function, the return type will not be void, but rather a Promise for void. + let promiseType = createPromiseType(voidType); + if (!promiseType) { + error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + return promiseType; } else { return voidType; @@ -7354,7 +7370,16 @@ module ts { let widenedType = getWidenedType(type); if (isAsync) { - return createPromiseType(widenedType, func); + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + let promiseType = createPromiseType(widenedType); + if (!promiseType) { + error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + return promiseType; } else { return widenedType; @@ -7492,11 +7517,6 @@ module ts { let returnType = node.type && getTypeFromTypeNode(node.type); let promisedType: Type; if (returnType && isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so we - // should not be checking assignability of a promise to the return type. Instead, we need to - // check assignability of the awaited type of the concise body against the promised type of - // its return type annotation. promisedType = checkAsyncFunctionReturnType(node, returnType); } @@ -7509,6 +7529,11 @@ module ts { checkSourceElement(node.body); } else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the concise body against the promised type of + // its return type annotation. let exprType = checkExpression(node.body); if (returnType) { if (isAsync) { @@ -8340,23 +8365,6 @@ module ts { break; } } - - if (isAsyncFunctionLike(node)) { - var promiseConstructor = getPromiseConstructor(node); - if (promiseConstructor) { - var promiseIdentifier = getFirstIdentifier(promiseConstructor); - var promiseName = promiseIdentifier.text; - var typeSymbol = resolveName(node, promiseName, SymbolFlags.Type | SymbolFlags.Module, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - var valueSymbol = resolveName(node, promiseName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (typeSymbol !== valueSymbol) { - var valueLinks = getNodeLinks(valueSymbol.valueDeclaration); - if (!(valueLinks.flags & NodeCheckFlags.PromiseCollision)) { - valueLinks.flags |= NodeCheckFlags.PromiseCollision; - error(valueSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseName, getTextOfNode(promiseConstructor)); - } - } - } - } } checkSpecializedSignatureDeclaration(node); @@ -8952,7 +8960,7 @@ module ts { } function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) { - if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (!allConstituentTypesHaveKind(type, TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -8970,33 +8978,58 @@ module ts { /** * Gets the "promised type" of a promise. * @param type The type of the promise. - * @remarks The "promised type" of a type is the type of the "value" argument of the "onfulfilled" callback. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. */ - function getPromisedType(type: Type): Type { + function getPromisedType(promise: Type): Type { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + + if (allConstituentTypesHaveKind(promise, TypeFlags.Any)) { + return undefined; + } + + if ((promise.flags & TypeFlags.Reference) && (promise).target === tryGetGlobalPromiseType()) { + return (promise).typeArguments[0]; + } + let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType !== emptyObjectType && isTypeAssignableTo(type, globalPromiseLikeType)) { - let thenProp = getPropertyOfType(type, "then"); - if (thenProp) { - let awaitedTypes: Type[] = []; - let thenType = getTypeOfSymbol(thenProp); - let thenSignatures = getSignaturesOfType(thenType, SignatureKind.Call); - for (let thenSignature of thenSignatures) { - thenSignature = getErasedSignature(thenSignature); - let onfulfilledParameterType = getTypeAtPosition(thenSignature, 0); - let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); - for (let onfulfilledParameterSignature of onfulfilledParameterSignatures) { - let valueParameterType = getTypeAtPosition(onfulfilledParameterSignature, 0); - if (valueParameterType !== type) { - awaitedTypes.push(valueParameterType); - } - } - } - - return getUnionType(awaitedTypes); - } + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; } - return unknownType; + let thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && allConstituentTypesHaveKind(thenFunction, TypeFlags.Any)) { + return undefined; + } + + let thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + + let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (allConstituentTypesHaveKind(onfulfilledParameterType, TypeFlags.Any)) { + return undefined; + } + + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + + let valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + + function getTypeOfFirstParameterOfSignature(signature: Signature) { + return getTypeAtPosition(signature, 0); } /** @@ -9006,28 +9039,7 @@ module ts { * Promise-like type; otherwise, it is the type of the expression. This is used to reflect * The runtime behavior of the `await` keyword. */ - function getAwaitedType(type: Type, location?: Node): Type { - let promisedType = getPromisedType(type); - if (promisedType === unknownType) { - // if we got the unknown type, the type wasn't a promise. We need to check to - // ensure it is not a thenable. - if (checkNonThenableType(type, location)) { - return type; - } - - return unknownType; - } - else if (promisedType === type) { - // if we have a bad actor in the form of a promise whose promised type is the same - // promise, return the unknown type as we cannot guess the shape. - // if this were the actual case in the JavaScript, this Promise would never resolve. - if (location) { - error(location, Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member); - } - - return unknownType; - } - + function getAwaitedType(type: Type, location?: Node): Type { // `seen` keeps track of types we've tried to await to avoid cycles. // This is to protect against a bad actor with a mutually recursive promised type: // @@ -9039,26 +9051,34 @@ module ts { // } // let seen: boolean[]; - - // unwrap any nested promises while (true) { - let nestedPromisedType = getPromisedType(promisedType); - if (nestedPromisedType === unknownType) { + let promisedType = getPromisedType(type); + if (!promisedType) { // this type could not be unwrapped further. We need to check to // ensure it is not a thenable - if (checkNonThenableType(promisedType, location)) { - return promisedType; + if (checkNonThenableType(type, location)) { + return type; } return unknownType; } if (!seen) { + if (promisedType === type) { + // if we have a bad actor in the form of a promise whose promised type is the same + // promise, return the unknown type as we cannot guess the shape. + // if this were the actual case in the JavaScript, this Promise would never resolve. + if (location) { + error(location, Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member); + } + + return unknownType; + } + seen = []; seen[type.id] = true; - seen[promisedType.id] = true; } - else if (seen[nestedPromisedType.id]) { + else if (seen[promisedType.id]) { // if we've already seen this type, this is a promise that // would never resolve. As above, we return the unknown type. if (location) { @@ -9068,8 +9088,8 @@ module ts { return unknownType; } - seen[nestedPromisedType.id] = true; - promisedType = nestedPromisedType; + seen[promisedType.id] = true; + type = promisedType; } } @@ -9089,15 +9109,11 @@ module ts { function checkAsyncFunctionReturnType(node: SignatureDeclaration, returnType: Type): Type { let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType !== emptyObjectType) { - if (!returnType) { - returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - - // get the constructor type of the return type + // get the constructor type of the return type let declaredType = returnType.symbol ? getTypeOfSymbol(returnType.symbol) : emptyObjectType; if (isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { let promisedType = getPromisedType(returnType); - if (promisedType !== unknownType) { + if (promisedType) { // unwrap the promised type let promiseConstructor = getPromiseConstructor(node); if (promiseConstructor) { @@ -10045,7 +10061,7 @@ module ts { } } else if (func.type && !isAccessor(func.kind) && isAsyncFunctionLike(func)) { - checkTypeAssignableTo(getAwaitedType(exprType), getPromisedType(returnType), node.expression); + checkTypeAssignableTo(getAwaitedType(exprType), getAwaitedType(returnType), node.expression); } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -12379,6 +12395,7 @@ module ts { getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); getGlobalPromiseType = memoize(() => getGlobalType("Promise", /*arity*/ 1)); + tryGetGlobalPromiseType = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Type, /*diagnostic*/ undefined) && getGlobalPromiseType()); getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = memoize(() => getGlobalValueSymbol("Promise")); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 770f23b53b830..74f32488e5ba2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -570,6 +570,10 @@ module ts { function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { // contextFlagsToClear will contain only the context flags that are // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). let contextFlagsToClear = context & contextFlags; if (contextFlagsToClear) { // clear the requested context flags @@ -586,7 +590,11 @@ module ts { function doInsideOfContext(context: ParserContextFlags, func: () => T): T { // contextFlagsToSet will contain only the context flags that - // are not currently set that we need to temporarily enable + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). let contextFlagsToSet = context & ~contextFlags; if (contextFlagsToSet) { // set the requested context flags From b70e6a1ee549fb3ce6f0bc6714ef10d2dfcecc0c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 15:27:24 -0700 Subject: [PATCH 020/250] Added parseModifiersForArrowFunction --- src/compiler/parser.ts | 64 ++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 74f32488e5ba2..9a35015cffb4e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -984,17 +984,10 @@ module ts { return finishNode(node); } - function parseContextualModifier(t: SyntaxKind, isArrowFunction?: boolean): boolean { - return token === t && tryParse(isArrowFunction - ? nextTokenCanFollowModifierForArrowFunction - : nextTokenCanFollowModifier); + function parseContextualModifier(t: SyntaxKind): boolean { + return token === t && tryParse(nextTokenCanFollowModifier); } - function nextTokenCanFollowModifierForArrowFunction() { - nextToken(); - return canFollowModifierForArrowFunction(); - } - function nextTokenCanFollowModifier() { if (token === SyntaxKind.ConstKeyword) { // 'const' is only a modifier if followed by 'enum'. @@ -1014,24 +1007,8 @@ module ts { return canFollowModifier(); } - function parseAnyContextualModifier(isArrowFunction?: boolean): boolean { - return isModifier(token) && tryParse(isArrowFunction - ? nextTokenCanFollowModifierForArrowFunction - : nextTokenCanFollowModifier); - } - - function canFollowModifierForArrowFunction(): boolean { - // Arrow functions can have an `async` modifier, but the rules for what can follow that modifier - // differ from the rules for any other declaration. - // The `async` modifier on an async function can only be followed by an open parenthesis, - // or a less than token (in the case of a generic arrow function). - // In addition, the `async` modifier must appear on the same line as the following token. - if (scanner.hasPrecedingLineBreak()) { - return false; - } - - return token === SyntaxKind.OpenParenToken - || token === SyntaxKind.LessThanToken; + function parseAnyContextualModifier(): boolean { + return isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier(): boolean { @@ -2709,8 +2686,11 @@ module ts { } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === SyntaxKind.AsyncKeyword && !parseContextualModifier(SyntaxKind.AsyncKeyword, /*isArrowFunction*/ true)) { - return Tristate.False; + if (token === SyntaxKind.AsyncKeyword) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return Tristate.False; + } } let first = token; @@ -2788,7 +2768,7 @@ module ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); - setModifiers(node, parseModifiers(/*isArrowFunction*/ true)); + setModifiers(node, parseModifiersForArrowFunction()); let isAsync = isAsyncFunctionLike(node); // Arrow functions are never generators. @@ -3451,8 +3431,8 @@ module ts { return finishNode(node); } - function parseFunctionExpression(): FunctionExpression { // GeneratorExpression : + function parseFunctionExpression(): FunctionExpression { // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } // FunctionExpression: // function BindingIdentifieropt(FormalParameters) { FunctionBody } @@ -4283,14 +4263,14 @@ module ts { return decorators; } - function parseModifiers(isArrowFunction?: boolean): ModifiersArray { + function parseModifiers(): ModifiersArray { let flags = 0; let modifiers: ModifiersArray; while (true) { let modifierStart = scanner.getStartPos(); let modifierKind = token; - if (!parseAnyContextualModifier(isArrowFunction)) { + if (!parseAnyContextualModifier()) { break; } @@ -4298,6 +4278,7 @@ module ts { modifiers = []; modifiers.pos = modifierStart; } + flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } @@ -4308,6 +4289,23 @@ module ts { return modifiers; } + function parseModifiersForArrowFunction(): ModifiersArray { + let flags = 0; + let modifiers: ModifiersArray; + if (token === SyntaxKind.AsyncKeyword) { + let modifierStart = scanner.getStartPos(); + let modifierKind = token; + modifiers = []; + modifiers.pos = modifierStart; + flags |= modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + + return modifiers; + } + function parseClassElement(): ClassElement { if (token === SyntaxKind.SemicolonToken) { let result = createNode(SyntaxKind.SemicolonClassElement); From 890a5d81d1101fd9c5636e543205976f63e9dc6e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 15:50:30 -0700 Subject: [PATCH 021/250] Fixed missing call to nextToken() --- src/compiler/parser.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9a35015cffb4e..425741ec3cc30 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4295,6 +4295,7 @@ module ts { if (token === SyntaxKind.AsyncKeyword) { let modifierStart = scanner.getStartPos(); let modifierKind = token; + nextToken(); modifiers = []; modifiers.pos = modifierStart; flags |= modifierToFlag(modifierKind); From a565a023ebee17ae2a96b75ca29f94375d1dfb44 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 13 May 2015 17:26:28 -0700 Subject: [PATCH 022/250] Fixes missing check in isParenthesizedArrowFunctionExpressionWorker --- src/compiler/parser.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 425741ec3cc30..6e9b37c97e738 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2691,6 +2691,9 @@ module ts { if (scanner.hasPrecedingLineBreak()) { return Tristate.False; } + if (token !== SyntaxKind.OpenParenToken && token !== SyntaxKind.LessThanToken) { + return Tristate.False; + } } let first = token; From a2c50732e8866575dbfd872e02e15edab6f3a134 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 19 May 2015 12:49:47 -0700 Subject: [PATCH 023/250] Some cleanup and additional comments following PR feedback --- src/compiler/checker.ts | 211 +++++++++++------- .../diagnosticInformationMap.generated.ts | 4 +- src/compiler/diagnosticMessages.json | 10 +- ...owFunctionCapturesArguments_es6.errors.txt | 4 +- 4 files changed, 144 insertions(+), 85 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 85b63ad0d7a48..734cae63881fc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7324,21 +7324,18 @@ module ts { let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { + type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body is not the return type of the consise body, rather it - // is the awaited type of the consise body, which we will wrap in the native Promise type - // later in this function. - type = checkAwaitedExpressionCached(func.body, contextualMapper); - } - else { - type = checkExpressionCached(func.body, contextualMapper); + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = getAwaitedType(type, func, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); } } else { // Aggregate the types of expressions within all the return statements. - let types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + let types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { if (isAsync) { // For an async function, the return type will not be void, but rather a Promise for void. @@ -7393,12 +7390,13 @@ module ts { forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { - let type: Type; + let type = checkExpressionCached(expr, contextualMapper); if (isAsync) { - type = checkAwaitedExpressionCached(expr, contextualMapper); - } - else { - type = checkExpressionCached(expr, contextualMapper); + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = getAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); } if (!contains(aggregatedTypes, type)) { @@ -7515,6 +7513,7 @@ module ts { let isAsync = isAsyncFunctionLike(node); let returnType = node.type && getTypeFromTypeNode(node.type); + let promisedType: Type; if (returnType && isAsync) { promisedType = checkAsyncFunctionReturnType(node, returnType); @@ -7532,17 +7531,19 @@ module ts { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so we // should not be checking assignability of a promise to the return type. Instead, we need to - // check assignability of the awaited type of the concise body against the promised type of + // check assignability of the awaited type of the expression body against the promised type of // its return type annotation. let exprType = checkExpression(node.body); if (returnType) { if (isAsync) { - checkTypeAssignableTo(getAwaitedType(exprType, node.body), promisedType, node.body); + let awaitedType = getAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); } else { checkTypeAssignableTo(exprType, returnType, node.body); } } + checkFunctionExpressionBodies(node.body); } } @@ -8108,15 +8109,6 @@ module ts { return result; } - function checkAwaitedExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { - let links = getNodeLinks(node); - if (!links.resolvedAwaitedType) { - links.resolvedAwaitedType = getAwaitedType(checkExpressionCached(node, contextualMapper)); - } - - return links.resolvedAwaitedType; - } - function checkExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -8960,7 +8952,7 @@ module ts { } function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) { - if (!allConstituentTypesHaveKind(type, TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -8991,7 +8983,7 @@ module ts { // } // - if (allConstituentTypesHaveKind(promise, TypeFlags.Any)) { + if (promise.flags & TypeFlags.Any) { return undefined; } @@ -9005,7 +8997,7 @@ module ts { } let thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (thenFunction && allConstituentTypesHaveKind(thenFunction, TypeFlags.Any)) { + if (thenFunction && (thenFunction.flags & TypeFlags.Any)) { return undefined; } @@ -9015,7 +9007,7 @@ module ts { } let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); - if (allConstituentTypesHaveKind(onfulfilledParameterType, TypeFlags.Any)) { + if (onfulfilledParameterType.flags & TypeFlags.Any) { return undefined; } @@ -9032,6 +9024,8 @@ module ts { return getTypeAtPosition(signature, 0); } + let alreadySeenTypesForAwait: boolean[] = []; + /** * Gets the "awaited type" of a type. * @param type The type to await. @@ -9039,58 +9033,81 @@ module ts { * Promise-like type; otherwise, it is the type of the expression. This is used to reflect * The runtime behavior of the `await` keyword. */ - function getAwaitedType(type: Type, location?: Node): Type { - // `seen` keeps track of types we've tried to await to avoid cycles. - // This is to protect against a bad actor with a mutually recursive promised type: - // - // declare class PromiseA { - // then(onfulfilled: (value: PromiseB) => any, onrejected?); - // } - // declare class PromiseB { - // then(onfulfilled: (value: PromiseA) => any, onrejected?); - // } - // - let seen: boolean[]; + function getAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage): Type { + // reset the set of visited types + alreadySeenTypesForAwait.length = 0; while (true) { let promisedType = getPromisedType(type); - if (!promisedType) { - // this type could not be unwrapped further. We need to check to - // ensure it is not a thenable - if (checkNonThenableType(type, location)) { - return type; + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a known callable "then" property, then it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + if (checkNonThenableType(type, location, message)) { + break; } - return unknownType; + type = unknownType; + break; } - if (!seen) { - if (promisedType === type) { - // if we have a bad actor in the form of a promise whose promised type is the same - // promise, return the unknown type as we cannot guess the shape. - // if this were the actual case in the JavaScript, this Promise would never resolve. - if (location) { - error(location, Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member); + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments below for more information. + alreadySeenTypesForAwait[type.id] = true; + + if (alreadySeenTypesForAwait[promisedType.id]) { + // We have a bad actor in the form of a promise whose promised type is the same + // promise type, or a mutually recursive promise. Return the unknown type as we cannot guess + // the shape. If this were the actual case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might be: + // + // interface BadPromise { + // then(onfulfilled: (value: BadPromise) => any, onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a promised type of `BadPromise`. + // Since this is a self reference, we don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive promise type might be: + // + // interface BadPromiseA { + // then(onfulfilled: (value: BadPromiseB) => any, onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then(onfulfilled: (value: BadPromiseA) => any, onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + if (!message) { + message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; } - return unknownType; + error(location, message); } - seen = []; - seen[type.id] = true; - } - else if (seen[promisedType.id]) { - // if we've already seen this type, this is a promise that - // would never resolve. As above, we return the unknown type. - if (location) { - error(location, Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member); - } - - return unknownType; + type = unknownType; + break; } - seen[promisedType.id] = true; type = promisedType; } + + // Cleanup, reset the set of visited types + alreadySeenTypesForAwait.length = 0; + return type; } /** @@ -9109,20 +9126,48 @@ module ts { function checkAsyncFunctionReturnType(node: SignatureDeclaration, returnType: Type): Type { let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType !== emptyObjectType) { - // get the constructor type of the return type + // The return type of an async function will be the type of the instance. For this + // to be a type compatible with our async function emit, we must also check that + // the type of the declaration (e.g. the static side or "constructor" type of the + // promise) is a compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. let declaredType = returnType.symbol ? getTypeOfSymbol(returnType.symbol) : emptyObjectType; if (isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { - let promisedType = getPromisedType(returnType); - if (promisedType) { - // unwrap the promised type - let promiseConstructor = getPromiseConstructor(node); - if (promiseConstructor) { - checkExpressionOrQualifiedName(promiseConstructor); - } - - emitAwaiter = true; - return getAwaitedType(promisedType, node); + // Ensure we will emit the `__awaiter` helper. + emitAwaiter = true; + + // When we emit the async function, we need to ensure we emit any imports that might + // otherwise have been elided if the return type were only ever referenced in a type + // position. As such, we get the entity name of the type reference from the return + // type and check it as an expression. + let promiseConstructor = getPromiseConstructor(node); + if (promiseConstructor) { + checkExpressionOrQualifiedName(promiseConstructor); } + + // Get and return the awaited type of the return type. + return getAwaitedType(returnType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } } @@ -10060,11 +10105,15 @@ module ts { error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type && !isAccessor(func.kind) && isAsyncFunctionLike(func)) { - checkTypeAssignableTo(getAwaitedType(exprType), getAwaitedType(returnType), node.expression); - } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { - checkTypeAssignableTo(exprType, returnType, node.expression); + if (isAsyncFunctionLike(func)) { + let promisedType = getPromisedType(returnType); + let awaitedType = getAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 3f781a268098a..6469bf8b1bbf0 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -51,6 +51,8 @@ module ts { Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, @@ -376,7 +378,7 @@ module ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, 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 df419f7ec8cb1..b1e8f565790f7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -191,6 +191,14 @@ "category": "Error", "code": 1058 }, + "Return expression in async function does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1059 + }, + "Expression body for async arrow function does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1060 + }, "Enum member must have initializer.": { "category": "Error", "code": 1061 @@ -1494,7 +1502,7 @@ "category": "Error", "code": 2521 }, - "The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression.": { + "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression.": { "category": "Error", "code": 2522 }, diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt index 6b80a53f5293e..dcaba564e2339 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2522: The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2522: The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression. ==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesA function other() {} var fn = async () => await other.apply(this, arguments); ~~~~~~~~~ -!!! error TS2522: The 'arguments' object cannot be referenced in an async arrow function Consider using a standard async function expression. +!!! error TS2522: The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression. } } \ No newline at end of file From 813d227e370c280f276a3e218402c2f760f896e1 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 27 May 2015 16:31:29 -0700 Subject: [PATCH 024/250] classInterface: changed excludes flags --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c8d22b2672863..87a887da5da8b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1339,8 +1339,8 @@ module ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~ValueModule, - InterfaceExcludes = Type & ~Interface, + ClassExcludes = (Value | Type) & ~(ValueModule | Interface), + InterfaceExcludes = Type & ~(Class | Interface), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), From 18abf470c25cb839829c97fc2c3e5e98ef4a2b18 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 09:17:09 -0700 Subject: [PATCH 025/250] Revert "classInterface: changed excludes flags" This reverts commit 813d227e370c280f276a3e218402c2f760f896e1. --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 87a887da5da8b..c8d22b2672863 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1339,8 +1339,8 @@ module ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~(ValueModule | Interface), - InterfaceExcludes = Type & ~(Class | Interface), + ClassExcludes = (Value | Type) & ~ValueModule, + InterfaceExcludes = Type & ~Interface, RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), From 05500f4577aa7761e46dc5ddcbd3a2e644c4c079 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 14:49:11 -0700 Subject: [PATCH 026/250] Added merged declarations for ambient class/interfaces --- src/compiler/binder.ts | 42 +++++++++++++++++++++++++++++++----------- src/compiler/types.ts | 3 ++- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b66497fc40d59..15370d5e9db32 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -6,8 +6,8 @@ module ts { export const enum ModuleInstanceState { NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 + Instantiated = 1, + ConstEnumOnly = 2 } export function getModuleInstanceState(node: Node): ModuleInstanceState { @@ -135,6 +135,26 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } + /* internal */ + /** + * Checks if the symbol contains a class declaration declaration that is non-ambient. + */ + function hasNonAmbientClass(symbol: Symbol): boolean { + if (symbol) { + return !! forEach(symbol.declarations, (element: Declaration, index: number) => { + return (element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient)) + }); + } + } + + /** + * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names, + * @param symbols - The symbolTable which node will be added to. + * @param parent - If node is in a class, parent denotes the parent declaration. + * @param node - The declaration to be added to the symbol table + * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) + * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. + */ function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { Debug.assert(!hasDynamicName(node)); @@ -144,15 +164,15 @@ module ts { let symbol: Symbol; if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } + if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol)) ) { + if (node.name) { + node.name.parent = node; + } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations let message = symbol.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; forEach(symbol.declarations, declaration => { @@ -249,7 +269,7 @@ module ts { // 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); + setBlockScopeContainer(node, /*cleanLocals*/(symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); @@ -403,7 +423,7 @@ module ts { declareModuleMember(node, symbolKind, symbolExcludes); break; } - // fall through. + // fall through. default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; @@ -424,7 +444,7 @@ module ts { function bind(node: Node) { node.parent = parent; - + switch (node.kind) { case SyntaxKind.TypeParameter: bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); @@ -516,7 +536,7 @@ module ts { bindCatchVariableDeclaration(node); break; case SyntaxKind.ClassDeclaration: - bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); + bindBlockScopedDeclaration(node, SymbolFlags.Class, isAmbientContext(node) ? SymbolFlags.AmbientClassExcludes : SymbolFlags.ClassExcludes); break; case SyntaxKind.InterfaceDeclaration: bindDeclaration(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c8d22b2672863..807d8ce756464 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1340,7 +1340,8 @@ module ts { EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), ClassExcludes = (Value | Type) & ~ValueModule, - InterfaceExcludes = Type & ~Interface, + AmbientClassExcludes = (Value | Type) & ~(ValueModule | Interface), + InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), From 6c98c677146ec32b9c41122daffc6946ef1c599c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:26:41 -0700 Subject: [PATCH 027/250] added conformance tests --- ...lassAndInterfaceMergeConflictingMembers.ts | 23 +++++++++++++++++++ .../declaredClassMergedwithSelf.ts | 9 ++++++++ .../classDeclarations/mergedClassInterface.ts | 11 +++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts new file mode 100644 index 0000000000000..d11d67c3feabb --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts @@ -0,0 +1,23 @@ +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts new file mode 100644 index 0000000000000..4688fec9e2679 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts @@ -0,0 +1,9 @@ +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts new file mode 100644 index 0000000000000..4fac95b516ab8 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts @@ -0,0 +1,11 @@ +declare class C1 {} + +interface C1 {} + +interface C2 {} + +declare class C2 {} + +interface C2 {} + +interface C2 {} \ No newline at end of file From b864df2fd4715ad291ca834583f43bcca385d927 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:39:41 -0700 Subject: [PATCH 028/250] New Baselines for class-interface merging --- ...nterfaceMergeConflictingMembers.errors.txt | 44 +++++++++++++++++++ ...lassAndInterfaceMergeConflictingMembers.js | 26 +++++++++++ .../declaredClassMergedwithSelf.errors.txt | 27 ++++++++++++ .../reference/declaredClassMergedwithSelf.js | 12 +++++ .../reference/mergedClassInterface.js | 14 ++++++ .../reference/mergedClassInterface.symbols | 19 ++++++++ .../reference/mergedClassInterface.types | 19 ++++++++ 7 files changed, 161 insertions(+) create mode 100644 tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt create mode 100644 tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js create mode 100644 tests/baselines/reference/declaredClassMergedwithSelf.errors.txt create mode 100644 tests/baselines/reference/declaredClassMergedwithSelf.js create mode 100644 tests/baselines/reference/mergedClassInterface.js create mode 100644 tests/baselines/reference/mergedClassInterface.symbols create mode 100644 tests/baselines/reference/mergedClassInterface.types diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt new file mode 100644 index 0000000000000..48e52faae1e78 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(2,12): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(6,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (6 errors) ==== + declare class C1 { + public x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C1 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C2 { + protected x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C2 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C3 { + private x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C3 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js new file mode 100644 index 0000000000000..07b425383f439 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js @@ -0,0 +1,26 @@ +//// [classAndInterfaceMergeConflictingMembers.ts] +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} + +//// [classAndInterfaceMergeConflictingMembers.js] diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt new file mode 100644 index 0000000000000..8a783639c1c9a --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(1,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(3,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(5,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(7,11): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(9,15): error TS2300: Duplicate identifier 'C2'. + + +==== tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts (5 errors) ==== + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + interface C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. \ No newline at end of file diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.js b/tests/baselines/reference/declaredClassMergedwithSelf.js new file mode 100644 index 0000000000000..85213668adc48 --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.js @@ -0,0 +1,12 @@ +//// [declaredClassMergedwithSelf.ts] +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} + +//// [declaredClassMergedwithSelf.js] diff --git a/tests/baselines/reference/mergedClassInterface.js b/tests/baselines/reference/mergedClassInterface.js new file mode 100644 index 0000000000000..70c8b7d2b2f69 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.js @@ -0,0 +1,14 @@ +//// [mergedClassInterface.ts] +declare class C1 {} + +interface C1 {} + +interface C2 {} + +declare class C2 {} + +interface C2 {} + +interface C2 {} + +//// [mergedClassInterface.js] diff --git a/tests/baselines/reference/mergedClassInterface.symbols b/tests/baselines/reference/mergedClassInterface.symbols new file mode 100644 index 0000000000000..dc7ba89155109 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === +declare class C1 {} +>C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) + +interface C1 {} +>C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + +declare class C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + diff --git a/tests/baselines/reference/mergedClassInterface.types b/tests/baselines/reference/mergedClassInterface.types new file mode 100644 index 0000000000000..a31f147b7344f --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === +declare class C1 {} +>C1 : C1 + +interface C1 {} +>C1 : C1 + +interface C2 {} +>C2 : C2 + +declare class C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + From ed46bc3b588de7bb53209a9678d60ba64c076c30 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:43:43 -0700 Subject: [PATCH 029/250] Fixed intendation typo --- src/compiler/binder.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 32fc5872ef671..6d91d11990c5b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -164,10 +164,10 @@ module ts { let symbol: Symbol; if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol)) ) { - if (node.name) { - node.name.parent = node; - } + if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { + if (node.name) { + node.name.parent = node; + } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations @@ -269,7 +269,7 @@ module ts { // 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); + setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); From d25b91032f96ba5a0a4d92f6a7bcca84b2c598b7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:45:11 -0700 Subject: [PATCH 030/250] fixed indentation --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6d91d11990c5b..7c38b2ecb908a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -6,8 +6,8 @@ module ts { export const enum ModuleInstanceState { NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 + Instantiated = 1, + ConstEnumOnly = 2 } export function getModuleInstanceState(node: Node): ModuleInstanceState { From 1f74b134f1ece1276a00f03836853ac3e3fe67c4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 09:30:28 -0700 Subject: [PATCH 031/250] fixed style, added comment --- src/compiler/binder.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7c38b2ecb908a..975f890927e00 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,14 +135,13 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - /* internal */ /** - * Checks if the symbol contains a class declaration declaration that is non-ambient. + * Checks if the symbol contains a class declaration that is non-ambient. */ function hasNonAmbientClass(symbol: Symbol): boolean { if (symbol) { - return !! forEach(symbol.declarations, (element: Declaration, index: number) => { - return (element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient)) + return forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); }); } } @@ -164,6 +163,9 @@ module ts { let symbol: Symbol; if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); + + // Check for declarations node cannot be merged with. + // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { if (node.name) { node.name.parent = node; @@ -423,7 +425,7 @@ module ts { declareModuleMember(node, symbolKind, symbolExcludes); break; } - // fall through. + // fall through. default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; From 2d77cbdc06d7b0ef9a3e653ce0bae86a6b38a79e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 10:49:22 -0700 Subject: [PATCH 032/250] cleaner hasNonAmbientClass --- src/compiler/binder.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 975f890927e00..30514c84e4004 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -139,11 +139,9 @@ module ts { * Checks if the symbol contains a class declaration that is non-ambient. */ function hasNonAmbientClass(symbol: Symbol): boolean { - if (symbol) { - return forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - }); - } + return symbol && forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); + }); } /** From edc4611341680ea6cb7a446c73defccc83e87132 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 11:27:40 -0700 Subject: [PATCH 033/250] removed comma --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 30514c84e4004..b417892d3543f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -145,7 +145,7 @@ module ts { } /** - * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names, + * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. * @param symbols - The symbolTable which node will be added to. * @param parent - If node is in a class, parent denotes the parent declaration. * @param node - The declaration to be added to the symbol table @@ -162,7 +162,7 @@ module ts { if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - // Check for declarations node cannot be merged with. + // Check for declarations 'node' cannot be merged with. // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { if (node.name) { From a50ab3ebb00d381974ad0308aaff2c4c9091be4c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 12:20:36 -0700 Subject: [PATCH 034/250] Remove checking in declareSymbol --- src/compiler/binder.ts | 20 ++++++++++---------- src/compiler/types.ts | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b417892d3543f..60b5a622ac65a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,14 +135,14 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - /** - * Checks if the symbol contains a class declaration that is non-ambient. - */ - function hasNonAmbientClass(symbol: Symbol): boolean { - return symbol && forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - }); - } + // /** + // * Checks if the symbol contains a class declaration that is non-ambient. + // */ + // function hasNonAmbientClass(symbol: Symbol): boolean { + // return symbol && forEach(symbol.declarations, (element: Declaration) => { + // return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); + // }); + // } /** * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. @@ -164,7 +164,7 @@ module ts { // Check for declarations 'node' cannot be merged with. // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. - if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { + if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; } @@ -536,7 +536,7 @@ module ts { bindCatchVariableDeclaration(node); break; case SyntaxKind.ClassDeclaration: - bindBlockScopedDeclaration(node, SymbolFlags.Class, isAmbientContext(node) ? SymbolFlags.AmbientClassExcludes : SymbolFlags.ClassExcludes); + bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); break; case SyntaxKind.InterfaceDeclaration: bindBlockScopedDeclaration(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 890c6968de9fe..ec5a8de00513d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1472,8 +1472,7 @@ module ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~ValueModule, - AmbientClassExcludes = (Value | Type) & ~(ValueModule | Interface), + ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // class-interface mergability done in checker.ts InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums From 90e19551bc71f25473eaf559f27611ccb89b8474 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:03:01 -0700 Subject: [PATCH 035/250] merge compatiblity now performed in checker.ts --- src/compiler/binder.ts | 12 +------- src/compiler/checker.ts | 28 +++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 2 ++ src/compiler/diagnosticMessages.json | 17 +++++++---- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 60b5a622ac65a..42c22eda571d7 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,15 +135,6 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - // /** - // * Checks if the symbol contains a class declaration that is non-ambient. - // */ - // function hasNonAmbientClass(symbol: Symbol): boolean { - // return symbol && forEach(symbol.declarations, (element: Declaration) => { - // return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - // }); - // } - /** * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. * @param symbols - The symbolTable which node will be added to. @@ -162,8 +153,7 @@ module ts { if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - // Check for declarations 'node' cannot be merged with. - // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. + // Check for declarations 'node' cannot be merged with. if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 759b235ad0a9b..20b0fc6d68e98 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10393,6 +10393,15 @@ module ts { }); } + // Non-ambient classes cannot merge with interfaces. + if (!(node.flags & NodeFlags.Ambient)) { + if (forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.InterfaceDeclaration; + })) { + error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) + } + } + forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); @@ -10544,6 +10553,15 @@ module ts { return ok; } + /** + * Checks if the symbol contains a class declaration that is non-ambient. + */ + function hasNonAmbientClass(symbol: Symbol): boolean { + return symbol && forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); + }); + } + function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); @@ -10572,6 +10590,13 @@ module ts { checkIndexConstraints(type); } } + + // Interfaces cannot merge with non-ambient classes. + if (!(node.flags & NodeFlags.Ambient)) { + if (hasNonAmbientClass(symbol)) { + error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + } + } } forEach(getInterfaceBaseTypeNodes(node), heritageElement => { if (!isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -10580,6 +10605,9 @@ module ts { checkExpressionWithTypeArguments(heritageElement); }); + + + forEach(node.members, checkSourceElement); if (produceDiagnostics) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 6e73d28bdddd1..2d7fd358f7088 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -371,6 +371,8 @@ module ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + A_non_ambient_class_cannot_be_merged_with_an_interface: { code: 2506, category: DiagnosticCategory.Error, key: "A non-ambient class cannot be merged with an interface." }, + An_interface_cannot_merge_with_a_non_ambient_class: { code: 2507, category: DiagnosticCategory.Error, key: "An interface cannot merge with a non-ambient class." }, 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 d5764605d51bb..fdf3598518961 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1456,15 +1456,15 @@ "A rest element cannot contain a binding pattern.": { "category": "Error", "code": 2501 - }, + }, "'{0}' is referenced directly or indirectly in its own type annotation.": { "category": "Error", "code": 2502 - }, + }, "Cannot find namespace '{0}'.": { "category": "Error", "code": 2503 - }, + }, "No best common type exists among yield expressions.": { "category": "Error", "code": 2504 @@ -1472,8 +1472,15 @@ "A generator cannot have a 'void' type annotation.": { "category": "Error", "code": 2505 - }, - + }, + "A non-ambient class cannot be merged with an interface.": { + "category": "Error", + "code": 2506 + }, + "An interface cannot merge with a non-ambient class.": { + "category": "Error", + "code": 2507 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From c629c3fbee82ab3057b43076134574a94f30edaf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:15:23 -0700 Subject: [PATCH 036/250] deleted redundant tests --- tests/cases/compiler/class1.ts | 2 -- tests/cases/compiler/classAndInterface1.ts | 2 -- 2 files changed, 4 deletions(-) delete mode 100644 tests/cases/compiler/class1.ts delete mode 100644 tests/cases/compiler/classAndInterface1.ts diff --git a/tests/cases/compiler/class1.ts b/tests/cases/compiler/class1.ts deleted file mode 100644 index c7b2115b88b28..0000000000000 --- a/tests/cases/compiler/class1.ts +++ /dev/null @@ -1,2 +0,0 @@ -interface foo{ } // error -class foo{ } // error \ No newline at end of file diff --git a/tests/cases/compiler/classAndInterface1.ts b/tests/cases/compiler/classAndInterface1.ts deleted file mode 100644 index 79b029158572e..0000000000000 --- a/tests/cases/compiler/classAndInterface1.ts +++ /dev/null @@ -1,2 +0,0 @@ - class cli { } // error -interface cli { } // error \ No newline at end of file From e4bc29e9a036f7b82a30cfb5dd06b72510571f0e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:22:52 -0700 Subject: [PATCH 037/250] Updated tests --- ...uplicateIdentifiersAcrossFileBoundaries.ts | 33 +++++++++++ .../classAndInterfaceMerge.d.ts | 25 +++++++++ .../declaredClassMergedwithSelf.ts | 13 ++++- .../classDeclarations/mergedClassInterface.ts | 55 +++++++++++++++++-- 4 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts diff --git a/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts new file mode 100644 index 0000000000000..94e5cd94ab188 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts @@ -0,0 +1,33 @@ +// @declaration: true + +// @Filename: file1.ts +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +// @Filename: file2.ts +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts new file mode 100644 index 0000000000000..1ef7724f81d30 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts @@ -0,0 +1,25 @@ + +interface C { } + +declare class C { } + +interface C { } + +interface C { } + +declare module M { + + interface C1 { } + + class C1 { } + + interface C1 { } + + interface C1 { } + + export class C2 { } +} + +declare module M { + export interface C2 { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts index 4688fec9e2679..7445104e22833 100644 --- a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts +++ b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts @@ -1,3 +1,6 @@ + +// @Filename: file1.ts + declare class C1 {} declare class C1 {} @@ -6,4 +9,12 @@ declare class C2 {} interface C2 {} -declare class C2 {} \ No newline at end of file +declare class C2 {} + +// @Filename: file2.ts + +declare class C3 { } + +// @Filename: file3.ts + +declare class C3 { } \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts index 4fac95b516ab8..29400c63808b8 100644 --- a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts +++ b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts @@ -1,11 +1,54 @@ -declare class C1 {} +// @declaration: true -interface C1 {} +// @Filename: file1.ts -interface C2 {} +declare class C1 { } -declare class C2 {} +interface C1 { } -interface C2 {} +interface C2 { } -interface C2 {} \ No newline at end of file +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface + +class C4 { } // error -- cannot merge non-ambient class and interface + +interface C5 { + x1: number; +} + +declare class C5 { + x2: number; +} + +interface C5 { + x3: number; +} + +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +// @Filename: file2.ts + +declare class C6 { } + +interface C7 { } + +// @Filename: file3.ts + +interface C6 { } + +declare class C7 { } \ No newline at end of file From b293da4f9bec122ef3b7761b4d3606661f2f0e03 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:26:43 -0700 Subject: [PATCH 038/250] updated baselines --- .../reference/augmentedTypesClass2.errors.txt | 8 +- .../augmentedTypesInterface.errors.txt | 8 +- tests/baselines/reference/class1.errors.txt | 11 -- tests/baselines/reference/class1.js | 10 -- .../reference/classAndInterface1.errors.txt | 11 -- .../baselines/reference/classAndInterface1.js | 10 -- .../classAndInterfaceMerge.d.errors.txt | 46 +++++++ .../classAndInterfaceWithSameName.errors.txt | 30 +++-- .../reference/clinterfaces.errors.txt | 32 ++--- tests/baselines/reference/clinterfaces.js | 1 + .../baselines/reference/declInput.errors.txt | 8 +- .../declaredClassMergedwithSelf.errors.txt | 30 +++-- .../reference/declaredClassMergedwithSelf.js | 20 ++- ...ifiersAcrossContainerBoundaries.errors.txt | 8 +- ...IdentifiersAcrossFileBoundaries.errors.txt | 67 ++++++++++ ...uplicateIdentifiersAcrossFileBoundaries.js | 76 +++++++++++ .../interfaceDeclaration2.errors.txt | 8 +- .../reference/mergedClassInterface.errors.txt | 67 ++++++++++ .../reference/mergedClassInterface.js | 119 ++++++++++++++++-- .../reference/mergedClassInterface.symbols | 19 --- .../reference/mergedClassInterface.types | 19 --- .../reference/nameCollisions.errors.txt | 16 +-- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 14 +-- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 14 +-- 24 files changed, 487 insertions(+), 165 deletions(-) delete mode 100644 tests/baselines/reference/class1.errors.txt delete mode 100644 tests/baselines/reference/class1.js delete mode 100644 tests/baselines/reference/classAndInterface1.errors.txt delete mode 100644 tests/baselines/reference/classAndInterface1.js create mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.errors.txt create mode 100644 tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt create mode 100644 tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js create mode 100644 tests/baselines/reference/mergedClassInterface.errors.txt delete mode 100644 tests/baselines/reference/mergedClassInterface.symbols delete mode 100644 tests/baselines/reference/mergedClassInterface.types diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 5881e49dae92d..2622429d74395 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2300: Duplicate identifier 'c11'. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2300: Duplicate identifier 'c11'. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2507: An interface cannot merge with a non-ambient class. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2507: An interface cannot merge with a non-ambient class. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index a9fc28dd5ae57..9719539b344ed 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2300: Duplicate identifier 'i2'. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2300: Duplicate identifier 'i2'. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2507: An interface cannot merge with a non-ambient class. foo(): void; } class i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/class1.errors.txt b/tests/baselines/reference/class1.errors.txt deleted file mode 100644 index b90fae9cb402e..0000000000000 --- a/tests/baselines/reference/class1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/class1.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/class1.ts(2,7): error TS2300: Duplicate identifier 'foo'. - - -==== tests/cases/compiler/class1.ts (2 errors) ==== - interface foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. - class foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/class1.js b/tests/baselines/reference/class1.js deleted file mode 100644 index 7a104e237b6c0..0000000000000 --- a/tests/baselines/reference/class1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [class1.ts] -interface foo{ } // error -class foo{ } // error - -//// [class1.js] -var foo = (function () { - function foo() { - } - return foo; -})(); // error diff --git a/tests/baselines/reference/classAndInterface1.errors.txt b/tests/baselines/reference/classAndInterface1.errors.txt deleted file mode 100644 index 8d31e847d71e7..0000000000000 --- a/tests/baselines/reference/classAndInterface1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/classAndInterface1.ts(1,8): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/classAndInterface1.ts(2,11): error TS2300: Duplicate identifier 'cli'. - - -==== tests/cases/compiler/classAndInterface1.ts (2 errors) ==== - class cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. - interface cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterface1.js b/tests/baselines/reference/classAndInterface1.js deleted file mode 100644 index 5efabded83813..0000000000000 --- a/tests/baselines/reference/classAndInterface1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [classAndInterface1.ts] - class cli { } // error -interface cli { } // error - -//// [classAndInterface1.js] -var cli = (function () { - function cli() { - } - return cli; -})(); // error diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt new file mode 100644 index 0000000000000..d4afe3bc7c9de --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2507: An interface cannot merge with a non-ambient class. + + +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts (6 errors) ==== + + interface C { } + + declare class C { } + + interface C { } + + interface C { } + + declare module M { + + interface C1 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + class C1 { } + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + + interface C1 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + interface C1 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + export class C2 { } + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + } + + declare module M { + export interface C2 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index aa3e687cf4d3f..6bf95880ceb4d 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,27 +1,39 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2300: Duplicate identifier 'D'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. -==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2507: An interface cannot merge with a non-ambient class. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } interface D { // error ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2507: An interface cannot merge with a non-ambient class. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } } \ No newline at end of file diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index d5eab2c7994df..6e172fa0d9684 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2300: Duplicate identifier 'Bar'. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2300: Duplicate identifier 'Bar'. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2507: An interface cannot merge with a non-ambient class. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. interface C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2507: An interface cannot merge with a non-ambient class. interface D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2507: An interface cannot merge with a non-ambient class. class D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } interface Foo { ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2507: An interface cannot merge with a non-ambient class. a: string; } class Foo{ ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2507: An interface cannot merge with a non-ambient class. a: string; } diff --git a/tests/baselines/reference/clinterfaces.js b/tests/baselines/reference/clinterfaces.js index 02ae73498697a..a55924227c9ef 100644 --- a/tests/baselines/reference/clinterfaces.js +++ b/tests/baselines/reference/clinterfaces.js @@ -49,3 +49,4 @@ var Bar = (function () { } return Bar; })(); +module.exports = Foo; diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 8ec341ce15bb9..313866cf93d5f 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/declInput.ts(5,7): error TS2300: Duplicate identifier 'bar'. +tests/cases/compiler/declInput.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/declInput.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2507: An interface cannot merge with a non-ambient class. } class bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt index 8a783639c1c9a..a46dfb0d3394a 100644 --- a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -1,11 +1,15 @@ -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(1,15): error TS2300: Duplicate identifier 'C1'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(3,15): error TS2300: Duplicate identifier 'C1'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(5,15): error TS2300: Duplicate identifier 'C2'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(7,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(9,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(3,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(5,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(7,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(9,11): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file2.ts(2,15): error TS2300: Duplicate identifier 'C3'. +tests/cases/conformance/classes/classDeclarations/file3.ts(2,15): error TS2300: Duplicate identifier 'C3'. -==== tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts (5 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/file1.ts (5 errors) ==== + + declare class C1 {} ~~ !!! error TS2300: Duplicate identifier 'C1'. @@ -24,4 +28,16 @@ tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts declare class C2 {} ~~ -!!! error TS2300: Duplicate identifier 'C2'. \ No newline at end of file +!!! error TS2300: Duplicate identifier 'C2'. + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. \ No newline at end of file diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.js b/tests/baselines/reference/declaredClassMergedwithSelf.js index 85213668adc48..a38391d90dbc8 100644 --- a/tests/baselines/reference/declaredClassMergedwithSelf.js +++ b/tests/baselines/reference/declaredClassMergedwithSelf.js @@ -1,4 +1,8 @@ -//// [declaredClassMergedwithSelf.ts] +//// [tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts] //// + +//// [file1.ts] + + declare class C1 {} declare class C1 {} @@ -7,6 +11,16 @@ declare class C2 {} interface C2 {} -declare class C2 {} +declare class C2 {} + +//// [file2.ts] + +declare class C3 { } + +//// [file3.ts] + +declare class C3 { } -//// [declaredClassMergedwithSelf.js] +//// [file1.js] +//// [file2.js] +//// [file3.js] diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 6c80d13b2f44a..77a7f4ffb3553 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2300: Duplicate identifier 'I'. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2300: Duplicate identifier 'I'. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: A non-ambient class cannot be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2507: An interface cannot merge with a non-ambient class. } module M { export class I { } // error ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt new file mode 100644 index 0000000000000..0febfd77ec5ba --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -0,0 +1,67 @@ +tests/cases/compiler/file1.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file1.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file1.ts(4,10): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file1.ts(8,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged +tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/compiler/file1.ts (5 errors) ==== + interface I { } + ~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + class C1 { } + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + class C2 { } + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + function f() { } + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + class Foo { + static x: number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + module N { + export module F { + var t; + } + } + +==== tests/cases/compiler/file2.ts (6 errors) ==== + class I { } // error -- cannot merge interface with non-ambient class + ~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + interface C1 { } // error -- cannot merge interface with non-ambient class + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + function C2() { } // error -- cannot merge function with non-ambient class + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + class f { } // error -- cannot merge function with non-ambient class + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + module Foo { + ~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged + export var x: number; // error for redeclaring var in a different parent + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare module N { + export function F(); // no error because function is ambient + } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js new file mode 100644 index 0000000000000..f6e3a5652e5d0 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] //// + +//// [file1.ts] +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +//// [file2.ts] +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} + + +//// [file1.js] +var C1 = (function () { + function C1() { + } + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +function f() { } +var v = 3; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var N; +(function (N) { + var F; + (function (F) { + var t; + })(F = N.F || (N.F = {})); +})(N || (N = {})); +//// [file2.js] +var I = (function () { + function I() { + } + return I; +})(); // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +var f = (function () { + function f() { + } + return f; +})(); // error -- cannot merge function with non-ambient class +var v = 3; +var Foo; +(function (Foo) { +})(Foo || (Foo = {})); diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 9739d946bc52b..06a0e24730188 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2300: Duplicate identifier 'I2'. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate identifier 'I2'. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate iden interface I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2507: An interface cannot merge with a non-ambient class. class I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt new file mode 100644 index 0000000000000..42f0a14b8ef76 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: A non-ambient class cannot be merged with an interface. + + +==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== + + + declare class C1 { } + + interface C1 { } + + interface C2 { } + + declare class C2 { } + + class C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + + interface C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + interface C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + class C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + + interface C5 { + x1: number; + } + + declare class C5 { + x2: number; + } + + interface C5 { + x3: number; + } + + interface C5 { + x4: number; + } + + // checks if properties actually were merged + var c5 : C5; + c5.x1; + c5.x2; + c5.x3; + c5.x4; + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (0 errors) ==== + + declare class C6 { } + + interface C7 { } + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (0 errors) ==== + + interface C6 { } + + declare class C7 { } \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassInterface.js b/tests/baselines/reference/mergedClassInterface.js index 70c8b7d2b2f69..7176255655dbf 100644 --- a/tests/baselines/reference/mergedClassInterface.js +++ b/tests/baselines/reference/mergedClassInterface.js @@ -1,14 +1,117 @@ -//// [mergedClassInterface.ts] -declare class C1 {} +//// [tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts] //// + +//// [file1.ts] + + +declare class C1 { } + +interface C1 { } + +interface C2 { } + +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface -interface C1 {} +class C4 { } // error -- cannot merge non-ambient class and interface -interface C2 {} +interface C5 { + x1: number; +} -declare class C2 {} +declare class C5 { + x2: number; +} -interface C2 {} +interface C5 { + x3: number; +} -interface C2 {} +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +//// [file2.ts] + +declare class C6 { } + +interface C7 { } + +//// [file3.ts] + +interface C6 { } + +declare class C7 { } + +//// [file1.js] +var C3 = (function () { + function C3() { + } + return C3; +})(); // error -- cannot merge non-ambient class and interface +var C4 = (function () { + function C4() { + } + return C4; +})(); // error -- cannot merge non-ambient class and interface +// checks if properties actually were merged +var c5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; +//// [file2.js] +//// [file3.js] + -//// [mergedClassInterface.js] +//// [file1.d.ts] +declare class C1 { +} +interface C1 { +} +interface C2 { +} +declare class C2 { +} +declare class C3 { +} +interface C3 { +} +interface C4 { +} +declare class C4 { +} +interface C5 { + x1: number; +} +declare class C5 { + x2: number; +} +interface C5 { + x3: number; +} +interface C5 { + x4: number; +} +declare var c5: C5; +//// [file2.d.ts] +declare class C6 { +} +interface C7 { +} +//// [file3.d.ts] +interface C6 { +} +declare class C7 { +} diff --git a/tests/baselines/reference/mergedClassInterface.symbols b/tests/baselines/reference/mergedClassInterface.symbols deleted file mode 100644 index dc7ba89155109..0000000000000 --- a/tests/baselines/reference/mergedClassInterface.symbols +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === -declare class C1 {} ->C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) - -interface C1 {} ->C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) - -interface C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - -declare class C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - -interface C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - -interface C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - diff --git a/tests/baselines/reference/mergedClassInterface.types b/tests/baselines/reference/mergedClassInterface.types deleted file mode 100644 index a31f147b7344f..0000000000000 --- a/tests/baselines/reference/mergedClassInterface.types +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === -declare class C1 {} ->C1 : C1 - -interface C1 {} ->C1 : C1 - -interface C2 {} ->C2 : C2 - -declare class C2 {} ->C2 : C2 - -interface C2 {} ->C2 : C2 - -interface C2 {} ->C2 : C2 - diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 5eb7ea2cf8023..d570d9e127841 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2300: Duplicate identifier 'cli2'. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifier 'cli2'. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: A non-ambient class cannot be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifie class cli { } ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. interface cli { } // error ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2507: An interface cannot merge with a non-ambient class. interface cli2 { } ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2507: An interface cannot merge with a non-ambient class. class cli2 { } // error ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 7c796d4739869..9d6da3ec4b473 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,14 +1,14 @@ -lib.d.ts(521,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; }'. +lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +16,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 f({}, 10, 10); ~~ -!!! 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; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 4b9cb63d9aaeb..ffb619cedc76a 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,14 +1,14 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.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; }'. +lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +16,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T f({}, 10, 10); ~~ -!!! 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; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file From 0917582a014cf3973d9d7f5f2d21d0ecb094b5e7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:39:48 -0700 Subject: [PATCH 039/250] removed extra newlines --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cce77cdd7de03..4a65b3503d92c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10614,9 +10614,7 @@ module ts { checkExpressionWithTypeArguments(heritageElement); }); - - forEach(node.members, checkSourceElement); if (produceDiagnostics) { From fa06f3e4e658bda108b6fbd4c8e0c8ab39284ba4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:58:15 -0700 Subject: [PATCH 040/250] fixed merge conflict. --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d4595d4cd28d8..8f3973fbdb871 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1476,7 +1476,6 @@ "category": "Error", "code": 2505 }, -<<<<<<< HEAD "A non-ambient class cannot be merged with an interface.": { "category": "Error", "code": 2506 @@ -1485,9 +1484,6 @@ "category": "Error", "code": 2507 }, -======= - ->>>>>>> master "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From fa9b6fcb0708d9a90f3d537198107abbe235627b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 17:34:34 -0700 Subject: [PATCH 041/250] fixed loops, merged baseline --- src/compiler/checker.ts | 27 +++++---------- .../classAndInterfaceMerge.d.errors.txt | 4 +-- ...IdentifiersAcrossFileBoundaries.errors.txt | 11 +++--- ...uplicateIdentifiersAcrossFileBoundaries.js | 34 +++++++++++++++++++ 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a65b3503d92c..36012af42a5d4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10403,12 +10403,8 @@ module ts { } // Non-ambient classes cannot merge with interfaces. - if (!(node.flags & NodeFlags.Ambient)) { - if (forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.InterfaceDeclaration; - })) { - error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) - } + if (!(node.flags & NodeFlags.Ambient) && getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)) { + error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) } forEach(node.members, checkSourceElement); @@ -10562,15 +10558,6 @@ module ts { return ok; } - /** - * Checks if the symbol contains a class declaration that is non-ambient. - */ - function hasNonAmbientClass(symbol: Symbol): boolean { - return symbol && forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - }); - } - function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); @@ -10600,10 +10587,12 @@ module ts { } } - // Interfaces cannot merge with non-ambient classes. - if (!(node.flags & NodeFlags.Ambient)) { - if (hasNonAmbientClass(symbol)) { - error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + if (symbol && symbol.declarations) { + for (let declaration of symbol.declarations) { + if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) { + error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + break; + } } } } diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt index d4afe3bc7c9de..d73e5fcb2f030 100644 --- a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt +++ b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt @@ -17,7 +17,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24 interface C { } declare module M { - + interface C1 { } ~~ !!! error TS2507: An interface cannot merge with a non-ambient class. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24 interface C1 { } ~~ !!! error TS2507: An interface cannot merge with a non-ambient class. - + export class C2 { } ~~ !!! error TS2506: A non-ambient class cannot be merged with an interface. diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index 0febfd77ec5ba..bd2233306690a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/file1.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/file1.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/file1.ts(3,7): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/file1.ts(4,10): error TS2300: Duplicate identifier 'f'. -tests/cases/compiler/file1.ts(8,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/file1.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file1.ts(3,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. @@ -12,6 +12,7 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file1.ts (5 errors) ==== + interface I { } ~ !!! error TS2507: An interface cannot merge with a non-ambient class. diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js index f6e3a5652e5d0..a2509ea97f462 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js @@ -1,6 +1,7 @@ //// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] //// //// [file1.ts] + interface I { } class C1 { } class C2 { } @@ -74,3 +75,36 @@ var v = 3; var Foo; (function (Foo) { })(Foo || (Foo = {})); + + +//// [file1.d.ts] +interface I { +} +declare class C1 { +} +declare class C2 { +} +declare function f(): void; +declare var v: number; +declare class Foo { + static x: number; +} +declare module N { + module F { + } +} +//// [file2.d.ts] +declare class I { +} +interface C1 { +} +declare function C2(): void; +declare class f { +} +declare var v: number; +declare module Foo { + var x: number; +} +declare module N { + function F(): any; +} From f3278e2f0f034c592a0bb2ab931811955a1590c4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 10:32:59 -0700 Subject: [PATCH 042/250] fixed a grammatical issue --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 96950ce7b427b..b8b63c3aa4560 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -166,7 +166,7 @@ module ts { } /** - * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. + * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. * @param symbolTable - The symbol table which node will be added to. * @param parent - If node is in a class, parent denotes the parent declaration. * @param node - The declaration to be added to the symbol table @@ -185,7 +185,7 @@ module ts { // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't // give the new symbol any flags *yet*. This ensures that it will not conflict - // witht he 'excludes' flags we pass in. + // with the 'excludes' flags we pass in. // // If we do get an existing symbol, see if it conflicts with the new symbol we're // creating. For example, a 'var' symbol and a 'class' symbol will conflict within From 531f3aa0ac222d9ce50dfba8b6b8db5da205dbaa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 7 May 2015 15:11:46 -0700 Subject: [PATCH 043/250] Nodes -> Node --- src/services/services.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 400bf754a009c..52ffc75efe4ec 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4227,7 +4227,7 @@ module ts { isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - let referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } @@ -4879,10 +4879,10 @@ module ts { } Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral); - return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencedSymbolsForNodes(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { let typeChecker = program.getTypeChecker(); // Labels From 1a17aba26ae0baf681327415d1be2cc55948f7d2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 15 May 2015 17:00:13 -0700 Subject: [PATCH 044/250] Added tests. --- .../findAllRefsForDefaultExport01.ts | 21 ++++++++++++++++ .../findAllRefsForDefaultExport02.ts | 22 +++++++++++++++++ .../findAllRefsForDefaultExport03.ts | 24 +++++++++++++++++++ .../findAllRefsForDefaultExportNegative01.ts | 14 +++++++++++ .../findAllRefsForDefaultExportNegative02.ts | 15 ++++++++++++ .../findAllRefsForDefaultExportNegative03.ts | 17 +++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport01.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport02.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport03.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts new file mode 100644 index 0000000000000..87c439bd9ef98 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -0,0 +1,21 @@ +/// + +////export default class [|DefaultExportedClass|] { +////} +//// +////var x: [|DefaultExportedClass|]; +//// +////var y = new [|DefaultExportedClass|]; +//// +////namespace [|DefaultExportedClass|] { +//// var local = 100; +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts new file mode 100644 index 0000000000000..3000b7de92dda --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -0,0 +1,22 @@ +/// + +////export default function [|DefaultExportedFunction|]() { +//// return [|DefaultExportedFunction|] +////} +//// +////var x: typeof [|DefaultExportedFunction|]; +//// +////var y = [|DefaultExportedFunction|](); +//// +////namespace [|DefaultExportedFunction|] { +//// var local = 100; +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts new file mode 100644 index 0000000000000..89027879ff170 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts @@ -0,0 +1,24 @@ +/// + +////function [|f|]() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace [|f|] { +//// var local = 100; +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts b/tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts new file mode 100644 index 0000000000000..b44ab76b2921a --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts @@ -0,0 +1,14 @@ +/// + +////export default class DefaultExportedClass { +////} +//// +////var x: DefaultExportedClass; +//// +////var y = new DefaultExportedClass; +//// +////namespace /**/DefaultExportedClass { +////} + +goTo.marker(); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts b/tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts new file mode 100644 index 0000000000000..901cc3ffe0fae --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts @@ -0,0 +1,15 @@ +/// + +////export default function DefaultExportedFunction() { +//// return DefaultExportedFunction +////} +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); +//// +////namespace /**/DefaultExportedFunction { +////} + +goTo.marker(); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts b/tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts new file mode 100644 index 0000000000000..d9364b2193e18 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts @@ -0,0 +1,17 @@ +/// + +////function f() { +//// return 100; +////} +//// +////export default f; +//// +////var x: typeof f; +//// +////var y = f(); +//// +////namespace /**/f { +////} + +goTo.marker(); +verify.referencesCountIs(1); From 9907d62f3b4f4995b9d3831b52248039357ae533 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 19 May 2015 12:43:58 -0700 Subject: [PATCH 045/250] Added rename tests. --- .../fourslash/renameForDefaultExport01.ts | 23 ++++++++++++++++ .../fourslash/renameForDefaultExport02.ts | 24 +++++++++++++++++ .../fourslash/renameForDefaultExport03.ts | 26 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/cases/fourslash/renameForDefaultExport01.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport02.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport03.ts diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts new file mode 100644 index 0000000000000..ec9c3900a5e09 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -0,0 +1,23 @@ +/// + +/////** +//// * Commenting [|DefaultExportedClass|] +//// */ +////export default class /*1*/[|DefaultExportedClass|] { +////} +//// +////var x: /*2*/[|DefaultExportedClass|]; +//// +////var y = new /*3*/[|DefaultExportedClass|]; +//// +////namespace /*4*/[|DefaultExportedClass|] { +//// var local = 100; +////} + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); + verify.renameInfoSucceeded("DefaultExportedClass"); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts new file mode 100644 index 0000000000000..eea63282f5f9e --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -0,0 +1,24 @@ +/// + +/////** +//// * Commenting [|DefaultExportedFunction|] +//// */ +////export default function /*1*/[|DefaultExportedFunction|]() { +//// return /*2*/[|DefaultExportedFunction|] +////} +//// +////var x: typeof /*3*/[|DefaultExportedFunction|]; +//// +////var y = /*4*/[|DefaultExportedFunction|](); +//// +////namespace /*5*/[|DefaultExportedFunction|] { +//// var local = 100; +////} + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); + verify.renameInfoSucceeded("DefaultExportedFunction"); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts new file mode 100644 index 0000000000000..b36b04768ab3c --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -0,0 +1,26 @@ +/// + +/////** +//// * Commenting [|f|] +//// */ +////function /*1*/[|f|]() { +//// return 100; +////} +//// +////export default /*2*/[|f|]; +//// +////var x: typeof /*3*/[|f|]; +//// +////var y = /*4*/[|f|](); +//// +////namespace /*5*/[|f|] { +//// var local = 100; +////} + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); + verify.renameInfoSucceeded("f"); +} \ No newline at end of file From 693c587b86fdcaac2e6e82955adc21a4e3974d66 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 19 May 2015 15:53:16 -0700 Subject: [PATCH 046/250] Removed unused code, use valueDeclaration for symbol. --- src/compiler/checker.ts | 3 ++- src/services/services.ts | 22 +++++++--------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa2207d543123..a6d95fd3d421e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11833,7 +11833,8 @@ module ts { if (languageVersion === ScriptTarget.ES3) { defaultKeyword = "[\"default\"]"; - } else { + } + else { defaultKeyword = ".default"; } return getGeneratedNameForNode(node.parent) + defaultKeyword; diff --git a/src/services/services.ts b/src/services/services.ts index 52ffc75efe4ec..1b5ba6752de0d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4988,19 +4988,6 @@ module ts { } function getDeclaredName(symbol: Symbol, location: Node) { - // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(symbol.declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); - - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name: string; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - // If this is an export or import specifier it could have been renamed using the as syntax. // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) // so check for the propertyName. @@ -5008,7 +4995,7 @@ module ts { return location.getText(); } - name = typeChecker.symbolToString(symbol); + let name = typeChecker.symbolToString(symbol); return stripQuotes(name); } @@ -5022,7 +5009,12 @@ module ts { } // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); + // TODO (drosen): Why would we have to lookup the interned name for a function expression? + // Shouldn't we have found a scope? Consider a 'Debug.fail()'. + let functionExpression: FunctionExpression; + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.FunctionExpression) { + functionExpression = symbol.valueDeclaration; + } // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier From 24c504415e0e8896980f4a9cad8cc031f86af064 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 19 May 2015 16:15:51 -0700 Subject: [PATCH 047/250] Error smarter. --- src/harness/fourslash.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8d313c9a1a605..6867863a9414c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -882,6 +882,14 @@ module FourSlash { this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments); var ranges = this.getRanges(); + + if (!references) { + if (ranges.length !== 0) { + this.raiseError(`Expected ${ranges.length} rename locations; got none.`); + } + return; + } + if (ranges.length !== references.length) { this.raiseError(this.assertionMessage("Rename locations", references.length, ranges.length)); } From 70911a31b656c020558702c8618f7623c5a04c45 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 20 May 2015 14:58:55 -0700 Subject: [PATCH 048/250] Adjust tests. --- .../fourslash/findAllRefsForDefault04.ts | 28 +++++++++++++++++++ .../fourslash/findAllRefsForDefault05.ts | 28 +++++++++++++++++++ .../fourslash/findAllRefsForDefault06.ts | 28 +++++++++++++++++++ ...gative02.ts => findAllRefsForDefault07.ts} | 3 ++ ...gative01.ts => findAllRefsForDefault08.ts} | 3 ++ .../findAllRefsForDefaultExportNegative03.ts | 17 ----------- 6 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsForDefault04.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefault05.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefault06.ts rename tests/cases/fourslash/{findAllRefsForDefaultExportNegative02.ts => findAllRefsForDefault07.ts} (76%) rename tests/cases/fourslash/{findAllRefsForDefaultExportNegative01.ts => findAllRefsForDefault08.ts} (72%) delete mode 100644 tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts diff --git a/tests/cases/fourslash/findAllRefsForDefault04.ts b/tests/cases/fourslash/findAllRefsForDefault04.ts new file mode 100644 index 0000000000000..45b008b55fe99 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefault04.ts @@ -0,0 +1,28 @@ +/// + +////function f() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof f; +//// +////var y = f(); +//// +////namespace /**/[|f|] { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' +// site is included in the references to the namespace. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefault05.ts b/tests/cases/fourslash/findAllRefsForDefault05.ts new file mode 100644 index 0000000000000..6655138da3bc8 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefault05.ts @@ -0,0 +1,28 @@ +/// + +////function /**/[|f|]() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace f { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' site +// and all value-uses of 'f' are included in the references to the function. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefault06.ts b/tests/cases/fourslash/findAllRefsForDefault06.ts new file mode 100644 index 0000000000000..12c187b4b0c07 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefault06.ts @@ -0,0 +1,28 @@ +/// + +////function [|f|]() { +//// return 100; +////} +//// +////export default /**/[|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace [|f|] { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' site +// and all value-uses of 'f' are included in the references to the function. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts b/tests/cases/fourslash/findAllRefsForDefault07.ts similarity index 76% rename from tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts rename to tests/cases/fourslash/findAllRefsForDefault07.ts index 901cc3ffe0fae..9534a671316ef 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExportNegative02.ts +++ b/tests/cases/fourslash/findAllRefsForDefault07.ts @@ -11,5 +11,8 @@ ////namespace /**/DefaultExportedFunction { ////} +// The namespace and function do not merge, +// so the namespace should be all alone. + goTo.marker(); verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts b/tests/cases/fourslash/findAllRefsForDefault08.ts similarity index 72% rename from tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts rename to tests/cases/fourslash/findAllRefsForDefault08.ts index b44ab76b2921a..80eabbe53f40b 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExportNegative01.ts +++ b/tests/cases/fourslash/findAllRefsForDefault08.ts @@ -10,5 +10,8 @@ ////namespace /**/DefaultExportedClass { ////} +// The namespace and class do not merge, +// so the namespace should be all alone. + goTo.marker(); verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts b/tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts deleted file mode 100644 index d9364b2193e18..0000000000000 --- a/tests/cases/fourslash/findAllRefsForDefaultExportNegative03.ts +++ /dev/null @@ -1,17 +0,0 @@ -/// - -////function f() { -//// return 100; -////} -//// -////export default f; -//// -////var x: typeof f; -//// -////var y = f(); -//// -////namespace /**/f { -////} - -goTo.marker(); -verify.referencesCountIs(1); From cf193a4dc4f203c7ff5fa64e69a1f890a37b2e1b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 20 May 2015 15:34:31 -0700 Subject: [PATCH 049/250] Renamed tests. --- ...indAllRefsForDefault04.ts => findAllRefsForDefaultExport04.ts} | 0 ...indAllRefsForDefault05.ts => findAllRefsForDefaultExport05.ts} | 0 ...indAllRefsForDefault06.ts => findAllRefsForDefaultExport06.ts} | 0 ...indAllRefsForDefault07.ts => findAllRefsForDefaultExport07.ts} | 0 ...indAllRefsForDefault08.ts => findAllRefsForDefaultExport08.ts} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename tests/cases/fourslash/{findAllRefsForDefault04.ts => findAllRefsForDefaultExport04.ts} (100%) rename tests/cases/fourslash/{findAllRefsForDefault05.ts => findAllRefsForDefaultExport05.ts} (100%) rename tests/cases/fourslash/{findAllRefsForDefault06.ts => findAllRefsForDefaultExport06.ts} (100%) rename tests/cases/fourslash/{findAllRefsForDefault07.ts => findAllRefsForDefaultExport07.ts} (100%) rename tests/cases/fourslash/{findAllRefsForDefault08.ts => findAllRefsForDefaultExport08.ts} (100%) diff --git a/tests/cases/fourslash/findAllRefsForDefault04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts similarity index 100% rename from tests/cases/fourslash/findAllRefsForDefault04.ts rename to tests/cases/fourslash/findAllRefsForDefaultExport04.ts diff --git a/tests/cases/fourslash/findAllRefsForDefault05.ts b/tests/cases/fourslash/findAllRefsForDefaultExport05.ts similarity index 100% rename from tests/cases/fourslash/findAllRefsForDefault05.ts rename to tests/cases/fourslash/findAllRefsForDefaultExport05.ts diff --git a/tests/cases/fourslash/findAllRefsForDefault06.ts b/tests/cases/fourslash/findAllRefsForDefaultExport06.ts similarity index 100% rename from tests/cases/fourslash/findAllRefsForDefault06.ts rename to tests/cases/fourslash/findAllRefsForDefaultExport06.ts diff --git a/tests/cases/fourslash/findAllRefsForDefault07.ts b/tests/cases/fourslash/findAllRefsForDefaultExport07.ts similarity index 100% rename from tests/cases/fourslash/findAllRefsForDefault07.ts rename to tests/cases/fourslash/findAllRefsForDefaultExport07.ts diff --git a/tests/cases/fourslash/findAllRefsForDefault08.ts b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts similarity index 100% rename from tests/cases/fourslash/findAllRefsForDefault08.ts rename to tests/cases/fourslash/findAllRefsForDefaultExport08.ts From 2539ebe29faba45accc9ca023231108e2d5dcd39 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 20 May 2015 15:39:35 -0700 Subject: [PATCH 050/250] Verify references count. --- tests/cases/fourslash/findAllRefsForDefaultExport01.ts | 1 + tests/cases/fourslash/findAllRefsForDefaultExport02.ts | 1 + tests/cases/fourslash/findAllRefsForDefaultExport03.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts index 87c439bd9ef98..ca2f982302c75 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -15,6 +15,7 @@ let ranges = test.ranges() for (let range of ranges) { goTo.position(range.start); + verify.referencesCountIs(ranges.length); for (let expectedReference of ranges) { verify.referencesAtPositionContains(expectedReference); } diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts index 3000b7de92dda..1a0a92241f4be 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -16,6 +16,7 @@ let ranges = test.ranges() for (let range of ranges) { goTo.position(range.start); + verify.referencesCountIs(ranges.length); for (let expectedReference of ranges) { verify.referencesAtPositionContains(expectedReference); } diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts index 89027879ff170..f753d17de49be 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts @@ -18,6 +18,7 @@ let ranges = test.ranges() for (let range of ranges) { goTo.position(range.start); + verify.referencesCountIs(ranges.length); for (let expectedReference of ranges) { verify.referencesAtPositionContains(expectedReference); } From b9ddfcc0824c0fc6498f1245c092bc634be9c47a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 May 2015 12:26:41 -0700 Subject: [PATCH 051/250] Spit out JSON when expected =/= actual. --- src/harness/fourslash.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 6867863a9414c..938e486fee1db 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -891,7 +891,7 @@ module FourSlash { } if (ranges.length !== references.length) { - this.raiseError(this.assertionMessage("Rename locations", references.length, ranges.length)); + this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); } ranges = ranges.sort((r1, r2) => r1.start - r2.start); @@ -904,9 +904,7 @@ module FourSlash { if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { - this.raiseError(this.assertionMessage("Rename location", - "[" + reference.textSpan.start + "," + ts.textSpanEnd(reference.textSpan) + ")", - "[" + range.start + "," + range.end + ")")); + this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); } } } From ddb67e461a6a19f0bcbf03d2dc89091775488b5b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 May 2015 12:28:02 -0700 Subject: [PATCH 052/250] Fixed tests. --- .../findAllRefsForDefaultExport01.ts | 4 ---- .../findAllRefsForDefaultExport02.ts | 4 ---- .../fourslash/renameForDefaultExport01.ts | 11 +++------- .../fourslash/renameForDefaultExport02.ts | 11 +++------- .../fourslash/renameForDefaultExport03.ts | 7 +++---- .../fourslash/renameForDefaultExport04.ts | 14 +++++++++++++ .../fourslash/renameForDefaultExport05.ts | 14 +++++++++++++ .../fourslash/renameForDefaultExport06.ts | 14 +++++++++++++ .../fourslash/renameForDefaultExport07.ts | 15 +++++++++++++ .../fourslash/renameForDefaultExport08.ts | 15 +++++++++++++ .../fourslash/renameForDefaultExport09.ts | 21 +++++++++++++++++++ 11 files changed, 102 insertions(+), 28 deletions(-) create mode 100644 tests/cases/fourslash/renameForDefaultExport04.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport05.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport06.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport07.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport08.ts create mode 100644 tests/cases/fourslash/renameForDefaultExport09.ts diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts index ca2f982302c75..2f40af93c0203 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -6,10 +6,6 @@ ////var x: [|DefaultExportedClass|]; //// ////var y = new [|DefaultExportedClass|]; -//// -////namespace [|DefaultExportedClass|] { -//// var local = 100; -////} let ranges = test.ranges() for (let range of ranges) { diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts index 1a0a92241f4be..db773c74e3c31 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -7,10 +7,6 @@ ////var x: typeof [|DefaultExportedFunction|]; //// ////var y = [|DefaultExportedFunction|](); -//// -////namespace [|DefaultExportedFunction|] { -//// var local = 100; -////} let ranges = test.ranges() for (let range of ranges) { diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts index ec9c3900a5e09..809c127a727c2 100644 --- a/tests/cases/fourslash/renameForDefaultExport01.ts +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -1,23 +1,18 @@ /// -/////** -//// * Commenting [|DefaultExportedClass|] -//// */ ////export default class /*1*/[|DefaultExportedClass|] { ////} +/////* +//// * Commenting [|DefaultExportedClass|] +//// */ //// ////var x: /*2*/[|DefaultExportedClass|]; //// ////var y = new /*3*/[|DefaultExportedClass|]; -//// -////namespace /*4*/[|DefaultExportedClass|] { -//// var local = 100; -////} let markers = test.markers() for (let marker of markers) { goTo.position(marker.position); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); - verify.renameInfoSucceeded("DefaultExportedClass"); } \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts index eea63282f5f9e..ddf4b224023ce 100644 --- a/tests/cases/fourslash/renameForDefaultExport02.ts +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -1,24 +1,19 @@ /// -/////** -//// * Commenting [|DefaultExportedFunction|] -//// */ ////export default function /*1*/[|DefaultExportedFunction|]() { //// return /*2*/[|DefaultExportedFunction|] ////} +/////** +//// * Commenting [|DefaultExportedFunction|] +//// */ //// ////var x: typeof /*3*/[|DefaultExportedFunction|]; //// ////var y = /*4*/[|DefaultExportedFunction|](); -//// -////namespace /*5*/[|DefaultExportedFunction|] { -//// var local = 100; -////} let markers = test.markers() for (let marker of markers) { goTo.position(marker.position); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); - verify.renameInfoSucceeded("DefaultExportedFunction"); } \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts index b36b04768ab3c..6f82d96fe5e63 100644 --- a/tests/cases/fourslash/renameForDefaultExport03.ts +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -1,8 +1,5 @@ /// -/////** -//// * Commenting [|f|] -//// */ ////function /*1*/[|f|]() { //// return 100; ////} @@ -13,6 +10,9 @@ //// ////var y = /*4*/[|f|](); //// +/////** +//// * Commenting [|f|] +//// */ ////namespace /*5*/[|f|] { //// var local = 100; ////} @@ -22,5 +22,4 @@ for (let marker of markers) { goTo.position(marker.position); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); - verify.renameInfoSucceeded("f"); } \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport04.ts b/tests/cases/fourslash/renameForDefaultExport04.ts new file mode 100644 index 0000000000000..44dd764682f7a --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport04.ts @@ -0,0 +1,14 @@ +/// + +////export default class /**/[|DefaultExportedClass|] { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: DefaultExportedClass; +//// +////var y = new DefaultExportedClass; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", "DefaultExportedClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport05.ts b/tests/cases/fourslash/renameForDefaultExport05.ts new file mode 100644 index 0000000000000..926fa5dd6fdf3 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport05.ts @@ -0,0 +1,14 @@ +/// + +////export default class DefaultExportedClass { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: /**/[|DefaultExportedClass|]; +//// +////var y = new DefaultExportedClass; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", "DefaultExportedClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport06.ts b/tests/cases/fourslash/renameForDefaultExport06.ts new file mode 100644 index 0000000000000..da3ca8d92a436 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport06.ts @@ -0,0 +1,14 @@ +/// + +////export default class DefaultExportedClass { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: DefaultExportedClass; +//// +////var y = new /**/[|DefaultExportedClass|]; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", "DefaultExportedClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport07.ts b/tests/cases/fourslash/renameForDefaultExport07.ts new file mode 100644 index 0000000000000..9b1010580bf27 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport07.ts @@ -0,0 +1,15 @@ +/// + +////export default function /**/[|DefaultExportedFunction|]() { +//// return DefaultExportedFunction +////} +/////** +//// * Commenting DefaultExportedFunction +//// */ +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedFunction", "DefaultExportedFunction"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport08.ts b/tests/cases/fourslash/renameForDefaultExport08.ts new file mode 100644 index 0000000000000..033b20516beae --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport08.ts @@ -0,0 +1,15 @@ +/// + +////export default function DefaultExportedFunction() { +//// return /**/[|DefaultExportedFunction|] +////} +/////** +//// * Commenting DefaultExportedFunction +//// */ +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedFunction", "DefaultExportedFunction"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport09.ts b/tests/cases/fourslash/renameForDefaultExport09.ts new file mode 100644 index 0000000000000..568eb18a84ef8 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport09.ts @@ -0,0 +1,21 @@ +/// + +////function /**/[|f|]() { +//// return 100; +////} +//// +////export default f; +//// +////var x: typeof f; +//// +////var y = f(); +//// +/////** +//// * Commenting f +//// */ +////namespace f { +//// var local = 100; +////} + +goTo.marker(); +verify.renameInfoSucceeded("f", "f"); \ No newline at end of file From 2c4bb5717c8e4a8a0868281465b9cff62c6966ef Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 May 2015 12:29:09 -0700 Subject: [PATCH 053/250] Find the references themselves. --- src/services/services.ts | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1b5ba6752de0d..d99f3bacfc864 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4915,20 +4915,25 @@ module ts { return undefined; } + let declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g.undefined symbol + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!declarations || !declarations.length) { return undefined; } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name and we need to account for other declarations. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + let result: ReferencedSymbol[]; // Compute the meaning from the location and the symbol it references let searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for, we need to normalize it as external module names will have quote - let declaredName = getDeclaredName(symbol, node); + // Get the text to search for, we need to normalize it as external module names will have quotes + let declaredName = getDeclaredName(localExportDefaultSymbol || symbol, node); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -4942,7 +4947,7 @@ module ts { getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - let internedName = getInternedName(symbol, node, declarations) + let internedName = getInternedName(localExportDefaultSymbol || symbol, node, declarations) for (let sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -4988,9 +4993,8 @@ module ts { } function getDeclaredName(symbol: Symbol, location: Node) { - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever is under the cursor. if (isImportOrExportSpecifierName(location)) { return location.getText(); } @@ -5000,10 +5004,9 @@ module ts { return stripQuotes(name); } - function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string { - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. + function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. if (isImportOrExportSpecifierName(location)) { return location.getText(); } @@ -5014,18 +5017,13 @@ module ts { let functionExpression: FunctionExpression; if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.FunctionExpression) { functionExpression = symbol.valueDeclaration; - } - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name = functionExpression && functionExpression.name - ? functionExpression.name.text - : symbol.name; + if (functionExpression.name) { + return functionExpression.name.text; + } + } - return stripQuotes(name); + return stripQuotes(symbol.name); } function stripQuotes(name: string) { From 33693e87ddf037fbbdfcfb56bb204d1c0a5ae895 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 May 2015 12:43:58 -0700 Subject: [PATCH 054/250] Adjust expectations. --- tests/cases/fourslash/renameForDefaultExport04.ts | 2 +- tests/cases/fourslash/renameForDefaultExport05.ts | 2 +- tests/cases/fourslash/renameForDefaultExport06.ts | 2 +- tests/cases/fourslash/renameForDefaultExport07.ts | 2 +- tests/cases/fourslash/renameForDefaultExport08.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cases/fourslash/renameForDefaultExport04.ts b/tests/cases/fourslash/renameForDefaultExport04.ts index 44dd764682f7a..8c4e2733e33e1 100644 --- a/tests/cases/fourslash/renameForDefaultExport04.ts +++ b/tests/cases/fourslash/renameForDefaultExport04.ts @@ -11,4 +11,4 @@ ////var y = new DefaultExportedClass; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass", "DefaultExportedClass"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport05.ts b/tests/cases/fourslash/renameForDefaultExport05.ts index 926fa5dd6fdf3..f6c87d936dae5 100644 --- a/tests/cases/fourslash/renameForDefaultExport05.ts +++ b/tests/cases/fourslash/renameForDefaultExport05.ts @@ -11,4 +11,4 @@ ////var y = new DefaultExportedClass; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass", "DefaultExportedClass"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport06.ts b/tests/cases/fourslash/renameForDefaultExport06.ts index da3ca8d92a436..083fd29054a66 100644 --- a/tests/cases/fourslash/renameForDefaultExport06.ts +++ b/tests/cases/fourslash/renameForDefaultExport06.ts @@ -11,4 +11,4 @@ ////var y = new /**/[|DefaultExportedClass|]; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass", "DefaultExportedClass"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport07.ts b/tests/cases/fourslash/renameForDefaultExport07.ts index 9b1010580bf27..2c718a1202bc0 100644 --- a/tests/cases/fourslash/renameForDefaultExport07.ts +++ b/tests/cases/fourslash/renameForDefaultExport07.ts @@ -12,4 +12,4 @@ ////var y = DefaultExportedFunction(); goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedFunction", "DefaultExportedFunction"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedFunction"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport08.ts b/tests/cases/fourslash/renameForDefaultExport08.ts index 033b20516beae..29064180d58fb 100644 --- a/tests/cases/fourslash/renameForDefaultExport08.ts +++ b/tests/cases/fourslash/renameForDefaultExport08.ts @@ -12,4 +12,4 @@ ////var y = DefaultExportedFunction(); goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedFunction", "DefaultExportedFunction"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedFunction"); \ No newline at end of file From 6f925acacbf50c491fc55b81dff7aa177852a2f2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 May 2015 12:50:22 -0700 Subject: [PATCH 055/250] Add rename tests for function expressions. --- .../fourslash/renameInfoForFunctionExpression01.ts | 8 ++++++++ .../renameLocationsForFunctionExpression01.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/cases/fourslash/renameInfoForFunctionExpression01.ts create mode 100644 tests/cases/fourslash/renameLocationsForFunctionExpression01.ts diff --git a/tests/cases/fourslash/renameInfoForFunctionExpression01.ts b/tests/cases/fourslash/renameInfoForFunctionExpression01.ts new file mode 100644 index 0000000000000..807c4541f3f76 --- /dev/null +++ b/tests/cases/fourslash/renameInfoForFunctionExpression01.ts @@ -0,0 +1,8 @@ +/// + +////var x = function /**/[|f|](g: any, h: any) { +//// f(f, g); +////} + +goTo.marker(); +verify.renameInfoSucceeded("f"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts new file mode 100644 index 0000000000000..b2f54853c7b51 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts @@ -0,0 +1,12 @@ +/// + +////var x = function /*1*/[|f|](g: any, h: any) { +//// /*2*/[|f|](/*3*/[|f|], g); +////} + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file From 934a3bfc6d53b986ca8434fbb2001a3bfc4fffaf Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 May 2015 12:52:00 -0700 Subject: [PATCH 056/250] Fixed 'displayName'. --- src/services/services.ts | 43 ++++++++------------------------------- src/services/utilities.ts | 30 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index d99f3bacfc864..0865c68db6496 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4915,7 +4915,6 @@ module ts { return undefined; } - let declarations = symbol.declarations; // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol @@ -4923,17 +4922,13 @@ module ts { return undefined; } - // Try to get the local symbol if we're dealing with an 'export default' - // since that symbol has the "true" name and we need to account for other declarations. - let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); - let result: ReferencedSymbol[]; // Compute the meaning from the location and the symbol it references let searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); // Get the text to search for, we need to normalize it as external module names will have quotes - let declaredName = getDeclaredName(localExportDefaultSymbol || symbol, node); + let declaredName = getDeclaredName(typeChecker, symbol, node); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -4947,7 +4942,7 @@ module ts { getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - let internedName = getInternedName(localExportDefaultSymbol || symbol, node, declarations) + let internedName = getInternedName(symbol, node, declarations) for (let sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -4980,30 +4975,12 @@ module ts { }; } - function isImportOrExportSpecifierName(location: Node): boolean { - return location.parent && - (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && - (location.parent).propertyName === location; - } - function isImportOrExportSpecifierImportSymbol(symbol: Symbol) { return (symbol.flags & SymbolFlags.Alias) && forEach(symbol.declarations, declaration => { return declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ExportSpecifier; }); } - function getDeclaredName(symbol: Symbol, location: Node) { - // If this is an export or import specifier it could have been renamed using the 'as' syntax. - // If so we want to search for whatever is under the cursor. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - - let name = typeChecker.symbolToString(symbol); - - return stripQuotes(name); - } - function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever under the cursor. @@ -5023,15 +5000,12 @@ module ts { } } - return stripQuotes(symbol.name); - } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; - function stripQuotes(name: string) { - let length = name.length; - if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { - return name.substring(1, length - 1); - }; - return name; + return stripQuotes(symbol.name); } function getSymbolScope(symbol: Symbol): Node { @@ -6647,12 +6621,13 @@ module ts { } } + let displayName = getDeclaredName(typeChecker, symbol, node); let kind = getSymbolKind(symbol, node); if (kind) { return { canRename: true, localizedErrorMessage: undefined, - displayName: symbol.name, + displayName, fullDisplayName: typeChecker.getFullyQualifiedName(symbol), kind: kind, kindModifiers: getSymbolModifiers(symbol), diff --git a/src/services/utilities.ts b/src/services/utilities.ts index da0a0aa96c199..e1cbf609c86ea 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -652,4 +652,34 @@ module ts { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); } + + export function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + + let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + + return stripQuotes(name); + } + + export function isImportOrExportSpecifierName(location: Node): boolean { + return location.parent && + (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && + (location.parent).propertyName === location; + } + + export function stripQuotes(name: string) { + let length = name.length; + if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { + return name.substring(1, length - 1); + }; + return name; + } } \ No newline at end of file From 035962bee16a68876acb5ba0e9df65dc6d428ffc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 28 May 2015 11:47:12 -0700 Subject: [PATCH 057/250] Added test for find all refs of function expressions. --- .../findAllRefsForFunctionExpression01.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsForFunctionExpression01.ts diff --git a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts new file mode 100644 index 0000000000000..a312a277ebbb3 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts @@ -0,0 +1,21 @@ +/// + +// @Filename: file1.ts +////var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { +//// [|foo|]([|foo|], [|foo|]); +////} + +// @Filename: file2.ts +/////// +////foo(); + + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file From bca3d014fd65703db6d2ec094d9a81a45534c979 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 28 May 2015 12:10:18 -0700 Subject: [PATCH 058/250] Limit scope of function expressions to themselves. --- src/compiler/types.ts | 4 ++-- src/services/services.ts | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 296e75c4b76fa..0fda2989e1a0b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1582,10 +1582,10 @@ module ts { Tuple = 0x00002000, // Tuple Union = 0x00004000, // Union Anonymous = 0x00008000, // Anonymous - /* @internal */ + /* @internal */ FromSignature = 0x00010000, // Created for signature assignment check ObjectLiteral = 0x00020000, // Originates in an object literal - /* @internal */ + /* @internal */ ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type /* @internal */ ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type diff --git a/src/services/services.ts b/src/services/services.ts index 0865c68db6496..691aebf6cc301 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4988,18 +4988,6 @@ module ts { return location.getText(); } - // Special case for function expressions, whose names are solely local to their bodies. - // TODO (drosen): Why would we have to lookup the interned name for a function expression? - // Shouldn't we have found a scope? Consider a 'Debug.fail()'. - let functionExpression: FunctionExpression; - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.FunctionExpression) { - functionExpression = symbol.valueDeclaration; - - if (functionExpression.name) { - return functionExpression.name.text; - } - } - // Try to get the local symbol if we're dealing with an 'export default' // since that symbol has the "true" name. let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); @@ -5008,7 +4996,20 @@ module ts { return stripQuotes(symbol.name); } + /** + * Determines the smallest scope in which a symbol may have named references. + * + * Returns undefined if the scope cannot be determined, often implying that + * a reference to a symbol can occur anywhere. + */ function getSymbolScope(symbol: Symbol): Node { + // If this is the symbol of a function expression, then named references + // are limited to its own scope. + let valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { let privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined); From 6a7ce44aadff783151d3e8a12b1cf95a1a61077f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 29 May 2015 14:37:51 -0700 Subject: [PATCH 059/250] a deer, a female deer -> does --- src/harness/fourslash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 938e486fee1db..cbbd1d37e63a4 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -743,7 +743,7 @@ module FourSlash { var reference = references[i]; if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) { - this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); + this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); } return; } From 2b899f129a27e9bbd97de703f09315463f5cadbb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:05:18 -0700 Subject: [PATCH 060/250] simplified check --- 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 ecf22938201cb..6a45dacb32a21 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10416,7 +10416,7 @@ module ts { } // Non-ambient classes cannot merge with interfaces. - if (!(node.flags & NodeFlags.Ambient) && getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)) { + if (!(node.flags & NodeFlags.Ambient) && symbol.flags & SymbolFlags.Interface) { error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) } From 29c9286cbc35d0a0a46e8cb149e8a141032d0b96 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:11:13 -0700 Subject: [PATCH 061/250] Updated error message --- src/compiler/checker.ts | 5 +++-- src/compiler/diagnosticInformationMap.generated.ts | 3 +-- src/compiler/diagnosticMessages.json | 6 +----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6a45dacb32a21..b0b6521e23087 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10417,7 +10417,7 @@ module ts { // Non-ambient classes cannot merge with interfaces. if (!(node.flags & NodeFlags.Ambient) && symbol.flags & SymbolFlags.Interface) { - error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface) } forEach(node.members, checkSourceElement); @@ -10600,10 +10600,11 @@ module ts { } } + // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { for (let declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) { - error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 358dea6e9884e..e327a51631113 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -372,8 +372,7 @@ module ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - A_non_ambient_class_cannot_be_merged_with_an_interface: { code: 2506, category: DiagnosticCategory.Error, key: "A non-ambient class cannot be merged with an interface." }, - An_interface_cannot_merge_with_a_non_ambient_class: { code: 2507, category: DiagnosticCategory.Error, key: "An interface cannot merge with a non-ambient class." }, + Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2506, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, 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 8f3973fbdb871..871fb2d9ea83d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1476,14 +1476,10 @@ "category": "Error", "code": 2505 }, - "A non-ambient class cannot be merged with an interface.": { + "Only an ambient class can be merged with an interface.": { "category": "Error", "code": 2506 }, - "An interface cannot merge with a non-ambient class.": { - "category": "Error", - "code": 2507 - }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From d000e0164b8b3bb548d1a1451057c0e83d6a1622 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:17:29 -0700 Subject: [PATCH 062/250] updated baselines to reflect new error message --- .../reference/augmentedTypesClass2.errors.txt | 8 ++--- .../augmentedTypesInterface.errors.txt | 8 ++--- .../classAndInterfaceMerge.d.errors.txt | 24 +++++++------- .../classAndInterfaceWithSameName.errors.txt | 16 +++++----- .../reference/clinterfaces.errors.txt | 32 +++++++++---------- .../baselines/reference/declInput.errors.txt | 8 ++--- ...ifiersAcrossContainerBoundaries.errors.txt | 8 ++--- ...IdentifiersAcrossFileBoundaries.errors.txt | 16 +++++----- .../interfaceDeclaration2.errors.txt | 8 ++--- .../reference/mergedClassInterface.errors.txt | 16 +++++----- .../reference/nameCollisions.errors.txt | 16 +++++----- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 6 ++-- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 6 ++-- 13 files changed, 86 insertions(+), 86 deletions(-) diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 2622429d74395..9d0b7b25c3414 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 9719539b344ed..8ee7dc4e1e80b 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt index d73e5fcb2f030..fa0d239cdc770 100644 --- a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt +++ b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts (6 errors) ==== @@ -20,27 +20,27 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24 interface C1 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C1 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C1 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. export class C2 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } declare module M { export interface C2 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index 6bf95880ceb4d..170ff29226b2d 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. @@ -31,7 +31,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName. interface D { // error ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index 6e172fa0d9684..1d5ecd136f066 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 313866cf93d5f..4e12c802bee61 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/declInput.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/declInput.ts(1,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 77a7f4ffb3553..f8b5c5595154a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index bd2233306690a..dcb2440aa2680 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file1.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/file1.ts(3,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file1.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. -tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file2.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged @@ -15,10 +15,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. interface I { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. @@ -42,10 +42,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file2.ts (6 errors) ==== class I { } // error -- cannot merge interface with non-ambient class ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C1 { } // error -- cannot merge interface with non-ambient class ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 06a0e24730188..2789657a20208 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: A non-ambient interface I2 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt index 42f0a14b8ef76..6177b5fa8713b 100644 --- a/tests/baselines/reference/mergedClassInterface.errors.txt +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== @@ -17,19 +17,19 @@ tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: class C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C5 { x1: number; diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index d570d9e127841..bc7ec75257310 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: A non-ambient class class cli { } ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 9d6da3ec4b473..aabebad055226 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,5 +1,5 @@ -lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +8,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index ffb619cedc76a..8b1c5fbe0e2a7 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,5 +1,5 @@ -lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +8,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { From 143890b1174058bee05f54e22303ef8b19da77d8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:22:39 -0700 Subject: [PATCH 063/250] New test --- .../mergeClassInterfaceAndModule.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts diff --git a/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts new file mode 100644 index 0000000000000..4dc733d28c05f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts @@ -0,0 +1,16 @@ + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} \ No newline at end of file From 323ce242877219127a6b388d18dcc9b003791cbb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:28:18 -0700 Subject: [PATCH 064/250] new baselines got mergeClassInterfaceAndModule --- .../reference/mergeClassInterfaceAndModule.js | 19 ++++++++++ .../mergeClassInterfaceAndModule.symbols | 38 +++++++++++++++++++ .../mergeClassInterfaceAndModule.types | 38 +++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/baselines/reference/mergeClassInterfaceAndModule.js create mode 100644 tests/baselines/reference/mergeClassInterfaceAndModule.symbols create mode 100644 tests/baselines/reference/mergeClassInterfaceAndModule.types diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.js b/tests/baselines/reference/mergeClassInterfaceAndModule.js new file mode 100644 index 0000000000000..5b7315031cd21 --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.js @@ -0,0 +1,19 @@ +//// [mergeClassInterfaceAndModule.ts] + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} + +//// [mergeClassInterfaceAndModule.js] diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.symbols b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols new file mode 100644 index 0000000000000..a10227ed4618b --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +module C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +module C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +declare class C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +interface C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +interface C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.types b/tests/baselines/reference/mergeClassInterfaceAndModule.types new file mode 100644 index 0000000000000..a91691e5bacda --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : C1 + +declare class C1 {} +>C1 : C1 + +module C1 {} +>C1 : typeof C1 + +declare class C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + +module C2 {} +>C2 : typeof C2 + +declare class C3 {} +>C3 : C3 + +module C3 {} +>C3 : typeof C3 + +interface C3 {} +>C3 : C3 + +module C4 {} +>C4 : typeof C4 + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : C4 + +interface C4 {} +>C4 : C4 + From 365ea3d9099cdfe953d95b8ee75e68cdf3e53e1b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 15:51:59 -0700 Subject: [PATCH 065/250] Check for ambient context instead of ambient flag --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b0b6521e23087..d904c670195b5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10415,8 +10415,8 @@ module ts { }); } - // Non-ambient classes cannot merge with interfaces. - if (!(node.flags & NodeFlags.Ambient) && symbol.flags & SymbolFlags.Interface) { + // Interfaces cannot be merged with non-ambient classes. + if (symbol.flags & SymbolFlags.Interface && !isInAmbientContext(node)) { error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface) } @@ -10603,7 +10603,7 @@ module ts { // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { for (let declaration of symbol.declarations) { - if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) { + if (declaration.kind === SyntaxKind.ClassDeclaration && !isInAmbientContext(declaration)) { error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } From 5ef426ca02eb15605caa1aff6c4eccf70ffe06ad Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 16:11:19 -0700 Subject: [PATCH 066/250] new baselines --- .../classAndInterfaceMerge.d.errors.txt | 46 ------------------- .../classAndInterfaceMerge.d.symbols | 39 ++++++++++++++++ .../reference/classAndInterfaceMerge.d.types | 39 ++++++++++++++++ 3 files changed, 78 insertions(+), 46 deletions(-) delete mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.errors.txt create mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.symbols create mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.types diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt deleted file mode 100644 index fa0d239cdc770..0000000000000 --- a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2506: Only an ambient class can be merged with an interface. - - -==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts (6 errors) ==== - - interface C { } - - declare class C { } - - interface C { } - - interface C { } - - declare module M { - - interface C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - class C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - interface C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - interface C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - export class C2 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - } - - declare module M { - export interface C2 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.symbols b/tests/baselines/reference/classAndInterfaceMerge.d.symbols new file mode 100644 index 0000000000000..84fc2b129c145 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare class C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + class C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + export class C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + export interface C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.types b/tests/baselines/reference/classAndInterfaceMerge.d.types new file mode 100644 index 0000000000000..baab121ca6ea6 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.types @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : C + +declare class C { } +>C : C + +interface C { } +>C : C + +interface C { } +>C : C + +declare module M { +>M : typeof M + + interface C1 { } +>C1 : C1 + + class C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + export class C2 { } +>C2 : C2 +} + +declare module M { +>M : typeof M + + export interface C2 { } +>C2 : C2 +} From 3a3479d7e2ed9fd17c0ea096825143678b9f186f Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 4 Jun 2015 11:08:13 -0700 Subject: [PATCH 067/250] New Test and Baseline --- ...sImplementsMergedClassInterface.errors.txt | 41 +++++++++++++++++ .../classImplementsMergedClassInterface.js | 46 +++++++++++++++++++ .../classImplementsMergedClassInterface.ts | 23 ++++++++++ 3 files changed, 110 insertions(+) create mode 100644 tests/baselines/reference/classImplementsMergedClassInterface.errors.txt create mode 100644 tests/baselines/reference/classImplementsMergedClassInterface.js create mode 100644 tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt new file mode 100644 index 0000000000000..3e62e72be8422 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(9,7): error TS2420: Class 'C2' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C2'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(12,7): error TS2420: Class 'C3' incorrectly implements interface 'C1'. + Property 'y' is missing in type 'C3'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(16,7): error TS2420: Class 'C4' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C4'. + + +==== tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts (3 errors) ==== + declare class C1 { + x : number; + } + + interface C1 { + y : number; + } + + class C2 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C2' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C2'. + } + + class C3 implements C1 { // error -- missing y + ~~ +!!! error TS2420: Class 'C3' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'y' is missing in type 'C3'. + x : number; + } + + class C4 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C4' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C4'. + y : number; + } + + class C5 implements C1 { // okay + x : number; + y : number; + } \ No newline at end of file diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.js b/tests/baselines/reference/classImplementsMergedClassInterface.js new file mode 100644 index 0000000000000..64a0198cc1627 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.js @@ -0,0 +1,46 @@ +//// [classImplementsMergedClassInterface.ts] +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} + +//// [classImplementsMergedClassInterface.js] +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C4 = (function () { + function C4() { + } + return C4; +})(); +var C5 = (function () { + function C5() { + } + return C5; +})(); diff --git a/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts new file mode 100644 index 0000000000000..d5ac1b005bfd3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts @@ -0,0 +1,23 @@ +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} \ No newline at end of file From 72a6865f93debeb72f8bf4c17f7929808f5a90fc Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 4 Jun 2015 12:08:09 -0700 Subject: [PATCH 068/250] Updated emit to align with current proposal for ES7 async functions --- src/compiler/checker.ts | 173 ++++++++++------- src/compiler/emitter.ts | 179 ++++++++++-------- src/compiler/types.ts | 6 +- .../reference/asyncArrowFunction1_es6.js | 4 +- .../reference/asyncArrowFunction6_es6.js | 4 +- .../reference/asyncArrowFunction7_es6.js | 8 +- .../reference/asyncArrowFunction8_es6.js | 4 +- .../reference/asyncArrowFunction9_es6.js | 4 +- ...owFunctionCapturesArguments_es6.errors.txt | 13 -- ...asyncArrowFunctionCapturesArguments_es6.js | 2 +- ...ncArrowFunctionCapturesArguments_es6.types | 22 +++ .../asyncArrowFunctionCapturesThis_es6.js | 2 +- .../asyncFunctionDeclaration10_es6.js | 6 +- .../asyncFunctionDeclaration11_es6.js | 4 +- .../asyncFunctionDeclaration13_es6.js | 4 +- .../asyncFunctionDeclaration14_es6.js | 4 +- .../asyncFunctionDeclaration1_es6.js | 4 +- .../asyncFunctionDeclaration6_es6.js | 6 +- .../asyncFunctionDeclaration7_es6.js | 10 +- .../asyncFunctionDeclaration9_es6.js | 4 +- .../reference/awaitBinaryExpression1_es6.js | 4 +- .../reference/awaitBinaryExpression2_es6.js | 4 +- .../reference/awaitBinaryExpression3_es6.js | 4 +- .../reference/awaitBinaryExpression4_es6.js | 4 +- .../reference/awaitBinaryExpression5_es6.js | 4 +- .../reference/awaitCallExpression1_es6.js | 4 +- .../reference/awaitCallExpression2_es6.js | 4 +- .../reference/awaitCallExpression3_es6.js | 4 +- .../reference/awaitCallExpression4_es6.js | 4 +- .../reference/awaitCallExpression5_es6.js | 4 +- .../reference/awaitCallExpression6_es6.js | 4 +- .../reference/awaitCallExpression7_es6.js | 4 +- .../reference/awaitCallExpression8_es6.js | 4 +- 33 files changed, 291 insertions(+), 224 deletions(-) delete mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7f93b21392bfc..177c577655756 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -824,7 +824,7 @@ module ts { } // Resolves a qualified name and any involved aliases - function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags): Symbol { + function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, location?: Node): Symbol { if (nodeIsMissing(name)) { return undefined; } @@ -833,7 +833,7 @@ module ts { if (name.kind === SyntaxKind.Identifier) { let message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, (name).text, meaning, message, name); + symbol = resolveName(location || name, (name).text, meaning, message, name); if (!symbol) { return undefined; } @@ -842,7 +842,7 @@ module ts { let left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; let right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; - let namespace = resolveEntityName(left, SymbolFlags.Namespace); + let namespace = resolveEntityName(left, SymbolFlags.Namespace, location); if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) { return undefined; } @@ -3834,6 +3834,20 @@ module ts { } return links.resolvedType; } + + function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression { + switch (node.kind) { + case SyntaxKind.TypeReference: + return (node).typeName; + case SyntaxKind.ExpressionWithTypeArguments: + return (node).expression + case SyntaxKind.Identifier: + case SyntaxKind.QualifiedName: + return (node); + default: + return undefined; + } + } function getTypeFromTypeNode(node: TypeNode): Type { switch (node.kind) { @@ -5643,9 +5657,10 @@ module ts { if (languageVersion < ScriptTarget.ES6) { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (node.parserContextFlags & ParserContextFlags.Await) { - error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression); - } + } + + if (node.parserContextFlags & ParserContextFlags.Await) { + getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; } } @@ -7746,11 +7761,14 @@ module ts { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + let returnType = node.type && getTypeFromTypeNode(node.type); - let promisedType: Type; if (returnType && isAsync) { - promisedType = checkAsyncFunctionReturnType(node, returnType); + promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { @@ -9440,56 +9458,71 @@ module ts { * a `resolve` function as one of its arguments and results in an object with a * callable `then` signature. */ - function checkAsyncFunctionReturnType(node: SignatureDeclaration, returnType: Type): Type { + function checkAsyncFunctionReturnType(node: SignatureDeclaration): Type { let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType !== emptyObjectType) { - // The return type of an async function will be the type of the instance. For this - // to be a type compatible with our async function emit, we must also check that - // the type of the declaration (e.g. the static side or "constructor" type of the - // promise) is a compatible `PromiseConstructorLike`. - // - // An example might be (from lib.es6.d.ts): - // - // interface Promise { ... } - // interface PromiseConstructor { - // new (...): Promise; - // } - // declare var Promise: PromiseConstructor; - // - // When an async function declares a return type annotation of `Promise`, we - // need to get the type of the `Promise` variable declaration above, which would - // be `PromiseConstructor`. - // - // The same case applies to a class: - // - // declare class Promise { - // constructor(...); - // then(...): Promise; - // } - // - // When we get the type of the `Promise` symbol here, we get the type of the static - // side of the `Promise` class, which would be `{ new (...): Promise }`. - let declaredType = returnType.symbol ? getTypeOfSymbol(returnType.symbol) : emptyObjectType; - if (isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { - // Ensure we will emit the `__awaiter` helper. - emitAwaiter = true; - - // When we emit the async function, we need to ensure we emit any imports that might - // otherwise have been elided if the return type were only ever referenced in a type - // position. As such, we get the entity name of the type reference from the return - // type and check it as an expression. - let promiseConstructor = getPromiseConstructor(node); - if (promiseConstructor) { - checkExpressionOrQualifiedName(promiseConstructor); - } - - // Get and return the awaited type of the return type. - return getAwaitedType(returnType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter, so we report an error. + error(node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + // The return type of an async function will be the type of the instance. For this + // to be a type compatible with our async function emit, we must also check that + // the type of the declaration (e.g. the static side or "constructor" type of the + // promise) is a compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + let returnType = getTypeFromTypeNode(node.type); + let entityName = getEntityNameFromTypeNode(node.type); + let resolvedName = entityName ? resolveEntityName(entityName, SymbolFlags.Value, node) : undefined; + if (!resolvedName || !returnType.symbol) { + error(node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + if (getMergedSymbol(resolvedName) !== getMergedSymbol(returnType.symbol)) { + // If we were unable to resolve the return type as a value, report an error. + let identifier = getFirstIdentifier(entityName); + error(resolvedName.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, + identifier.text, + identifier.text); + return unknownType; + } + + // When we emit the async function, we need to ensure we emit any imports that might + // otherwise have been elided if the return type were only ever referenced in a type + // position. As such, we check the entity name as an expression. + let declaredType = checkExpressionOrQualifiedName(entityName); + + if (!isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { + // If the declared type of the return type is not assignable to a PromiseConstructorLike, report an error. + error(node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; } - error(node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; + // Get and return the awaited type of the return type. + return getAwaitedType(returnType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } /** Check a decorator */ @@ -9635,6 +9668,10 @@ module ts { checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including @@ -9670,10 +9707,9 @@ module ts { checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { let returnType = getTypeFromTypeNode(node.type); - let isAsync = isAsyncFunctionLike(node); let promisedType: Type; if (isAsync) { - promisedType = checkAsyncFunctionReturnType(node, returnType); + promisedType = checkAsyncFunctionReturnType(node); } checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); @@ -9888,13 +9924,11 @@ module ts { } } - function getPromiseConstructor(node: SignatureDeclaration): EntityName { - if (isAsyncFunctionLike(node)) { + function getPromiseConstructor(node: SignatureDeclaration): EntityName | Expression { + if (isAsyncFunctionLike(node) && node.type) { let links = getNodeLinks(node); if (!links.promiseConstructor) { - if (node.type && node.type.kind === SyntaxKind.TypeReference) { - links.promiseConstructor = (node.type).typeName; - } + links.promiseConstructor = getEntityNameFromTypeNode(node.type); } return links.promiseConstructor; @@ -10037,8 +10071,12 @@ module ts { function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node: Node) { if (node.modifiers) { if (inBlockOrObjectLiteralExpression(node)) { - // disallow all but the `async` modifier here - if (isAccessor(node.kind) || !isFunctionLike(node) || (node.modifiers.flags & ~NodeFlags.Async)) { + if (isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + } + else { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } } @@ -12973,10 +13011,15 @@ module ts { case SyntaxKind.ExportAssignment: case SyntaxKind.Parameter: break; + case SyntaxKind.FunctionDeclaration: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== SyntaxKind.AsyncKeyword) && + node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + break; case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.VariableStatement: - case SyntaxKind.FunctionDeclaration: case SyntaxKind.TypeAliasDeclaration: if (node.modifiers && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9472ed680912c..66cdebe4ee85c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -49,19 +49,20 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { };`; const awaiterHelper = ` -var __awaiter = (this && this.__awaiter) || function (generator, ctor) { - function resolve(value) { return step(generator.next(value)); } - function reject(reason) { return step(generator["throw"](reason)); } - function step(result) { - while (true) { - var done = result.done, value = result.value, then; - if (done) return value; - if (value && typeof (then = value.then) === "function") return then.call(value, resolve, reject); - result = generator.next(value); +var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, PromiseConstructor) { + PromiseConstructor || (PromiseConstructor = Promise); + return new PromiseConstructor(function (resolve, reject) { + generator = generator.call(thisArg, args); + function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); } - } - return new (ctor || Promise)(function (resolver) { resolver(resolve(undefined)); }); -}`; + step("next", void 0); + }); +};`; let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; @@ -128,7 +129,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { let writeLine = writer.writeLine; let increaseIndent = writer.increaseIndent; let decreaseIndent = writer.decreaseIndent; - + let currentSourceFile: SourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -3390,100 +3391,114 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { emitSignatureParameters(node); } - function emitAsyncSignatureAndBodyForES6(node: FunctionLikeDeclaration) { + function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) { let promiseConstructor = resolver.getPromiseConstructor(node); let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; let args: string; // An async function is emit as an outer function that calls an inner - // generator function. Any arguments of the outer function must be - // evaluated in the context of the generator function, to ensure the correct - // environment and bindings for things like binding patterns in the - // argument list. + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. // - // For async function declarations and function expressions, we want to - // pass the `arguments` object of the outer function to the inner generator - // function in the event the async function directly manipulates the `arguments` - // object. + // The emit for an async arrow without a lexical `arguments` binding might be: // - // For async arrow functions, the `arguments` object is not bound to the arrow - // but its containing function. In that case, we must collect all of the passed - // arguments into an array which we then pass to the inner generator function to - // ensure the correct environment for any binding patterns. + // // input + // let a = async (b) => { await b; } // - // Async arrow functions do not have access to the lexical `arguments` of its - // lexical container. + // // output + // let a = (b) => __awaiter(function* (b) { + // yield b; + // }, this); // - // The emit for an async arrow without parameters will look something like this: + // The emit for an async arrow with a lexical `arguments` binding might be: // - // let a = async () => await b; + // // input + // let a = async (b) => { await arguments[0]; } // - // let a = () => __awaiter(function* () { - // return yield b; - // }.apply(this)); + // // output + // let a = (b) => __awaiter(function* (arguments) { + // yield arguments[0]; + // }, this, arguments); // - // The emit for an async arrow with parameters will look something like this: + // The emit for an async function expression without a lexical `arguments` binding + // might be: // - // let a = async (b) => await b; + // // input + // let a = async function (b) { + // await b; + // } // - // let a = (...arguments_1) => __awaiter(function* (b) { - // return yield b; - // }).apply(this, arguments_1); + // // output + // let a = function (b) { + // return __awaiter(function* () { + // yield b; + // }, this); + // } // - // The emit for an async function expression will look something like this: + // The emit for an async function expression with a lexical `arguments` binding + // might be: // - // let a = async function () { - // return await b; + // // input + // let a = async function (b) { + // await arguments[0]; // } // - // let a = function () { - // return __awaiter(function* () { - // return yield b; - // }.apply(this, arguments)); + // // output + // let a = function (b) { + // return __awaiter(function* (arguments) { + // yield arguments[0]; + // }, this, arguments); // } // - if (isArrowFunction) { - // Emit the outer signature for the async arrow - if (node.parameters.length) { - args = makeUniqueName("arguments"); - write(`(...${args}) => `); - } - else { - write("() => "); - } - } - else { - // Emit the outer signature for the async function expression or declaration - args = "arguments"; - write("() {"); + + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); increaseIndent(); writeLine(); - write("return "); + write("return"); } - // Emit the call to __awaiter - write("__awaiter(function *"); - // Emit the signature and body for the inner generator function - emitSignatureParameters(node); + // Emit the call to __awaiter. + let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; + if (hasLexicalArguments) { + write(" __awaiter(function* (arguments)"); + } + else { + write(" __awaiter(function* ()"); + } + + // Emit the signature and body for the inner generator function. emitFunctionBody(node); - // Emit the call to `apply` to ensure the correct `this` and arguments. - write(".apply(this"); - if (args) { - write(`, ${args}`); - } - write(")"); + // Emit the current `this` binding. + write(", this"); + // Optionally emit the lexical arguments. + if (hasLexicalArguments) { + write(", arguments"); + } + // If the function has an explicit type annotation for a promise, emit the // constructor. if (promiseConstructor) { + // If we did not have lexical arguments, supply undefined (void 0) for + // the `arguments` parameter. + if (!hasLexicalArguments) { + write(", void 0"); + } + write(", "); - emit(promiseConstructor); + emitNodeWithoutSourceMap(promiseConstructor); } + write(")"); - // If this is not an async arrow, emit the closing brace of the outer function body + // If this is not an async arrow, emit the closing brace of the outer function body. if (!isArrowFunction) { write(";"); decreaseIndent(); @@ -3516,20 +3531,20 @@ var __awaiter = (this && this.__awaiter) || function (generator, ctor) { tempVariables = undefined; tempParameters = undefined; + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + let isAsync = isAsyncFunctionLike(node); if (isAsync && languageVersion === ScriptTarget.ES6) { - emitAsyncSignatureAndBodyForES6(node); + emitAsyncFunctionBodyForES6(node); } else { - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - emitFunctionBody(node); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0d70de93e191f..28b2bffa94a4b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1441,7 +1441,7 @@ module ts { serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[]; serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[]; serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[]; - getPromiseConstructor(node: SignatureDeclaration): EntityName; + getPromiseConstructor(node: SignatureDeclaration): EntityName | Expression; } export const enum SymbolFlags { @@ -1569,7 +1569,7 @@ module ts { SuperInstance = 0x00000100, // Instance 'super' reference SuperStatic = 0x00000200, // Static 'super' reference ContextChecked = 0x00000400, // Contextual types have been assigned - PromiseCollision = 0x00000800, // Declaration collides with the global 'Promise' + CaptureArguments = 0x00000800, // Lexical 'arguments' used in body (for async functions) // Values for enum members have been computed, and any errors have been reported for them. EnumValuesComputed = 0x00001000, @@ -1592,7 +1592,7 @@ module ts { assignmentChecks?: Map; // Cache of assignment checks hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side - promiseConstructor?: EntityName; + promiseConstructor?: EntityName | Expression; } export const enum TypeFlags { diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js index 78a2899d056e3..4ce29929de855 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.js +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -4,5 +4,5 @@ var foo = async (): Promise => { }; //// [asyncArrowFunction1_es6.js] -var foo = () => __awaiter(function *() { -}.apply(this), Promise); +var foo = () => __awaiter(function* () { +}, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js index e4da75e3cd157..1554e895d14a3 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.js +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -4,5 +4,5 @@ var foo = async (a = await): Promise => { } //// [asyncArrowFunction6_es6.js] -var foo = (...arguments_1) => __awaiter(function *(a = await) { -}.apply(this, arguments_1), Promise); +var foo = (a = await) => __awaiter(function* () { +}, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js index 9bf3fdc480f0a..459ec413da587 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.js +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -7,8 +7,8 @@ var bar = async (): Promise => { } //// [asyncArrowFunction7_es6.js] -var bar = () => __awaiter(function *() { +var bar = () => __awaiter(function* () { // 'await' here is an identifier, and not an await expression. - var foo = (...arguments_1) => __awaiter(function *(a = await) { - }.apply(this, arguments_1), Promise); -}.apply(this), Promise); + var foo = (a = await) => __awaiter(function* () { + }, this, void 0, Promise); +}, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js index 3f98f3a4f63c2..b32541fdda6b7 100644 --- a/tests/baselines/reference/asyncArrowFunction8_es6.js +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -5,6 +5,6 @@ var foo = async (): Promise => { } //// [asyncArrowFunction8_es6.js] -var foo = () => __awaiter(function *() { +var foo = () => __awaiter(function* () { var v = { [yield ]: foo }; -}.apply(this), Promise); +}, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js index b78a49afdbb76..8a9b663266c58 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -3,5 +3,5 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es6.js] -var foo = (...arguments_1) => __awaiter(function *(a = await => await) { -}.apply(this, arguments_1), Promise); +var foo = (a = await => await) => __awaiter(function* () { +}, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt deleted file mode 100644 index dcaba564e2339..0000000000000 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2522: The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression. - - -==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts (1 errors) ==== - class C { - method() { - function other() {} - var fn = async () => await other.apply(this, arguments); - ~~~~~~~~~ -!!! error TS2522: The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression. - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js index 96926ba8f41b3..86a1b6e110c6d 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -11,6 +11,6 @@ class C { class C { method() { function other() { } - var fn = () => __awaiter(function *() { return yield other.apply(this, arguments); }.apply(this)); + var fn = () => __awaiter(function* (arguments) { return yield other.apply(this, arguments); }, this, arguments); } } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types new file mode 100644 index 0000000000000..b3f6f18cde834 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + var fn = async () => await other.apply(this, arguments); +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>other.apply(this, arguments) : any +>other.apply : (thisArg: any, argArray?: any) => any +>other : () => void +>apply : (thisArg: any, argArray?: any) => any +>this : C +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js index 572c5fbe04668..afcd73b32dccf 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -9,6 +9,6 @@ class C { //// [asyncArrowFunctionCapturesThis_es6.js] class C { method() { - var fn = () => __awaiter(function *() { return yield this; }.apply(this)); + var fn = () => __awaiter(function* () { return yield this; }, this); } } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index e85492bee709b..25319680cebca 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -3,7 +3,7 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es6.js] -function foo() { - return __awaiter(function *(a = await => await) { - }.apply(this, arguments), Promise); +function foo(a = await => await) { + return __awaiter(function* () { + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js index 39bf2c20e7956..37cb4bbc0d43b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -4,6 +4,6 @@ async function await(): Promise { //// [asyncFunctionDeclaration11_es6.js] function await() { - return __awaiter(function *() { - }.apply(this, arguments), Promise); + return __awaiter(function* () { + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js index 9666fb5d7c4fb..0423ca2341ba8 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -7,8 +7,8 @@ async function foo(): Promise { //// [asyncFunctionDeclaration13_es6.js] function foo() { - return __awaiter(function *() { + return __awaiter(function* () { // Legal to use 'await' in a type context. var v; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js index 2f694f0269686..eccf374cdc3a5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -5,7 +5,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration14_es6.js] function foo() { - return __awaiter(function *() { + return __awaiter(function* () { return; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js index 75cb74a68a53e..386e1e76241e2 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -4,6 +4,6 @@ async function foo(): Promise { //// [asyncFunctionDeclaration1_es6.js] function foo() { - return __awaiter(function *() { - }.apply(this, arguments), Promise); + return __awaiter(function* () { + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js index 663e02604ead1..9bd17a7cd0ec1 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -3,7 +3,7 @@ async function foo(a = await): Promise { } //// [asyncFunctionDeclaration6_es6.js] -function foo() { - return __awaiter(function *(a = await) { - }.apply(this, arguments), Promise); +function foo(a = await) { + return __awaiter(function* () { + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js index fb913e3f6f435..b32c90664acd5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -7,11 +7,11 @@ async function bar(): Promise { //// [asyncFunctionDeclaration7_es6.js] function bar() { - return __awaiter(function *() { + return __awaiter(function* () { // 'await' here is an identifier, and not a yield expression. - function foo() { - return __awaiter(function *(a = await) { - }.apply(this, arguments), Promise); + function foo(a = await) { + return __awaiter(function* () { + }, this, void 0, Promise); } - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js index 8b5ea4c4b5c4b..3fcf3f2f7cace 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -5,7 +5,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration9_es6.js] function foo() { - return __awaiter(function *() { + return __awaiter(function* () { var v = { [yield ]: foo }; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js index f92324dcdacbc..889e937336816 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -9,9 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression1_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = (yield p) || a; "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js index e2d3b3ba46f4f..5a156d6d0d36a 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -9,9 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression2_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = (yield p) && a; "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js index 08e98d5dafee0..8b150a9fcbf48 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -9,9 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression3_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = (yield p) + a; "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js index 0eec5e990a544..c8f42d191c09b 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -9,9 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression4_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = yield p, a; "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js index d725d55404add..1c867a8abbf7b 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -10,10 +10,10 @@ async function func(): Promise { //// [awaitBinaryExpression5_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var o; o.a = yield p; "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js index 3391274ae7a5d..dc73da972acad 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.js +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression1_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = fn(a, a, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js index fd7129e84182e..a0f0944d79610 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.js +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression2_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = fn(yield p, a, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js index 4f0d55185e2d4..75e7788399325 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.js +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression3_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = fn(a, yield p, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js index 7ec6c6ff90e27..8f1756393cb6d 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.js +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression4_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = (yield pfn)(a, a, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js index f41d0ae994fdc..0752c02758b1f 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.js +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression5_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = o.fn(a, a, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js index d6c0e3707483d..3fc683dc399bd 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.js +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression6_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = o.fn(yield p, a, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js index 45e8a9fa64679..8618313587a97 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.js +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression7_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = o.fn(a, yield p, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js index 3ffac0006aecb..ceab826c58aae 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.js +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -13,9 +13,9 @@ async function func(): Promise { //// [awaitCallExpression8_es6.js] function func() { - return __awaiter(function *() { + return __awaiter(function* () { "before"; var b = (yield po).fn(a, a, a); "after"; - }.apply(this, arguments), Promise); + }, this, void 0, Promise); } From 02557b140310f3247edf5e881da43640cc72b093 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 9 Jun 2015 14:50:46 -0700 Subject: [PATCH 069/250] Emit awaiter arguments on new line --- 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 66cdebe4ee85c..d5eb314c4782d 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3476,7 +3476,9 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, emitFunctionBody(node); // Emit the current `this` binding. - write(", this"); + write(","); + writeLine(); + write("this"); // Optionally emit the lexical arguments. if (hasLexicalArguments) { From 371583b1eee87bbf923e1e04b9ac2d5ab31c4790 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 9 Jun 2015 17:08:15 -0700 Subject: [PATCH 070/250] Update baselines for emit change --- tests/baselines/reference/asyncArrowFunction1_es6.js | 3 ++- tests/baselines/reference/asyncArrowFunction6_es6.js | 3 ++- tests/baselines/reference/asyncArrowFunction7_es6.js | 6 ++++-- tests/baselines/reference/asyncArrowFunction8_es6.js | 3 ++- tests/baselines/reference/asyncArrowFunction9_es6.js | 3 ++- .../reference/asyncArrowFunctionCapturesArguments_es6.js | 3 ++- .../reference/asyncArrowFunctionCapturesThis_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration10_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration11_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration13_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration14_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration1_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration6_es6.js | 3 ++- tests/baselines/reference/asyncFunctionDeclaration7_es6.js | 6 ++++-- tests/baselines/reference/asyncFunctionDeclaration9_es6.js | 3 ++- tests/baselines/reference/awaitBinaryExpression1_es6.js | 3 ++- tests/baselines/reference/awaitBinaryExpression2_es6.js | 3 ++- tests/baselines/reference/awaitBinaryExpression3_es6.js | 3 ++- tests/baselines/reference/awaitBinaryExpression4_es6.js | 3 ++- tests/baselines/reference/awaitBinaryExpression5_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression1_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression2_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression3_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression4_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression5_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression6_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression7_es6.js | 3 ++- tests/baselines/reference/awaitCallExpression8_es6.js | 3 ++- 28 files changed, 60 insertions(+), 30 deletions(-) diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js index 4ce29929de855..257b147dbc7b2 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.js +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -5,4 +5,5 @@ var foo = async (): Promise => { //// [asyncArrowFunction1_es6.js] var foo = () => __awaiter(function* () { -}, this, void 0, Promise); +}, +this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js index 1554e895d14a3..48035057fe05d 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.js +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -5,4 +5,5 @@ var foo = async (a = await): Promise => { //// [asyncArrowFunction6_es6.js] var foo = (a = await) => __awaiter(function* () { -}, this, void 0, Promise); +}, +this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js index 459ec413da587..6f8cf6141a893 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.js +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -10,5 +10,7 @@ var bar = async (): Promise => { var bar = () => __awaiter(function* () { // 'await' here is an identifier, and not an await expression. var foo = (a = await) => __awaiter(function* () { - }, this, void 0, Promise); -}, this, void 0, Promise); + }, + this, void 0, Promise); +}, +this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js index b32541fdda6b7..e4383a16220c6 100644 --- a/tests/baselines/reference/asyncArrowFunction8_es6.js +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -7,4 +7,5 @@ var foo = async (): Promise => { //// [asyncArrowFunction8_es6.js] var foo = () => __awaiter(function* () { var v = { [yield ]: foo }; -}, this, void 0, Promise); +}, +this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js index 8a9b663266c58..42511dd87f547 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -4,4 +4,5 @@ var foo = async (a = await => await): Promise => { //// [asyncArrowFunction9_es6.js] var foo = (a = await => await) => __awaiter(function* () { -}, this, void 0, Promise); +}, +this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js index 86a1b6e110c6d..888c935cc3f47 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -11,6 +11,7 @@ class C { class C { method() { function other() { } - var fn = () => __awaiter(function* (arguments) { return yield other.apply(this, arguments); }, this, arguments); + var fn = () => __awaiter(function* (arguments) { return yield other.apply(this, arguments); }, + this, arguments); } } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js index afcd73b32dccf..67279d7f1be09 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -9,6 +9,7 @@ class C { //// [asyncArrowFunctionCapturesThis_es6.js] class C { method() { - var fn = () => __awaiter(function* () { return yield this; }, this); + var fn = () => __awaiter(function* () { return yield this; }, + this); } } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 25319680cebca..7048ca2ffa423 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -5,5 +5,6 @@ async function foo(a = await => await): Promise { //// [asyncFunctionDeclaration10_es6.js] function foo(a = await => await) { return __awaiter(function* () { - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js index 37cb4bbc0d43b..dbf2d489a92ff 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -5,5 +5,6 @@ async function await(): Promise { //// [asyncFunctionDeclaration11_es6.js] function await() { return __awaiter(function* () { - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js index 0423ca2341ba8..35f6af6b2ff30 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -10,5 +10,6 @@ function foo() { return __awaiter(function* () { // Legal to use 'await' in a type context. var v; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js index eccf374cdc3a5..3610cabbdec63 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -7,5 +7,6 @@ async function foo(): Promise { function foo() { return __awaiter(function* () { return; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js index 386e1e76241e2..e3e1fb650964a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -5,5 +5,6 @@ async function foo(): Promise { //// [asyncFunctionDeclaration1_es6.js] function foo() { return __awaiter(function* () { - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js index 9bd17a7cd0ec1..a74d55c35ca2c 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -5,5 +5,6 @@ async function foo(a = await): Promise { //// [asyncFunctionDeclaration6_es6.js] function foo(a = await) { return __awaiter(function* () { - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js index b32c90664acd5..fcc2394a1d13d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -11,7 +11,9 @@ function bar() { // 'await' here is an identifier, and not a yield expression. function foo(a = await) { return __awaiter(function* () { - }, this, void 0, Promise); + }, + this, void 0, Promise); } - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js index 3fcf3f2f7cace..7f23510f942d6 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -7,5 +7,6 @@ async function foo(): Promise { function foo() { return __awaiter(function* () { var v = { [yield ]: foo }; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js index 889e937336816..0531f7643fcb0 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -13,5 +13,6 @@ function func() { "before"; var b = (yield p) || a; "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js index 5a156d6d0d36a..36545440f1f1f 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -13,5 +13,6 @@ function func() { "before"; var b = (yield p) && a; "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js index 8b150a9fcbf48..bfe95956ebc4a 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -13,5 +13,6 @@ function func() { "before"; var b = (yield p) + a; "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js index c8f42d191c09b..fa2dd17143e55 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -13,5 +13,6 @@ function func() { "before"; var b = yield p, a; "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js index 1c867a8abbf7b..615320e8ebb0c 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -15,5 +15,6 @@ function func() { var o; o.a = yield p; "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js index dc73da972acad..9e329e14ad2dd 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.js +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = fn(a, a, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js index a0f0944d79610..4f8e088b55dd1 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.js +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = fn(yield p, a, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js index 75e7788399325..54b5d8411d728 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.js +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = fn(a, yield p, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js index 8f1756393cb6d..9e32395df83e0 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.js +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = (yield pfn)(a, a, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js index 0752c02758b1f..76ccf06b1050c 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.js +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = o.fn(a, a, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js index 3fc683dc399bd..90b96a06ad741 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.js +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = o.fn(yield p, a, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js index 8618313587a97..e9a2edb8a9142 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.js +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = o.fn(a, yield p, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js index ceab826c58aae..e172dde417d31 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.js +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -17,5 +17,6 @@ function func() { "before"; var b = (yield po).fn(a, a, a); "after"; - }, this, void 0, Promise); + }, + this, void 0, Promise); } From cd0662725756c84e12061df26760a0527e45834d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 10 Jun 2015 15:43:22 -0700 Subject: [PATCH 071/250] Fixed Some indentation --- src/compiler/checker.ts | 100 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4adc1ad65c79f..89d30e93f5dbf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1358,7 +1358,7 @@ module ts { return result; } - function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { + function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string  { let writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); let result = writer.string(); @@ -1978,7 +1978,7 @@ module ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -2172,8 +2172,8 @@ module ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2556,7 +2556,7 @@ module ts { // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and // returns the same array. - function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[]{ + function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[] { while (true) { node = node.parent; if (!node) { @@ -2867,7 +2867,7 @@ module ts { sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } - function getDefaultConstructSignatures(classType: InterfaceType): Signature[]{ + function getDefaultConstructSignatures(classType: InterfaceType): Signature[] { let baseTypes = getBaseTypes(classType); if (baseTypes.length) { let baseType = baseTypes[0]; @@ -3606,12 +3606,12 @@ module ts { // We only support expressions that are simple qualified names. For other expressions this produces undefined. let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; + undefined; let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; let type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -4687,7 +4687,7 @@ module ts { if (source.typePredicate && target.typePredicate) { let hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; let hasDifferentTypes: boolean; - if (hasDifferentParameterIndex || + if (hasDifferentParameterIndex || (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { if (reportErrors) { @@ -4697,12 +4697,12 @@ module ts { let targetTypeText = typeToString(target.typePredicate.type); if (hasDifferentParameterIndex) { - reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, + reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); } else if (hasDifferentTypes) { - reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, + reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); } @@ -5699,7 +5699,7 @@ module ts { if (!assumeTrue) { if (type.flags & TypeFlags.Union) { return getUnionType(filter((type).types, t => !isTypeSubtypeOf(t, signature.typePredicate.type))); - } + } return type; } return getNarrowedType(type, signature.typePredicate.type); @@ -5931,20 +5931,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; } } } @@ -6409,7 +6409,7 @@ module ts { let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); - + if (restElementType) { elementTypes.push(restElementType); } @@ -7314,7 +7314,7 @@ module ts { if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - + let candidate: Signature; let typeArgumentsAreValid: boolean; let inferenceContext = originalCandidate.typeParameters @@ -8061,8 +8061,8 @@ module ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -8257,7 +8257,7 @@ module ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -8285,8 +8285,8 @@ module ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { let 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; @@ -8336,7 +8336,7 @@ module ts { function isYieldExpressionInClass(node: YieldExpression): boolean { let current: Node = node let parent = node.parent; - while (parent) { + while (parent) { if (isFunctionLike(parent) && current === (parent).body) { return false; } @@ -8703,12 +8703,12 @@ module ts { if (hasReportedError) { break; } - if (param.name.kind === SyntaxKind.ObjectBindingPattern || + if (param.name.kind === SyntaxKind.ObjectBindingPattern || param.name.kind === SyntaxKind.ArrayBindingPattern) { (function checkBindingPattern(pattern: BindingPattern) { for (let element of pattern.elements) { - if (element.name.kind === SyntaxKind.Identifier && + if (element.name.kind === SyntaxKind.Identifier && (element.name).text === typePredicate.parameterName) { error(typePredicateNode.parameterName, @@ -9463,7 +9463,7 @@ module ts { if (!nodeCanBeDecorated(node)) { return; } - + if (!compilerOptions.experimentalDecorators) { error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); } @@ -9480,7 +9480,7 @@ module ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // fall-through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -10061,7 +10061,7 @@ module ts { if (allowStringInput) { return checkElementTypeOfArrayOrString(inputType, errorNode); } - + if (isArrayLikeType(inputType)) { let indexType = getIndexTypeOfType(inputType, IndexKind.Number); if (indexType) { @@ -11147,7 +11147,7 @@ module ts { // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); + let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= NodeCheckFlags.LexicalModuleMergesWithClass; @@ -11378,7 +11378,7 @@ module ts { } function checkTypePredicate(node: TypePredicateNode) { - if(!isInLegalTypePredicatePosition(node)) { + if (!isInLegalTypePredicatePosition(node)) { error(node, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); } } @@ -12112,7 +12112,7 @@ module ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -12346,7 +12346,7 @@ module ts { break; } } - + return "Object"; } @@ -12472,7 +12472,7 @@ module ts { let isVariableDeclarationOrBindingElement = n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n); - let symbol = + let symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -12500,7 +12500,7 @@ module ts { if (!signature) { return unknownType; } - + let instantiatedSignature = getSignatureInstantiation(signature, typeArguments); return getOrCreateTypeFromSignature(instantiatedSignature); } @@ -12719,7 +12719,7 @@ module ts { } // TODO (yuisu): Fix when module is a strict mode - let errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText)|| + let errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || grammarErrorOnNode(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); return errorReport; } @@ -12843,8 +12843,8 @@ module ts { flags |= NodeFlags.Static; lastStatic = modifier; break; - - case SyntaxKind.ExportKeyword: + + case SyntaxKind.ExportKeyword: if (flags & NodeFlags.Export) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); } @@ -13196,13 +13196,13 @@ module ts { let currentKind: number; if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { // Grammar checking for computedPropertName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if ( prop.kind === SyntaxKind.MethodDeclaration) { + else if (prop.kind === SyntaxKind.MethodDeclaration) { currentKind = Property; } else if (prop.kind === SyntaxKind.GetAccessor) { @@ -13471,7 +13471,7 @@ module ts { } } - let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); + let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -13630,7 +13630,7 @@ module ts { // otherwise report generic error message. // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise let reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration){ + if (!reportErrorInClassDeclaration) { return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); } return reportErrorInClassDeclaration; From 9a57e6ff172cdb591f35ec6a02ad7d9f6401a08b Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 15 Jun 2015 12:04:15 -0700 Subject: [PATCH 072/250] Updated baselines --- src/harness/runner.ts | 2 +- .../argumentsObjectIterator02_ES6.symbols | 6 +- .../reference/arrayLiterals2ES6.symbols | 6 +- .../reference/asyncArrowFunction1_es6.symbols | 2 +- .../reference/asyncArrowFunction9_es6.symbols | 2 +- .../asyncFunctionDeclaration10_es6.symbols | 2 +- .../asyncFunctionDeclaration11_es6.symbols | 2 +- .../asyncFunctionDeclaration14_es6.symbols | 2 +- .../asyncFunctionDeclaration1_es6.symbols | 2 +- .../awaitBinaryExpression1_es6.symbols | 4 +- .../awaitBinaryExpression2_es6.symbols | 4 +- .../awaitBinaryExpression3_es6.symbols | 4 +- .../awaitBinaryExpression4_es6.symbols | 4 +- .../awaitBinaryExpression5_es6.symbols | 4 +- .../awaitCallExpression1_es6.symbols | 8 +- .../awaitCallExpression2_es6.symbols | 8 +- .../awaitCallExpression3_es6.symbols | 8 +- .../awaitCallExpression4_es6.symbols | 8 +- .../awaitCallExpression5_es6.symbols | 8 +- .../awaitCallExpression6_es6.symbols | 8 +- .../awaitCallExpression7_es6.symbols | 8 +- .../awaitCallExpression8_es6.symbols | 8 +- .../reference/callWithSpreadES6.symbols | 2 +- ...tructuringParameterDeclaration3ES5.symbols | 16 +- ...tructuringParameterDeclaration3ES6.symbols | 16 +- ...owFunctionWhenUsingArguments14_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments15_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments16_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments17_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments18_ES6.symbols | 2 +- tests/baselines/reference/for-of13.symbols | 4 +- tests/baselines/reference/for-of18.symbols | 6 +- tests/baselines/reference/for-of19.symbols | 6 +- tests/baselines/reference/for-of20.symbols | 6 +- tests/baselines/reference/for-of21.symbols | 6 +- tests/baselines/reference/for-of22.symbols | 6 +- tests/baselines/reference/for-of23.symbols | 6 +- tests/baselines/reference/for-of25.symbols | 6 +- tests/baselines/reference/for-of26.symbols | 6 +- tests/baselines/reference/for-of27.symbols | 6 +- tests/baselines/reference/for-of28.symbols | 6 +- tests/baselines/reference/for-of37.symbols | 2 +- tests/baselines/reference/for-of38.symbols | 2 +- tests/baselines/reference/for-of40.symbols | 2 +- tests/baselines/reference/for-of44.symbols | 2 +- tests/baselines/reference/for-of45.symbols | 2 +- tests/baselines/reference/for-of50.symbols | 2 +- tests/baselines/reference/for-of57.symbols | 2 +- .../reference/generatorES6_6.symbols | 6 +- .../reference/generatorOverloads4.symbols | 6 +- .../reference/generatorOverloads5.symbols | 6 +- .../reference/generatorTypeCheck1.symbols | 2 +- .../reference/generatorTypeCheck10.symbols | 2 +- .../reference/generatorTypeCheck11.symbols | 2 +- .../reference/generatorTypeCheck12.symbols | 2 +- .../reference/generatorTypeCheck13.symbols | 2 +- .../reference/generatorTypeCheck17.symbols | 2 +- .../reference/generatorTypeCheck19.symbols | 2 +- .../reference/generatorTypeCheck2.symbols | 2 +- .../reference/generatorTypeCheck26.symbols | 2 +- .../reference/generatorTypeCheck27.symbols | 2 +- .../reference/generatorTypeCheck28.symbols | 8 +- .../reference/generatorTypeCheck29.symbols | 4 +- .../reference/generatorTypeCheck3.symbols | 2 +- .../reference/generatorTypeCheck30.symbols | 4 +- .../reference/generatorTypeCheck45.symbols | 2 +- .../reference/generatorTypeCheck46.symbols | 8 +- .../reference/iterableArrayPattern1.symbols | 8 +- .../reference/iterableArrayPattern11.symbols | 6 +- .../reference/iterableArrayPattern12.symbols | 6 +- .../reference/iterableArrayPattern13.symbols | 6 +- .../reference/iterableArrayPattern2.symbols | 8 +- .../reference/iterableArrayPattern3.symbols | 6 +- .../reference/iterableArrayPattern30.symbols | 2 +- .../reference/iterableArrayPattern4.symbols | 6 +- .../reference/iterableArrayPattern9.symbols | 6 +- .../iterableContextualTyping1.symbols | 2 +- .../reference/iteratorSpreadInArray.symbols | 8 +- .../reference/iteratorSpreadInArray11.symbols | 2 +- .../reference/iteratorSpreadInArray2.symbols | 14 +- .../reference/iteratorSpreadInArray3.symbols | 8 +- .../reference/iteratorSpreadInArray4.symbols | 8 +- .../reference/iteratorSpreadInArray7.symbols | 8 +- .../reference/iteratorSpreadInCall11.symbols | 8 +- .../reference/iteratorSpreadInCall12.symbols | 14 +- .../reference/iteratorSpreadInCall3.symbols | 8 +- .../reference/iteratorSpreadInCall5.symbols | 14 +- .../reference/parserSymbolProperty1.symbols | 6 +- .../reference/parserSymbolProperty2.symbols | 6 +- .../reference/parserSymbolProperty3.symbols | 6 +- .../reference/parserSymbolProperty4.symbols | 6 +- .../reference/parserSymbolProperty5.symbols | 6 +- .../reference/parserSymbolProperty6.symbols | 6 +- .../reference/parserSymbolProperty7.symbols | 6 +- .../reference/parserSymbolProperty8.symbols | 6 +- .../reference/parserSymbolProperty9.symbols | 6 +- .../promiseVoidErrorCallback.symbols | 16 +- .../reference/symbolDeclarationEmit1.symbols | 6 +- .../reference/symbolDeclarationEmit10.symbols | 12 +- .../reference/symbolDeclarationEmit11.symbols | 24 +- .../reference/symbolDeclarationEmit13.symbols | 12 +- .../reference/symbolDeclarationEmit14.symbols | 12 +- .../reference/symbolDeclarationEmit2.symbols | 6 +- .../reference/symbolDeclarationEmit3.symbols | 18 +- .../reference/symbolDeclarationEmit4.symbols | 12 +- .../reference/symbolDeclarationEmit5.symbols | 6 +- .../reference/symbolDeclarationEmit6.symbols | 6 +- .../reference/symbolDeclarationEmit7.symbols | 6 +- .../reference/symbolDeclarationEmit8.symbols | 6 +- .../reference/symbolDeclarationEmit9.symbols | 6 +- .../reference/symbolProperty11.symbols | 6 +- .../reference/symbolProperty13.symbols | 12 +- .../reference/symbolProperty14.symbols | 12 +- .../reference/symbolProperty15.symbols | 6 +- .../reference/symbolProperty16.symbols | 12 +- .../reference/symbolProperty18.symbols | 36 +- .../reference/symbolProperty19.symbols | 24 +- .../reference/symbolProperty2.symbols | 2 +- .../reference/symbolProperty20.symbols | 24 +- .../reference/symbolProperty21.symbols | 30 +- .../reference/symbolProperty22.symbols | 12 +- .../reference/symbolProperty23.symbols | 12 +- .../reference/symbolProperty26.symbols | 12 +- .../reference/symbolProperty27.symbols | 12 +- .../reference/symbolProperty28.symbols | 12 +- .../reference/symbolProperty4.symbols | 6 +- .../reference/symbolProperty40.symbols | 30 +- .../reference/symbolProperty41.symbols | 30 +- .../reference/symbolProperty45.symbols | 12 +- .../reference/symbolProperty5.symbols | 18 +- .../reference/symbolProperty50.symbols | 6 +- .../reference/symbolProperty51.symbols | 6 +- .../reference/symbolProperty55.symbols | 12 +- .../reference/symbolProperty56.symbols | 6 +- .../reference/symbolProperty57.symbols | 8 +- .../reference/symbolProperty6.symbols | 24 +- .../reference/symbolProperty8.symbols | 12 +- .../baselines/reference/symbolType11.symbols | 6 +- .../baselines/reference/symbolType16.symbols | 2 +- ...teStringWithEmbeddedNewOperatorES6.symbols | 2 +- tests/baselines/reference/typedArrays.symbols | 330 +++++++++--------- 141 files changed, 691 insertions(+), 691 deletions(-) diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 42c2d5667c4be..13d93302f183c 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -49,7 +49,7 @@ if (testConfigFile !== '') { if (!option) { continue; } - ts.sys.write("Option: " + option + "\r\n"); + switch (option) { case 'compiler': runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols index 2b1504386622b..208646dc1013e 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols @@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe let blah = arguments[Symbol.iterator]; >blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7)) >arguments : Symbol(arguments) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) let result = []; >result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7)) diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index 5a13a359581f8..faf0b13073815 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index db10199213556..81712c324c0bc 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) }; diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.symbols b/tests/baselines/reference/asyncArrowFunction9_es6.symbols index 706baa3fbb4db..9714b119e72dd 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction9_es6.symbols @@ -4,5 +4,5 @@ var foo = async (a = await => await): Promise => { >a : Symbol(a, Decl(asyncArrowFunction9_es6.ts, 0, 17)) >await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) >await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols index e4fb76ac698d2..3bf5baec3b190 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols @@ -4,5 +4,5 @@ async function foo(a = await => await): Promise { >a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) >await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) >await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index 58bc3fc0146f7..339108848fa5a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index b0a05f8d5212e..a9679f386922a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index b5c3c1b837d5f..ce3b922cae882 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index 19a480a376d77..ea5174c203580 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = await p || a; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index b0398a7399867..6b12c72bce439 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = await p && a; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index 0c0bd1815f5ae..c4e568a54e94b 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,11 +4,11 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = await p + a; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index d5c3fa80d58ee..77c80010b647d 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = await p, a; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index b1d75d324a42b..451311947aa3a 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var o: { a: boolean; }; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index f574a34dd5121..5d44f790f23a4 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index 4e474e1db99e7..fdd6975f45b25 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 242b35baa3b98..17ba0bf92c707 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index 66974f24a71a0..5bff8aa3b2ee5 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = (await pfn)(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index 848168bc8d705..a5a883780742f 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index e8d1c38e9e251..ed6f52a4a50fb 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = o.fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index ef8834d405093..3e901f6dd1b97 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = o.fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index 888062d58d2dd..fda2b254b173c 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) "before"; var b = (await po).fn(a, a, a); diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 9cb8319d41426..0e2368210200e 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1367, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1368, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index 9f46ea81288ec..c232eb2463682 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index f5f6f0cc6fd45..89f62f9718593 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1451, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 98cb744f549d3..ad1482e7f1afd 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1703, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 84dbbf9fca40d..42db5aeaa859f 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1703, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index d1b92562299f0..453e04d752136 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1703, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index 96973f9dbf4cb..b686dd1959243 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1703, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 0b4e4b37fec0d..4ac60f9b429d5 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1703, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index bc4595f73cf00..08e5f4ff4683e 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1465, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1465, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index f5688d73566c7..066d9534051ef 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 182d45a3369bb..8c34f6f0d7a4e 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 4697f3283a629..4e7aaf7e362bf 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index fcaf9b069dc04..70c1132afbd6d 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index f72094cdf4f5f..4650725593796 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 205a57d2c0781..8401de024d976 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 6ff68dea5d45c..93e918c4bcdbd 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 19e917e7190be..04445f50171ab 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index edf8ab0a84c81..4c645d359dd55 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index d569ffae2f6dc..6887b46a44de7 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index e4f958d5ac96f..09d3b036829d5 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1876, 1), Decl(lib.d.ts, 1898, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index e8205819ba1f1..d4958740698b1 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1876, 1), Decl(lib.d.ts, 1898, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index 3e54e9651a752..3ab1825211460 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1876, 1), Decl(lib.d.ts, 1898, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index 2c4ebb582f9f2..a9ea283d6736b 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 96180033a3709..3f746c0520640 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1876, 1), Decl(lib.d.ts, 1898, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index a80a91b4fb6a1..e96abcae76e37 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1876, 1), Decl(lib.d.ts, 1898, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index da7d83844f831..b8d01d3bd1b06 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 1a9c76911ef7f..7f30b4f67973a 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) let a = yield 1; >a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index 7327e0f22ce44..c4fb9401517ab 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index a0cb5ed3610de..509ed22d1976c 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols index 775148b80e1a6..79cc3e275ad61 100644 --- a/tests/baselines/reference/generatorTypeCheck1.symbols +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === function* g1(): Iterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1674, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols index bd652fdae9267..6247bd7b85ca4 100644 --- a/tests/baselines/reference/generatorTypeCheck10.symbols +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return; } diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols index 2ede04e04cebb..dce2524d1ba3f 100644 --- a/tests/baselines/reference/generatorTypeCheck11.symbols +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return 0; } diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols index 49309243b64f3..f9c9b7b6e22a7 100644 --- a/tests/baselines/reference/generatorTypeCheck12.symbols +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return ""; } diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols index 13f633d527e93..bc43ea8c8f909 100644 --- a/tests/baselines/reference/generatorTypeCheck13.symbols +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) yield 0; return ""; diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols index ce5f683d238bf..789eb22347cfc 100644 --- a/tests/baselines/reference/generatorTypeCheck17.symbols +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols index 0b4d61fb29224..e7a5898099f29 100644 --- a/tests/baselines/reference/generatorTypeCheck19.symbols +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols index 009568c15a7db..5a0aec4d59224 100644 --- a/tests/baselines/reference/generatorTypeCheck2.symbols +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === function* g1(): Iterable { } >g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols index 6feb9b6fabdde..08cc7289ef872 100644 --- a/tests/baselines/reference/generatorTypeCheck26.symbols +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) yield x => x.length; diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols index 01cd720ca77ca..fcee922d1e909 100644 --- a/tests/baselines/reference/generatorTypeCheck27.symbols +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) yield * function* () { diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols index 11ddf19bf40be..27b246515f603 100644 --- a/tests/baselines/reference/generatorTypeCheck28.symbols +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) yield * { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) yield x => x.length; >x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols index 72e4d2dc7490c..260137dd1cf3a 100644 --- a/tests/baselines/reference/generatorTypeCheck29.symbols +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1674, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols index f39c8675d989e..a149a592e3d3c 100644 --- a/tests/baselines/reference/generatorTypeCheck3.symbols +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === function* g1(): IterableIterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1684, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols index c489eb83f2bf2..086c65685a8e3 100644 --- a/tests/baselines/reference/generatorTypeCheck30.symbols +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1674, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols index ccf9fbe57ebeb..89c01ff020353 100644 --- a/tests/baselines/reference/generatorTypeCheck45.symbols +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1674, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols index 853f0ffab162c..72d8ebf57a167 100644 --- a/tests/baselines/reference/generatorTypeCheck46.symbols +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) @@ -21,9 +21,9 @@ foo("", function* () { yield* { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) yield x => x.length >x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index d7877b5947abb..3920dc1cef466 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index a4dae0104c85a..06e38c57af41d 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 124fc600b068c..e16fe5255e4fd 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index 43641993f344e..b870919782926 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index ded5eea872675..17ac6a1feacef 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 85ecd34218b2f..468866ca32404 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index af6f8c617b253..3701cc85ed8ea 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1876, 1), Decl(lib.d.ts, 1898, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index b6b569d15c616..10225e183e6cb 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 0722765c4de1b..86c46812688fa 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index 3960aa4d5d108..ae99a4b52554e 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index e7085745aa7f1..c4a2459e26276 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index 882df437fd39c..c2fce062fb007 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1680, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index 7bc6808d849a9..cdc7bb3e2bcb6 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index bded5309f83ed..e4d1b508bb5d4 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index 0dbe4711e95ee..bd6760dd0aa21 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index 50725a3f99f89..d0bc97907526d 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index ac52c5d172abb..a7e5d7b8919f8 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 8ac205edcc579..67b9e9e500daf 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 12e4bd1bb9ba7..0c3c11c84f470 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 06226958069e4..03faf4b593ea8 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 72d4ad96aac92..5d97b2d7a017f 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 77eb6c610593a..69764d70b4531 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index 5f7f13956a824..c42bb3abb8343 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index 94701b8908a13..ba93afde83716 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index b91cd771c5d28..4829677f5160c 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 4762fb4fd7002..793b925b382dd 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index 0eb96fa03b039..e1b85f2a3b996 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index cc11d61259e84..05b002eb56940 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index eae90071b65d8..774eb2dcc4b34 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index aa15fc016594d..b01825c8ad992 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4835, 39), Decl(lib.d.ts, 4842, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4767, 1), Decl(lib.d.ts, 4853, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4835, 39), Decl(lib.d.ts, 4842, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4772, 22), Decl(lib.d.ts, 4779, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4772, 22), Decl(lib.d.ts, 4779, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4772, 22), Decl(lib.d.ts, 4779, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4772, 22), Decl(lib.d.ts, 4779, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index 0b0e820404bdc..9fae9d57c4f6d 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 5ed853abd19fd..5dba2268d2641 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index 44115a3e7309b..a6019a364e47b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index a0aa4e1142a1f..e16ec7384893e 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index 0acef2d8a7180..b2f520351f2c0 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index bfcf6243d9e47..7e9d06cd332e6 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index fcfcd0efe1400..177180b5bcae9 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index 28d4602b181c6..98cb277ad474a 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index c8a7ab36e94b8..17bda345253bc 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index d535c8ce1ec89..c4b046cc14607 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index 0860dae4a277f..58a661412da23 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 21faad440290a..7879d28b02f52 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index 9212123105def..17901fb713aac 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index 952846d768d91..4028da455a6eb 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 3b5685d1d7738..07e9b6bae2698 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index b47ae5d912dde..d4e79a064a961 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index ac05eb6195e74..2a83145da03b6 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index c45b22056af9c..1b4b23e951175 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index 40c5a86c0e91c..89df72d65430d 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index 909c6394ec267..3ee9ed595c2ad 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index 9d618e7751f87..b52c4087d7143 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index b12874d028bf0..ad4f0c7952351 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols index b0632e2eaaebb..09997f687d53f 100644 --- a/tests/baselines/reference/symbolProperty21.symbols +++ b/tests/baselines/reference/symbolProperty21.symbols @@ -5,15 +5,15 @@ interface I { >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) >T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) [Symbol.isConcatSpreadable]: U; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) } @@ -34,18 +34,18 @@ foo({ >foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1242, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) [Symbol.unscopables]: true ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) }); diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index 4c8ec1aa7f5d2..b62037e32a507 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index a8ebaf9534590..da9d07ffeed89 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index b5c726712e4d2..46babb69a87c0 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 039963b02aad7..69fe473e17c3f 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index 6ba9c126943c5..cf6ab1f5edba1 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index 99961ec662981..4e17e561bce0e 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index 62acefd45c242..e3e469764a866 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index 1635419694d01..622d1b693e87f 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 67fce3aefab3e..5aba3b8c104e8 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1234, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1234, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index 4dc58d689d8ac..7b57003e607a0 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index 9201435c09eb1..4beb1f6d9e2b9 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 199c51e65a3aa..32240efd98610 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index 95521c7e7149a..05eeace3b869e 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1208, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1209, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index 97f9966e19613..a4e335cc7d7c3 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index bc1497aaa1479..249545872b1d0 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index 0dbda66432f52..78be14d086222 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1248, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1290, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 07f572b03bc36..64452f49c9c19 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1296, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1284, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index 11be00dba4076..d40e0e7272474 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1220, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1220, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 7791f4ee2ba96..4b61749b89873 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1198, 53), Decl(lib.d.ts, 1304, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index 8133afb527335..baa4613d26b46 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1555, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 47ceb90c04ee1..f4a310ef0fcc2 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1446, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2390, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2390, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2391, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2391, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2680, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2680, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2681, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2681, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3260, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3260, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3261, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3261, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3550, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3550, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3551, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3551, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3840, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3840, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3841, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3841, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4130, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4130, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4131, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4131, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4420, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4420, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4421, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4421, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4710, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4710, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4711, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4711, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2970, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2970, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2971, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2971, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1446, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1446, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2116, 42), Decl(lib.d.ts, 2406, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2396, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2406, 44), Decl(lib.d.ts, 2696, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2686, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2986, 60), Decl(lib.d.ts, 3276, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3266, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3276, 46), Decl(lib.d.ts, 3566, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3556, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3566, 48), Decl(lib.d.ts, 3856, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3846, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3856, 46), Decl(lib.d.ts, 4146, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4136, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4146, 48), Decl(lib.d.ts, 4436, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4426, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4436, 50), Decl(lib.d.ts, 4726, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4716, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2696, 46), Decl(lib.d.ts, 2986, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2976, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) From 5316d0d0df4ca62b31dc120700e3ad90b9d134ee Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 15 Jun 2015 16:29:34 -0700 Subject: [PATCH 073/250] Abstract keyword: Added parsing and some checks keyword `abstract` is parsed at the head of class declarations and as a modifier for class member functions/variables. The following checks have been implemented: * Objects whose type is an abstract class cannot be instantiated with `new`. * all overloads of a function must match w/r/t having the abstract keyword. * a member/class decl can't use the `abstract` keyword multiple times. * a member can't be both `abstract` and `static`. * a member can't be both `abstract` and `private`. * Accessibility modifiers can't follow `abstract` * Only classes and member functions can be declared abstract. * abstract methods don't need an implementation * abstract methods can only appear in abstract classes. TODO: * forbid abstract methods from having an implementation. * make sure, barring overriding, an inherited method is abstract iff it is abstract in the parent. * If a class has an abstract members, then it must be abstract. (eg: class B does not implement inherited member 'foo()') * prevent overriding a non-abstract method with an abstract method. * update "abstractness" flag when overriding abstract method with non-abstract method. * prevent calling an abstract method via super.() * make all overloads of an abstract method adjacent to eachother. * constructors can't be declared abstract -- give appropriate error. * figure out what to emit to the *.ts file -- probably nothing. * figure out what to emit to the *.d.ts file. * process abstract declarations. --- src/compiler/checker.ts | 58 +++++++++++++++++-- .../diagnosticInformationMap.generated.ts | 6 +- src/compiler/diagnosticMessages.json | 14 ++++- src/compiler/parser.ts | 7 +++ src/compiler/utilities.ts | 10 ++-- src/services/formatting/rules.ts | 4 +- src/services/services.ts | 2 + src/services/utilities.ts | 1 + 8 files changed, 86 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 89d30e93f5dbf..d3211a8475f22 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1358,7 +1358,7 @@ module ts { return result; } - function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string  { + function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { let writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); let result = writer.string(); @@ -7454,7 +7454,7 @@ module ts { var valueDecl = (expressionType.symbol ? expressionType.symbol.valueDeclaration : undefined); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { - error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0_, declarationNameToString(valueDecl.name)); } // TS 1.0 spec: 4.11 @@ -7543,6 +7543,11 @@ module ts { return links.resolvedSignature; } + /** + * Performs typechecking on the given node, which is a call/new expression. + * @param node The call expression to be checked. + * @returns On success, the expression's signature's return type. On failure, any. + */ function checkCallExpression(node: CallExpression): Type { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); @@ -7553,6 +7558,11 @@ module ts { } if (node.kind === SyntaxKind.NewExpression) { let declaration = signature.declaration; + // let newedClass = declaration.parent; + // if(node.expression. & NodeFlags.Abstract) { + // error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declaration.name); + // } + if (declaration && declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && @@ -9123,6 +9133,9 @@ module ts { else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & NodeFlags.Abstract) { + error(o.name, Diagnostics.Overload_signatures_must_all_match_with_respect_to_modifier_0_, "abstract"); + } }); } } @@ -9139,7 +9152,7 @@ module ts { } } - let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected; + let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract; let someNodeFlags: NodeFlags = 0; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -9157,6 +9170,9 @@ module ts { return; } + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (node.flags & NodeFlags.Abstract) { return; } + let seen = false; let subsequentNode = forEachChild(node.parent, c => { if (seen) { @@ -12827,6 +12843,9 @@ module ts { else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } flags |= modifierToFlag(modifier.kind); break; @@ -12840,17 +12859,23 @@ module ts { else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= NodeFlags.Static; lastStatic = modifier; break; - - case SyntaxKind.ExportKeyword: + + case SyntaxKind.ExportKeyword: if (flags & NodeFlags.Export) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); } else if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } @@ -12874,7 +12899,28 @@ module ts { return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= NodeFlags.Ambient; - lastDeclare = modifier + lastDeclare = modifier; + break; + + case SyntaxKind.AbstractKeyword: + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== SyntaxKind.ClassDeclaration) { + if (node.kind !== SyntaxKind.MethodDeclaration) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_class_or_member_function_declaration, "abstract"); + } + if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) { + return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + } + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & NodeFlags.Private) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + flags |= NodeFlags.Abstract; break; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 4d638cf071364..47e1b8e2b391d 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -186,6 +186,9 @@ module ts { A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + _0_modifier_can_only_appear_on_a_class_or_member_function_declaration: { code: 1231, category: DiagnosticCategory.Error, key: "'{0}' modifier can only appear on a class or member function declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1232, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1233, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, 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." }, @@ -379,7 +382,8 @@ module ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2506, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" }, + Cannot_create_an_instance_of_the_abstract_class_0_: { code: 2506, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_match_with_respect_to_modifier_0_: { code: 2507, category: DiagnosticCategory.Error, key: "Overload sigantures must all match with respect to modifier '{0}'."}, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ae146368fc3e9..6a7c5ef658155 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -731,8 +731,18 @@ "category": "Error", "code": 1230 }, - - + "'{0}' modifier can only appear on a class or member function declaration.": { + "category": "Error", + "code": 1231 + }, + "'{0}' modifier cannot be used with '{1}' modifier.": { + "category": "Error", + "code": 1232 + }, + "Abstract methods can only appear within an abstract class.": { + "category": "Error", + "code": 1233 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 394bb0f401d8c..f0a5850220b86 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1097,6 +1097,11 @@ module ts { } return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.OpenBraceToken && canFollowModifier(); } + if (token === SyntaxKind.AbstractKeyword) { + nextToken(); + // 'abstract' can precede class declarations and member function declarations. + return token === SyntaxKind.ClassKeyword || token === SyntaxKind.Identifier; + } if (token === SyntaxKind.DefaultKeyword) { return nextTokenIsClassOrFunction(); } @@ -3873,6 +3878,7 @@ module ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: + case SyntaxKind.AbstractKeyword: nextToken(); continue; default: @@ -4031,6 +4037,7 @@ module ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.PublicKeyword: + case SyntaxKind.AbstractKeyword: case SyntaxKind.StaticKeyword: if (getDeclarationFlags() & flags) { return parseDeclaration(); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9cb0cb02a3fc8..26237803b87ee 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1332,15 +1332,15 @@ module ts { export function isModifier(token: SyntaxKind): boolean { switch (token) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.ConstKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.ExportKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: - case SyntaxKind.AbstractKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.DefaultKeyword: return true; } return false; diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 9cf6d8ff4bcea..cdd6e4358e864 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -318,7 +318,7 @@ module ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -344,7 +344,7 @@ module ts.formatting { // decorators this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); + this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete)); this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); diff --git a/src/services/services.ts b/src/services/services.ts index 5f030bf320ea4..c8c0f3320017f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1491,6 +1491,7 @@ module ts { export const exportedModifier = "export"; export const ambientModifier = "declare"; export const staticModifier = "static"; + export const abstractModifier = "abstract"; } export class ClassificationTypeNames { @@ -2786,6 +2787,7 @@ module ts { case SyntaxKind.ExportKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DefaultKeyword: + case SyntaxKind.AbstractKeyword: } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index da0a0aa96c199..548822ddee424 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -429,6 +429,7 @@ module ts { if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier); if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier); if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier); + if (flags & NodeFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier); if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier); if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier); From 19543221555d0d3742603e2aceb81b06cd3ab3f3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 15 Jun 2015 17:10:53 -0700 Subject: [PATCH 074/250] Fixed some indentation issues --- src/compiler/checker.ts | 57 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04e7c63635439..272af29d6e2f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1978,7 +1978,7 @@ namespace ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -2172,8 +2172,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -3610,8 +3610,8 @@ namespace ts { let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; let type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -5921,20 +5921,20 @@ namespace 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; } } } @@ -7442,11 +7442,12 @@ namespace ts { return resolveErrorCall(node); } + // If the expression is of abstract type, then it cannot be instantiated. var valueDecl = (expressionType.symbol ? expressionType.symbol.valueDeclaration : undefined); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0_, declarationNameToString(valueDecl.name)); } - + // TS 1.0 spec: 4.11 // If ConstructExpr is of type Any, Args can be any argument // list and the result of the operation is of type Any. @@ -7548,11 +7549,7 @@ namespace ts { } if (node.kind === SyntaxKind.NewExpression) { let declaration = signature.declaration; - // let newedClass = declaration.parent; - // if(node.expression. & NodeFlags.Abstract) { - // error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declaration.name); - // } - + if (declaration && declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && @@ -8061,8 +8058,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -8257,7 +8254,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // fall-through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -8285,8 +8282,8 @@ namespace ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { let 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; @@ -9476,7 +9473,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // fall-through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -11978,8 +11975,8 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + // fall-through - // Intentional fall-through case SyntaxKind.NumericLiteral: // index access if (node.parent.kind == SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { @@ -12145,7 +12142,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } From 864a28a586b58ca6e3650fe089c7b6634a3e1a4e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 16 Jun 2015 10:02:21 -0700 Subject: [PATCH 075/250] forbid abstract methods from having an implementation --- src/compiler/checker.ts | 9 +++++++-- src/compiler/diagnosticInformationMap.generated.ts | 5 +++-- src/compiler/diagnosticMessages.json | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 272af29d6e2f3..4ffa0a81d9598 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7445,7 +7445,7 @@ namespace ts { // If the expression is of abstract type, then it cannot be instantiated. var valueDecl = (expressionType.symbol ? expressionType.symbol.valueDeclaration : undefined); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { - error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0_, declarationNameToString(valueDecl.name)); + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); } // TS 1.0 spec: 4.11 @@ -9111,7 +9111,7 @@ namespace ts { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & NodeFlags.Abstract) { - error(o.name, Diagnostics.Overload_signatures_must_all_match_with_respect_to_modifier_0_, "abstract"); + error(o.name, Diagnostics.All_overload_signatures_must_match_with_respect_to_modifier_0, "abstract"); } }); } @@ -9229,6 +9229,11 @@ namespace ts { if (!bodyDeclaration) { bodyDeclaration = node; } + + // abstract functions cannot have an implementation + if(currentNodeFlags & NodeFlags.Abstract) { + error(node, Diagnostics.Abstract_member_functions_cannot_have_an_implementation) + } } else { hasOverloads = true; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 6616556382f73..a65eba493adfe 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -192,6 +192,7 @@ namespace ts { _0_modifier_can_only_appear_on_a_class_or_member_function_declaration: { code: 1236, category: DiagnosticCategory.Error, key: "'{0}' modifier can only appear on a class or member function declaration." }, _0_modifier_cannot_be_used_with_1_modifier: { code: 1237, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1238, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, + Abstract_member_functions_cannot_have_an_implementation: { code: 1240, category: DiagnosticCategory.Error, key: "Abstract member functions cannot have an implementation." }, 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." }, @@ -385,8 +386,8 @@ namespace ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - Cannot_create_an_instance_of_the_abstract_class_0_: { code: 2506, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_match_with_respect_to_modifier_0_: { code: 2507, category: DiagnosticCategory.Error, key: "Overload sigantures must all match with respect to modifier '{0}'."}, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2506, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" }, + All_overload_signatures_must_match_with_respect_to_modifier_0: { code: 2507, category: DiagnosticCategory.Error, key: "All overload signatures must match with respect to modifier '{0}'." }, 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 1b55a6dc214e7..c5291d2900d27 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -755,6 +755,10 @@ "category": "Error", "code": 1238 }, + "Abstract member functions cannot have an implementation.": { + "category": "Error", + "code": 1240 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -1531,6 +1535,10 @@ "category": "Error", "code": 2506 }, + "All overload signatures must match with respect to modifier '{0}'.": { + "category": "Error", + "code": 2507 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From f1c99f3397edcf01300f77e5f2d7b66a89cfb090 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Jun 2015 13:25:46 -0700 Subject: [PATCH 076/250] Remove generatorParameter and asyncParameter contexts. --- src/compiler/checker.ts | 32 ++++- .../diagnosticInformationMap.generated.ts | 2 + src/compiler/diagnosticMessages.json | 9 +- src/compiler/parser.ts | 134 ++++++------------ src/compiler/types.ts | 14 +- .../FunctionDeclaration10_es6.errors.txt | 20 ++- .../reference/FunctionDeclaration10_es6.js | 4 +- .../FunctionDeclaration6_es6.errors.txt | 4 +- .../FunctionDeclaration7_es6.errors.txt | 4 +- .../asyncArrowFunction6_es6.errors.txt | 9 +- .../reference/asyncArrowFunction6_es6.js | 2 +- .../asyncArrowFunction7_es6.errors.txt | 9 +- .../reference/asyncArrowFunction7_es6.js | 2 +- .../asyncArrowFunction9_es6.errors.txt | 23 +++ .../reference/asyncArrowFunction9_es6.js | 6 +- .../reference/asyncArrowFunction9_es6.symbols | 8 -- .../reference/asyncArrowFunction9_es6.types | 10 -- .../asyncFunctionDeclaration10_es6.errors.txt | 26 ++++ .../asyncFunctionDeclaration10_es6.js | 7 +- .../asyncFunctionDeclaration10_es6.symbols | 8 -- .../asyncFunctionDeclaration10_es6.types | 9 -- .../asyncFunctionDeclaration6_es6.errors.txt | 9 +- .../asyncFunctionDeclaration6_es6.js | 2 +- .../asyncFunctionDeclaration7_es6.errors.txt | 9 +- .../asyncFunctionDeclaration7_es6.js | 2 +- 25 files changed, 186 insertions(+), 178 deletions(-) create mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.errors.txt delete mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.symbols delete mode 100644 tests/baselines/reference/asyncArrowFunction9_es6.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es6.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1ee1e1cd09485..c39cb04302510 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6083,6 +6083,18 @@ namespace ts { return undefined; } + function isInParameterInitializerBeforeContainingFunction(node: Node) { + while (node.parent && !isFunctionLike(node.parent)) { + if (node.parent.kind === SyntaxKind.Parameter && (node.parent).initializer === node) { + return true; + } + + node = node.parent; + } + + return false; + } + function getContextualReturnType(functionDecl: FunctionLikeDeclaration): Type { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -8031,8 +8043,14 @@ namespace ts { function checkAwaitExpression(node: AwaitExpression): Type { // Grammar checking - if (!(node.parserContextFlags & ParserContextFlags.Await)) { - grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); + if (produceDiagnostics) { + if (!(node.parserContextFlags & ParserContextFlags.Await)) { + grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } } let operandType = checkExpression(node.expression); @@ -8465,8 +8483,14 @@ namespace ts { function checkYieldExpression(node: YieldExpression): Type { // Grammar checking - if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 6118e62a1a757..08efa93781c67 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -398,6 +398,8 @@ namespace ts { Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, 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 7e256bbe8ce3f..05f2690ae43be 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1570,7 +1570,6 @@ "category": "Error", "code": 2505 }, - "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { "category": "Error", "code": 2520 @@ -1583,6 +1582,14 @@ "category": "Error", "code": 2522 }, + "'yield' expressions cannot be used in a parameter initializer.": { + "category": "Error", + "code": 2523 + }, + "'await' expressions cannot be used in a parameter initializer.": { + "category": "Error", + "code": 2524 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6059aec65ae3b..2bff3ee72debc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -661,10 +661,6 @@ namespace ts { setContextFlag(val, ParserContextFlags.Yield); } - function setGeneratorParameterContext(val: boolean) { - setContextFlag(val, ParserContextFlags.GeneratorParameter); - } - function setDecoratorContext(val: boolean) { setContextFlag(val, ParserContextFlags.Decorator); } @@ -672,11 +668,7 @@ namespace ts { function setAwaitContext(val: boolean) { setContextFlag(val, ParserContextFlags.Await); } - - function setAsyncParameterContext(val: boolean) { - setContextFlag(val, ParserContextFlags.AsyncParameter); - } - + function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { // contextFlagsToClear will contain only the context flags that are // currently set that we need to temporarily clear @@ -767,10 +759,6 @@ namespace ts { return inContext(ParserContextFlags.StrictMode); } - function inGeneratorParameterContext() { - return inContext(ParserContextFlags.GeneratorParameter); - } - function inDisallowInContext() { return inContext(ParserContextFlags.DisallowIn); } @@ -782,15 +770,7 @@ namespace ts { function inAwaitContext() { return inContext(ParserContextFlags.Await); } - - function inAsyncParameterContext() { - return inContext(ParserContextFlags.AsyncParameter); - } - function inGeneratorParameterOrAsyncParameterContext() { - return inContext(ParserContextFlags.GeneratorParameter | ParserContextFlags.AsyncParameter); - } - function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { let start = scanner.getTokenPos(); let length = scanner.getTextPos() - start; @@ -1083,24 +1063,16 @@ namespace ts { } function parseComputedPropertyName(): ComputedPropertyName { - // PropertyName[Yield,GeneratorParameter] : - // LiteralPropertyName - // [+GeneratorParameter] ComputedPropertyName - // [+AsyncParameter] ComputedPropertyName - // [~GeneratorParameter,~AsyncParameter] ComputedPropertyName[?Yield,?Await] - // - // ComputedPropertyName[Yield] : - // [ AssignmentExpression[In, ?Yield] ] - // + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] let node = createNode(SyntaxKind.ComputedPropertyName); parseExpected(SyntaxKind.OpenBracketToken); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. - node.expression = inGeneratorParameterOrAsyncParameterContext() - ? doOutsideOfYieldAndAwaitContext(allowInAndParseExpression) - : allowInAnd(parseExpression); + node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); @@ -1991,8 +1963,8 @@ namespace ts { node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); setModifiers(node, parseModifiers()); - // FormalParameter[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 14.1 - // BindingElement[?Yield,?GeneratorParameter,?Await,?AsyncParameter] + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -2024,18 +1996,7 @@ namespace ts { } function parseBindingElementInitializer(inParameter: boolean) { - // BindingElement[Yield,GeneratorParameter,Await,AsyncParameter] : - // [+GeneratorParameter] BindingPattern[?Yield,?Await,?AsyncParameter,GeneratorParameter] Initializer[In]opt - // [+AsyncParameter] BindingPattern[?Yield,?GeneratorParameter,?Await,AsyncParameter] Initializer[In]opt - // [~GeneratorParameter,~AsyncParameter] BindingPattern[?Yield,?Await] Initializer[In,?Yield,?Await]opt - // SingleNameBinding[Yield,GeneratorParameter,Await,AsyncParameter] : - // [+GeneratorParameter] BindingIdentifier[Yield, ?Await] Initializer[In]opt - // [+AsyncParameter] BindingIdentifier[Await, ?Yield] Initializer[In]opt - // [~GeneratorParameter,~AsyncParameter] BindingIdentifier[?Yield,?Await] Initializer[In,?Yield,?Await]opt - let parseInitializer = inParameter ? parseParameterInitializer : parseNonParameterInitializer; - return inGeneratorParameterOrAsyncParameterContext() - ? doOutsideOfYieldAndAwaitContext(parseInitializer) - : parseInitializer(); + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { @@ -2043,14 +2004,15 @@ namespace ts { } function fillSignature( - returnToken: SyntaxKind, - yieldAndGeneratorParameterContext: boolean, - awaitAndAsyncParameterContext: boolean, - requireCompleteParameterList: boolean, - signature: SignatureDeclaration): void { + returnToken: SyntaxKind, + yieldContext: boolean, + awaitContext: boolean, + requireCompleteParameterList: boolean, + signature: SignatureDeclaration): void { + let returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, awaitAndAsyncParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); @@ -2061,44 +2023,31 @@ namespace ts { } } - // Note: after careful analysis of the grammar, it does not appear to be possible to - // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling - // this FormalParameters production either always sets both to true, or always sets - // both to false. As such we only have a single parameter to represent both. - function parseParameterList(yieldAndGeneratorParameterContext: boolean, awaitAndAsyncParameterContext: boolean, requireCompleteParameterList: boolean) { - // FormalParameters[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) - // ... + function parseParameterList(yieldContext: boolean, awaitContext: boolean, requireCompleteParameterList: boolean) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] // - // FormalParameter[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) - // BindingElement[?Yield,?GeneratorParameter,?Await,?AsyncParameter] + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] // - // BindingElement[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 13.2.3 - // SingleNameBinding[?Yield,?GeneratorParameter,?Await,?AsyncParameter] - // [+GeneratorParameter]BindingPattern[?Yield,?Await,?AsyncParameter,GeneratorParameter] Initializer[In]opt - // [+AsyncParameter]BindingPattern[?Yield,?Await,?GeneratorParameter,AsyncParameter] Initializer[In]opt - // [~GeneratorParameter,~AsyncParameter]BindingPattern[?Yield,?Await]Initializer[In,?Yield,?Await]opt + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt // - // SingleNameBinding[Yield,GeneratorParameter,Await,AsyncParameter] : (Modified) See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [+AsyncParameter]BindingIdentifier[Await]Initializer[In]opt - // [~GeneratorParameter,~AsyncParameter]BindingIdentifier[?Yield,?Await]Initializer[In,?Yield,?Await]opt + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt if (parseExpected(SyntaxKind.OpenParenToken)) { let savedYieldContext = inYieldContext(); - let savedGeneratorParameterContext = inGeneratorParameterContext(); let savedAwaitContext = inAwaitContext(); - let savedAsyncParameterContext = inAsyncParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - setAwaitContext(awaitAndAsyncParameterContext); - setAsyncParameterContext(awaitAndAsyncParameterContext); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); let result = parseDelimitedList(ParsingContext.Parameters, parseParameter); setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); setAwaitContext(savedAwaitContext); - setAsyncParameterContext(savedAsyncParameterContext); if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return @@ -2131,7 +2080,7 @@ namespace ts { if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -2220,8 +2169,8 @@ namespace ts { method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [GeneratorParameter] - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, method); + // [Yield] nor [Await] + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } @@ -2360,7 +2309,7 @@ namespace ts { if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } @@ -2912,7 +2861,7 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -3566,11 +3515,12 @@ namespace ts { return finishNode(node); } - // GeneratorExpression : function parseFunctionExpression(): FunctionExpression { - // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // // FunctionExpression: - // function BindingIdentifieropt(FormalParameters) { FunctionBody } + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } let saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); @@ -3589,7 +3539,7 @@ namespace ts { isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { @@ -4303,7 +4253,7 @@ namespace ts { node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); let isGenerator = !!node.asteriskToken; let isAsync = isAsyncFunctionLike(node); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); return finishNode(node); } @@ -4313,7 +4263,7 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected); return finishNode(node); } @@ -4327,7 +4277,7 @@ namespace ts { method.questionToken = questionToken; let isGenerator = !!asteriskToken; let isAsync = isAsyncFunctionLike(method); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ isGenerator, /*awaitAndAsyncParameterContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } @@ -4381,7 +4331,7 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*awaitAndAsyncParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9022295ccfbb2..e1aa071a7d927 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -376,18 +376,12 @@ namespace ts { // If this node was parsed in the 'yield' context created when parsing a generator. Yield = 1 << 2, - // If this node was parsed in the parameters of a generator. - GeneratorParameter = 1 << 3, - // If this node was parsed as part of a decorator Decorator = 1 << 4, // If this node was parsed in the 'await' context created when parsing an async function. Await = 1 << 5, - // If this node was parsed in the parameters of an async function. - AsyncParameter = 1 << 6, - // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. @@ -398,14 +392,10 @@ namespace ts { JavaScriptFile = 1 << 8, // Context flags set directly by the parser. - ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | Await | AsyncParameter, - - // Context flags passed as part of the modified ES6 grammar. - YieldAndGeneratorParameterFlags = Yield | GeneratorParameter, - AwaitAndAsyncParameterFlags = Await | AsyncParameter, + ParserGeneratedFlags = StrictMode | DisallowIn | Yield | Decorator | ThisNodeHasError | Await, // Exclude these flags when parsing a Type - TypeExcludesFlags = YieldAndGeneratorParameterFlags | AwaitAndAsyncParameterFlags, + TypeExcludesFlags = Yield | Await, // Context flags computed by aggregating child flags upwards. diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 35edf48564afc..6efd10dce099f 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,20 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ==== function * foo(a = yield => yield) { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~ +!!! error TS1005: ';' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index 5169453396463..ccff1ac10362b 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -3,6 +3,6 @@ function * foo(a = yield => yield) { } //// [FunctionDeclaration10_es6.js] -function foo(a) { - if (a === void 0) { a = function (yield) { return yield; }; } +yield; +{ } diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 9f696e710847f..eae7628f04657 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2523: 'yield' expressions cannot be used in a parameter initializer. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,1 ~ !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 91fab36ed3118..4a9e4bca6d3eb 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2523: 'yield' expressions cannot be used in a parameter initializer. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== @@ -12,6 +12,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,2 ~ !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt index c5a34f513b029..111e4ff46d095 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,22): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,22): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,27): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (1 errors) ==== +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (2 errors) ==== var foo = async (a = await): Promise => { ~~~~~ -!!! error TS2304: Cannot find name 'await'. +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js index 48035057fe05d..5353903d10e94 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.js +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -4,6 +4,6 @@ var foo = async (a = await): Promise => { } //// [asyncArrowFunction6_es6.js] -var foo = (a = await) => __awaiter(function* () { +var foo = (a = yield ) => __awaiter(function* () { }, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt index 823d779c601c5..6376626d0e717 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt @@ -1,12 +1,15 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,24): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,29): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (1 errors) ==== +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (2 errors) ==== var bar = async (): Promise => { // 'await' here is an identifier, and not an await expression. var foo = async (a = await): Promise => { ~~~~~ -!!! error TS2304: Cannot find name 'await'. +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js index 6f8cf6141a893..b3c5f536550d6 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.js +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -9,7 +9,7 @@ var bar = async (): Promise => { //// [asyncArrowFunction7_es6.js] var bar = () => __awaiter(function* () { // 'await' here is an identifier, and not an await expression. - var foo = (a = await) => __awaiter(function* () { + var foo = (a = yield ) => __awaiter(function* () { }, this, void 0, Promise); }, diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt new file mode 100644 index 0000000000000..623095e8a5e33 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts (6 errors) ==== + var foo = async (a = await => await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js index 42511dd87f547..fb2f9d28a17c4 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -3,6 +3,6 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es6.js] -var foo = (a = await => await) => __awaiter(function* () { -}, -this, void 0, Promise); +var foo = async(a = await => await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.symbols b/tests/baselines/reference/asyncArrowFunction9_es6.symbols deleted file mode 100644 index 9714b119e72dd..0000000000000 --- a/tests/baselines/reference/asyncArrowFunction9_es6.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts === -var foo = async (a = await => await): Promise => { ->foo : Symbol(foo, Decl(asyncArrowFunction9_es6.ts, 0, 3)) ->a : Symbol(a, Decl(asyncArrowFunction9_es6.ts, 0, 17)) ->await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) ->await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) -} diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.types b/tests/baselines/reference/asyncArrowFunction9_es6.types deleted file mode 100644 index 9f6244c4a0eed..0000000000000 --- a/tests/baselines/reference/asyncArrowFunction9_es6.types +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts === -var foo = async (a = await => await): Promise => { ->foo : (a?: (await: any) => any) => Promise ->async (a = await => await): Promise => {} : (a?: (await: any) => any) => Promise ->a : (await: any) => any ->await => await : (await: any) => any ->await : any ->await : any ->Promise : Promise -} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt new file mode 100644 index 0000000000000..15ceb3e60c763 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== + async function foo(a = await => await): Promise { + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 7048ca2ffa423..141c0cbab55cd 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -3,8 +3,5 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es6.js] -function foo(a = await => await) { - return __awaiter(function* () { - }, - this, void 0, Promise); -} +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols deleted file mode 100644 index 3bf5baec3b190..0000000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === -async function foo(a = await => await): Promise { ->foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es6.ts, 0, 0)) ->a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) ->await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) ->await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) -} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.types b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types deleted file mode 100644 index 0018b994e0026..0000000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === -async function foo(a = await => await): Promise { ->foo : (a?: (await: any) => any) => Promise ->a : (await: any) => any ->await => await : (await: any) => any ->await : any ->await : any ->Promise : Promise -} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt index e89029e7c5f10..ee8abb7bdadf6 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt @@ -1,8 +1,11 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,24): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,29): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (1 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (2 errors) ==== async function foo(a = await): Promise { ~~~~~ -!!! error TS2304: Cannot find name 'await'. +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js index a74d55c35ca2c..3c1b16cea96a0 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -3,7 +3,7 @@ async function foo(a = await): Promise { } //// [asyncFunctionDeclaration6_es6.js] -function foo(a = await) { +function foo(a = yield ) { return __awaiter(function* () { }, this, void 0, Promise); diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt index b29fed652d866..91ba4508ba139 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt @@ -1,11 +1,14 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,26): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,26): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,31): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (1 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (2 errors) ==== async function bar(): Promise { // 'await' here is an identifier, and not a yield expression. async function foo(a = await): Promise { ~~~~~ -!!! error TS2304: Cannot find name 'await'. +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js index fcc2394a1d13d..0b2f643e469e5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -9,7 +9,7 @@ async function bar(): Promise { function bar() { return __awaiter(function* () { // 'await' here is an identifier, and not a yield expression. - function foo(a = await) { + function foo(a = yield ) { return __awaiter(function* () { }, this, void 0, Promise); From 2e16680f01ecb9fb5d9fe5bdd73ac57b2a1d0b67 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Jun 2015 14:00:31 -0700 Subject: [PATCH 077/250] Re-number enum. --- src/compiler/types.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d6baa492bb634..db2eafe4e5377 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -367,25 +367,25 @@ namespace ts { None = 0, // If this node was parsed in a context where 'in-expressions' are not allowed. - DisallowIn = 1 << 1, + DisallowIn = 1 << 0, // If this node was parsed in the 'yield' context created when parsing a generator. - Yield = 1 << 2, + Yield = 1 << 1, // If this node was parsed as part of a decorator - Decorator = 1 << 4, + Decorator = 1 << 2, // If this node was parsed in the 'await' context created when parsing an async function. - Await = 1 << 5, + Await = 1 << 3, // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. - ThisNodeHasError = 1 << 7, + ThisNodeHasError = 1 << 4, // This node was parsed in a JavaScript file and can be processed differently. For example // its type can be specified usign a JSDoc comment. - JavaScriptFile = 1 << 8, + JavaScriptFile = 1 << 5, // Context flags set directly by the parser. ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await, @@ -397,13 +397,10 @@ namespace ts { // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ThisNodeOrAnySubNodesHasError = 1 << 9, - - // Used to know if we've computed whether any children of this node are or contain an 'await' or 'yield' expression. - ThisNodeOrAnySubNodesHasAwaitOrYield = 1 << 10, + ThisNodeOrAnySubNodesHasError = 1 << 6, // Used to know if we've computed data from children and cached it in this node. - HasAggregatedChildData = 1 << 11 + HasAggregatedChildData = 1 << 7 } /* @internal */ From a07f86240d7ca9af9e77bdd45caf3b0ad4396adf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 17 Jun 2015 15:01:34 -0700 Subject: [PATCH 078/250] forbid calling abstract member foo() via super.foo() --- src/compiler/checker.ts | 14 ++++++++++++-- src/compiler/diagnosticInformationMap.generated.ts | 3 ++- src/compiler/diagnosticMessages.json | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 242793c8b6bd2..fac2ee3b4c557 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6714,8 +6714,18 @@ namespace ts { // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (left.kind === SyntaxKind.SuperKeyword) { + if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { + error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } + + // Abstract methods cannot be accessed through super property accesses. Eg: + // class A { abstract foo(); } + // class B extends A { bar() { super.foo();} } + // is illegal. + if (getDeclarationFlagsFromSymbol(prop) & NodeFlags.Abstract) { + error(right, Diagnostics.Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression, declarationNameToString(right), typeToString(type)); + } } else { checkClassPropertyAccess(node, left, type, prop); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index ba617d9cf3ba5..d1cd9b4ba39d8 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -393,8 +393,9 @@ namespace ts { No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_does_not_return_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor does not return a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, All_overload_signatures_must_match_with_respect_to_modifier_0: { code: 2512, category: DiagnosticCategory.Error, key: "All overload signatures must match with respect to modifier '{0}'." }, + Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract member function '{0}' on type '{1}' cannot be called via super expression." }, 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 91d1eafb998bc..ddfc885dcf6a1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1559,7 +1559,7 @@ "category": "Error", "code": 2510 }, - "Cannot create an instance of the abstract class '{0}'": { + "Cannot create an instance of the abstract class '{0}'.": { "category": "Error", "code": 2511 }, @@ -1567,6 +1567,10 @@ "category": "Error", "code": 2512 }, + "Abstract member function '{0}' on type '{1}' cannot be called via super expression.": { + "category": "Error", + "code": 2513 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From b25d855341b9c9f98071895a99a88aa1403c6558 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 17 Jun 2015 16:05:55 -0700 Subject: [PATCH 079/250] Removed unused getContainingParameter function --- src/compiler/utilities.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4aed1aaee58e1..5f062539e1c21 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -640,19 +640,6 @@ namespace ts { } } } - - export function getContainingParameter(node: Node): ParameterDeclaration { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return undefined; - } - - if (node.kind === SyntaxKind.Parameter) { - return node; - } - } - } export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node { while (true) { From 82eae194f1ea6aa4a7c85fd96d0cf98e898418a8 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 17 Jun 2015 16:10:17 -0700 Subject: [PATCH 080/250] Inlined checks for NodeFlags.Async in parser --- src/compiler/parser.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 72fb6a8b3e513..98c9c56ae8ca5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2695,13 +2695,15 @@ namespace ts { // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } + + let isAsync = !!(arrowFunction.flags & NodeFlags.Async); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/false, Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) - ? parseArrowFunctionExpressionBody(/*isAsync*/ isAsyncFunctionLike(arrowFunction)) + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -2813,7 +2815,7 @@ namespace ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); setModifiers(node, parseModifiersForArrowFunction()); - let isAsync = isAsyncFunctionLike(node); + let isAsync = !!(node.flags & NodeFlags.Async); // Arrow functions are never generators. // @@ -3493,7 +3495,7 @@ namespace ts { node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); let isGenerator = !!node.asteriskToken; - let isAsync = isAsyncFunctionLike(node); + let isAsync = !!(node.flags & NodeFlags.Async); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -4217,7 +4219,7 @@ namespace ts { node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); let isGenerator = !!node.asteriskToken; - let isAsync = isAsyncFunctionLike(node); + let isAsync = !!(node.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); return finishNode(node); @@ -4241,7 +4243,7 @@ namespace ts { method.name = name; method.questionToken = questionToken; let isGenerator = !!asteriskToken; - let isAsync = isAsyncFunctionLike(method); + let isAsync = !!(method.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); From c74bb842ba266370384d31bc47caf6dee3210161 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 17 Jun 2015 16:11:14 -0700 Subject: [PATCH 081/250] Moved getContainingFunction call in checkIdentifier --- 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 cdacf47375f87..500d0dec3440b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5755,8 +5755,8 @@ namespace ts { // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - let container = getContainingFunction(node); if (symbol === argumentsSymbol) { + let container = getContainingFunction(node); if (container.kind === SyntaxKind.ArrowFunction) { if (languageVersion < ScriptTarget.ES6) { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); From b00a9579a8645cc96ff5717296a8bcda6d33f2d7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 17 Jun 2015 16:16:55 -0700 Subject: [PATCH 082/250] Removed unneeded capture for lexical this --- src/compiler/checker.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 500d0dec3440b..d0af755125c51 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5855,10 +5855,6 @@ namespace ts { // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES6); } - else if (node.parserContextFlags & ParserContextFlags.Await) { - // if 'this' is part of an async function, we will need to capture 'this' - needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES6); - } switch (container.kind) { case SyntaxKind.ModuleDeclaration: From 02f6622e43b03d269806b641524a60fed6593059 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 17 Jun 2015 16:28:32 -0700 Subject: [PATCH 083/250] Changed createPromiseType to return emptyObjectType --- src/compiler/checker.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d0af755125c51..c6d0b8aacbf24 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7632,12 +7632,10 @@ namespace ts { if (globalPromiseType !== emptyObjectType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); - if (promisedType !== unknownType) { - return createTypeReference(globalPromiseType, [promisedType]); - } + return createTypeReference(globalPromiseType, [promisedType]); } - return undefined; + return emptyObjectType; } function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { @@ -7678,7 +7676,7 @@ namespace ts { if (isAsync) { // For an async function, the return type will not be void, but rather a Promise for void. let promiseType = createPromiseType(voidType); - if (!promiseType) { + if (promiseType === emptyObjectType) { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; } @@ -7688,7 +7686,7 @@ namespace ts { else { return voidType; } - } + } } // When yield/return statements are contextually typed we allow the return type to be a union type. // Otherwise we require the yield/return expressions to have a best common supertype. @@ -7718,7 +7716,7 @@ namespace ts { // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body is awaited type of the body, wrapped in a native Promise type. let promiseType = createPromiseType(widenedType); - if (!promiseType) { + if (promiseType === emptyObjectType) { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; } @@ -9556,7 +9554,7 @@ namespace ts { let promisedType = getPromisedType(type); if (promisedType === undefined) { // The type was not a PromiseLike, so it could not be unwrapped any further. - // As long as the type does not have a known callable "then" property, then it is + // As long as the type does not have a callable "then" property, then it is // safe to return the type; otherwise, an error will have been reported in // the call to checkNonThenableType and we will return unknownType. // @@ -9570,11 +9568,10 @@ namespace ts { // of a runtime problem. If the user wants to return this value from an async // function, they would need to wrap it in some other value. If they want it to // be treated as a promise, they can cast to . - if (checkNonThenableType(type, location, message)) { - break; + if (!checkNonThenableType(type, location, message)) { + type = unknownType; } - type = unknownType; break; } From 7443ecc6a57ab558a5d5affbeecec296f1640777 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 17 Jun 2015 16:30:25 -0700 Subject: [PATCH 084/250] Cleaned up diagnostics --- src/compiler/checker.ts | 9 ++------- src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c6d0b8aacbf24..6ede08a32a40f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9604,11 +9604,7 @@ namespace ts { // } // if (location) { - if (!message) { - message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - - error(location, message); + error(location, Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); } type = unknownType; @@ -9640,8 +9636,7 @@ namespace ts { let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify - // compatibility with __awaiter, so we report an error. - error(node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + // compatibility with __awaiter. return unknownType; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index e1b563bb3ea70..17472e4ce85d7 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -54,6 +54,7 @@ namespace ts { Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4ccf40e8463a5..6ddf170947502 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -203,6 +203,10 @@ "category": "Error", "code": 1061 }, + "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method.": { + "category": "Error", + "code": 1062 + }, "An export assignment cannot be used in a namespace.": { "category": "Error", "code": 1063 From 958a423142dad45c4e9f51e461d383f51cbe8ed5 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Jun 2015 08:56:48 -0700 Subject: [PATCH 085/250] Make classification cancellable. --- src/services/services.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index bab5b7707ef59..188e711ed9fcf 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5986,6 +5986,26 @@ namespace ts { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } + function checkForClassificationCancellation(kind: SyntaxKind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // That means we're calling back into the host around every 1.2k of the file we process. + // Lib.d.ts has similar numbers. + switch (kind) { + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.FunctionDeclaration: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { synchronizeHostData(); @@ -6053,7 +6073,10 @@ namespace ts { function processNode(node: Node) { // Only walk into nodes that intersect the requested span. if (node && textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - if (node.kind === SyntaxKind.Identifier && !nodeIsMissing(node)) { + let kind = node.kind; + checkForClassificationCancellation(kind); + + if (kind === SyntaxKind.Identifier && !nodeIsMissing(node)) { let identifier = node; // Only bother calling into the typechecker if this is an identifier that @@ -6405,6 +6428,8 @@ namespace ts { // Ignore nodes that don't intersect the original span to classify. if (textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + checkForClassificationCancellation(element.kind); + let children = element.getChildren(sourceFile); for (let child of children) { if (isToken(child)) { From 1a96a146ed7bbb1af2ad568d4eacb1809525e6db Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Jun 2015 10:52:19 -0700 Subject: [PATCH 086/250] Make type-checking cancellable. --- src/compiler/checker.ts | 37 +++++++++++++--- src/compiler/core.ts | 21 +++++++++ src/compiler/program.ts | 93 +++++++++++++++++++++++++++------------- src/compiler/types.ts | 16 +++---- src/harness/runner.ts | 1 - src/services/services.ts | 30 +++---------- 6 files changed, 129 insertions(+), 69 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efc3e32166e57..c550c703336d5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -159,10 +159,10 @@ namespace ts { } }; - function getEmitResolver(sourceFile?: SourceFile) { + function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationTokenObject) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile); + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } @@ -11405,8 +11405,24 @@ namespace ts { } function checkSourceElement(node: Node): void { - if (!node) return; - switch (node.kind) { + if (!node) { + return; + } + + let kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.FunctionDeclaration: + cancellationToken.throwIfCancellationRequested(); + } + } + + switch (kind) { case SyntaxKind.TypeParameter: return checkTypeParameter(node); case SyntaxKind.Parameter: @@ -11661,7 +11677,18 @@ namespace ts { } } - function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] { + var cancellationToken: CancellationTokenObject; + function getDiagnostics(sourceFile: SourceFile, ct: CancellationTokenObject): Diagnostic[] { + try { + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + + function getDiagnosticsWorker(sourceFile: SourceFile): Diagnostic[] { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ced477eeeec54..49371dbccd2cd 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -799,3 +799,24 @@ namespace ts { } } } + +namespace ts { + export class OperationCanceledException { } + + export class CancellationTokenObject { + public static None: CancellationTokenObject = new CancellationTokenObject(null) + + constructor(private cancellationToken: CancellationToken) { + } + + public isCancellationRequested() { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } +} \ No newline at end of file diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 800e2238a5480..df976f17ae9c5 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -104,11 +104,13 @@ namespace ts { }; } - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[] { - let diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[] { + let diagnostics = program.getSyntacticDiagnostics(sourceFile, cancellationToken).concat( + program.getGlobalDiagnostics(cancellationToken)).concat( + program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return sortAndDeduplicateDiagnostics(diagnostics); @@ -230,10 +232,15 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult { + function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationTokenObject): EmitResult { + return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); + } + + function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationTokenObject): EmitResult { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } @@ -262,53 +269,79 @@ namespace ts { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] { + function getDiagnosticsHelper( + sourceFile: SourceFile, + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationTokenObject) => Diagnostic[], + cancellationToken: CancellationTokenObject): Diagnostic[] { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } let allDiagnostics: Diagnostic[] = []; forEach(program.getSourceFiles(), sourceFile => { - addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { - let typeChecker = getDiagnosticsProducingTypeChecker(); + function runWithCancellationToken(func: () => T): T { + try { + return func(); + } + catch (e) { + if (e instanceof OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } - Debug.assert(!!sourceFile.bindDiagnostics); - let bindDiagnostics = sourceFile.bindDiagnostics; - let checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + throw e; + } + } + + function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + return runWithCancellationToken(() => { + let typeChecker = getDiagnosticsProducingTypeChecker(); + + Debug.assert(!!sourceFile.bindDiagnostics); + let bindDiagnostics = sourceFile.bindDiagnostics; + let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); } - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { - if (!isDeclarationFile(sourceFile)) { - let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - // Don't actually write any files since we're just getting diagnostics. - var writeFile: WriteFileCallback = () => { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); - } + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + return runWithCancellationToken(() => { + if (!isDeclarationFile(sourceFile)) { + let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + var writeFile: WriteFileCallback = () => { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + }); } function getCompilerOptionsDiagnostics(): Diagnostic[] { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c39426a2e2217..b230b2c5feb7a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1210,13 +1210,13 @@ namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationTokenObject): EmitResult; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - /* @internal */ getCompilerOptionsDiagnostics(): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; + /* @internal */ getCompilerOptionsDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source fils in the program. @@ -1324,9 +1324,9 @@ namespace ts { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; // Should not be called directly. Should only be accessed through the Program instance. - /* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; - /* @internal */ getEmitResolver(sourceFile?: SourceFile): EmitResolver; + /* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): EmitResolver; /* @internal */ getNodeCount(): number; /* @internal */ getIdentifierCount(): number; diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 42c2d5667c4be..1e9c64704210a 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -49,7 +49,6 @@ if (testConfigFile !== '') { if (!option) { continue; } - ts.sys.write("Option: " + option + "\r\n"); switch (option) { case 'compiler': runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); diff --git a/src/services/services.ts b/src/services/services.ts index bed1f9b6bb93a..86540ccd3e569 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1610,26 +1610,6 @@ namespace ts { }; } - export class OperationCanceledException { } - - export class CancellationTokenObject { - - public static None: CancellationTokenObject = new CancellationTokenObject(null) - - constructor(private cancellationToken: CancellationToken) { - } - - public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - } - - public throwIfCancellationRequested(): void { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - } - } - // Cache host information about scrip Should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. @@ -2600,7 +2580,7 @@ namespace ts { function getSyntacticDiagnostics(fileName: string) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName)); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** @@ -2622,13 +2602,13 @@ namespace ts { // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. - let semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile); + let semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { return semanticDiagnostics; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); + let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return concatenate(semanticDiagnostics, declarationDiagnostics); } @@ -2790,7 +2770,7 @@ namespace ts { function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getGlobalDiagnostics(cancellationToken); } /// Completion @@ -5732,7 +5712,7 @@ namespace ts { }); } - let emitOutput = program.emit(sourceFile, writeFile); + let emitOutput = program.emit(sourceFile, writeFile, cancellationToken); return { outputFiles, From 2891a1d1b7b032fe92a5c8d45f6b27588e60e070 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 18 Jun 2015 11:31:03 -0700 Subject: [PATCH 087/250] Cleaned up async return type check --- src/compiler/checker.ts | 78 ++++------- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 + src/compiler/emitter.ts | 73 +++++----- .../reference/asyncArrowFunction1_es6.js | 5 +- .../reference/asyncArrowFunction6_es6.js | 5 +- .../reference/asyncArrowFunction7_es6.js | 10 +- .../reference/asyncArrowFunction8_es6.js | 5 +- ...asyncArrowFunctionCapturesArguments_es6.js | 3 +- .../asyncArrowFunctionCapturesThis_es6.js | 3 +- tests/baselines/reference/asyncAwait_es6.js | 119 ++++++++++++++++ .../reference/asyncAwait_es6.symbols | 118 ++++++++++++++++ .../baselines/reference/asyncAwait_es6.types | 129 ++++++++++++++++++ .../asyncFunctionDeclaration11_es6.js | 5 +- .../asyncFunctionDeclaration13_es6.js | 5 +- .../asyncFunctionDeclaration14_es6.js | 5 +- .../asyncFunctionDeclaration1_es6.js | 5 +- .../asyncFunctionDeclaration6_es6.js | 5 +- .../asyncFunctionDeclaration7_es6.js | 10 +- .../asyncFunctionDeclaration9_es6.js | 5 +- .../reference/awaitBinaryExpression1_es6.js | 5 +- .../reference/awaitBinaryExpression2_es6.js | 5 +- .../reference/awaitBinaryExpression3_es6.js | 5 +- .../reference/awaitBinaryExpression4_es6.js | 5 +- .../reference/awaitBinaryExpression5_es6.js | 5 +- .../reference/awaitCallExpression1_es6.js | 5 +- .../reference/awaitCallExpression2_es6.js | 5 +- .../reference/awaitCallExpression3_es6.js | 5 +- .../reference/awaitCallExpression4_es6.js | 5 +- .../reference/awaitCallExpression5_es6.js | 5 +- .../reference/awaitCallExpression6_es6.js | 5 +- .../reference/awaitCallExpression7_es6.js | 5 +- .../reference/awaitCallExpression8_es6.js | 5 +- .../conformance/async/es6/asyncAwait_es6.ts | 40 ++++++ 34 files changed, 530 insertions(+), 168 deletions(-) create mode 100644 tests/baselines/reference/asyncAwait_es6.js create mode 100644 tests/baselines/reference/asyncAwait_es6.symbols create mode 100644 tests/baselines/reference/asyncAwait_es6.types create mode 100644 tests/cases/conformance/async/es6/asyncAwait_es6.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6ede08a32a40f..70ca1172ccbfa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -824,7 +824,7 @@ namespace ts { } // Resolves a qualified name and any involved aliases - function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, location?: Node): Symbol { + function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags): Symbol { if (nodeIsMissing(name)) { return undefined; } @@ -833,7 +833,7 @@ namespace ts { if (name.kind === SyntaxKind.Identifier) { let message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, (name).text, meaning, message, name); + symbol = resolveName(name, (name).text, meaning, message, name); if (!symbol) { return undefined; } @@ -842,7 +842,7 @@ namespace ts { let left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; let right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; - let namespace = resolveEntityName(left, SymbolFlags.Namespace, location); + let namespace = resolveEntityName(left, SymbolFlags.Namespace); if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) { return undefined; } @@ -8839,7 +8839,6 @@ namespace ts { } if (produceDiagnostics) { - checkCollisionWithAwaiterVariablesInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -9632,7 +9631,7 @@ namespace ts { * a `resolve` function as one of its arguments and results in an object with a * callable `then` signature. */ - function checkAsyncFunctionReturnType(node: SignatureDeclaration): Type { + function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify @@ -9640,10 +9639,10 @@ namespace ts { return unknownType; } - // The return type of an async function will be the type of the instance. For this - // to be a type compatible with our async function emit, we must also check that - // the type of the declaration (e.g. the static side or "constructor" type of the - // promise) is a compatible `PromiseConstructorLike`. + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. // // An example might be (from lib.es6.d.ts): // @@ -9666,36 +9665,33 @@ namespace ts { // // When we get the type of the `Promise` symbol here, we get the type of the static // side of the `Promise` class, which would be `{ new (...): Promise }`. - let returnType = getTypeFromTypeNode(node.type); - let entityName = getEntityNameFromTypeNode(node.type); - let resolvedName = entityName ? resolveEntityName(entityName, SymbolFlags.Value, node) : undefined; - if (!resolvedName || !returnType.symbol) { - error(node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; + + let promiseType = getTypeFromTypeNode(node.type); + let promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType } - - if (getMergedSymbol(resolvedName) !== getMergedSymbol(returnType.symbol)) { - // If we were unable to resolve the return type as a value, report an error. - let identifier = getFirstIdentifier(entityName); - error(resolvedName.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, - identifier.text, - identifier.text); + + // Validate the promise constructor type. + let promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { return unknownType; } - // When we emit the async function, we need to ensure we emit any imports that might - // otherwise have been elided if the return type were only ever referenced in a type - // position. As such, we check the entity name as an expression. - let declaredType = checkExpression(entityName); - - if (!isTypeAssignableTo(declaredType, globalPromiseConstructorLikeType)) { - // If the declared type of the return type is not assignable to a PromiseConstructorLike, report an error. - error(node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + // Verify there is no local declaration that could collide with the promise constructor. + let promiseName = getEntityNameFromTypeNode(node.type); + let root = getFirstIdentifier(promiseName); + let rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, + root.text, + getFullyQualifiedName(promiseConstructor)); return unknownType; } - + // Get and return the awaited type of the return type. - return getAwaitedType(returnType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return getAwaitedType(promiseType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } /** Check a decorator */ @@ -10093,22 +10089,6 @@ namespace ts { } } } - - function checkCollisionWithAwaiterVariablesInGeneratedCode(node: Node, name: DeclarationName): void { - if (!name || name.kind !== SyntaxKind.Identifier || isTypeNode(name)) { - return; - } - - let identifier = name; - let container = getContainingFunction(name); - if (container && isAsyncFunctionLike(container) && node.kind !== SyntaxKind.Identifier) { - let promiseConstructorName = getEntityNameFromTypeNode(container.type); - let firstIdentifier = promiseConstructorName ? getFirstIdentifier(promiseConstructorName) : undefined; - if (firstIdentifier && firstIdentifier.text === identifier.text) { - error(node, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, identifier.text, getTextOfNode(promiseConstructorName)); - } - } - } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node: VariableLikeDeclaration): void { @@ -10954,7 +10934,6 @@ namespace ts { checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithAwaiterVariablesInGeneratedCode(node, node.name); } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); @@ -11398,7 +11377,6 @@ namespace ts { checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithAwaiterVariablesInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 17472e4ce85d7..6cd9a803aa4a7 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -48,6 +48,7 @@ namespace ts { A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6ddf170947502..4ad7408d70d17 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -179,6 +179,10 @@ "category": "Error", "code": 1054 }, + "Type '{0}' is not a valid async function return type.": { + "category": "Error", + "code": 1055 + }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", "code": 1056 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d0903ccfdf238..d537380dc5d8f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -49,10 +49,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { };`; const awaiterHelper = ` -var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, PromiseConstructor) { - PromiseConstructor || (PromiseConstructor = Promise); +var __awaiter = (this && this.__awaiter) || function (args, generator) { + var PromiseConstructor = args[1] || Promise; return new PromiseConstructor(function (resolve, reject) { - generator = generator.call(thisArg, args); + generator = generator.call(args[0], args[2]); function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } @@ -3359,6 +3359,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) { let promiseConstructor = getEntityNameFromTypeNode(node.type); let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; + let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; let args: string; // An async function is emit as an outer function that calls an inner @@ -3373,7 +3374,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, // let a = async (b) => { await b; } // // // output - // let a = (b) => __awaiter(function* (b) { + // let a = (b) => __awaiter([this], function* (b) { // yield b; // }, this); // @@ -3383,9 +3384,9 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, // let a = async (b) => { await arguments[0]; } // // // output - // let a = (b) => __awaiter(function* (arguments) { + // let a = (b) => __awaiter([this, arguments], function* (arguments) { // yield arguments[0]; - // }, this, arguments); + // }); // // The emit for an async function expression without a lexical `arguments` binding // might be: @@ -3397,7 +3398,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, // // // output // let a = function (b) { - // return __awaiter(function* () { + // return __awaiter([this], function* () { // yield b; // }, this); // } @@ -3412,9 +3413,24 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, // // // output // let a = function (b) { - // return __awaiter(function* (arguments) { + // return __awaiter([this, arguments], function* (arguments) { + // yield arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter([this, arguments, MyPromise], function* (arguments) { // yield arguments[0]; - // }, this, arguments); + // }); // } // @@ -3427,42 +3443,27 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args, write("return"); } + write(" __awaiter([this"); + if (promiseConstructor || hasLexicalArguments) { + write(", "); + if (promiseConstructor) { + emitNodeWithoutSourceMap(promiseConstructor); + } + if (hasLexicalArguments) { + write(", arguments"); + } + } // Emit the call to __awaiter. - let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; if (hasLexicalArguments) { - write(" __awaiter(function* (arguments)"); + write("], function* (arguments)"); } else { - write(" __awaiter(function* ()"); + write("], function* ()"); } // Emit the signature and body for the inner generator function. emitFunctionBody(node); - - // Emit the current `this` binding. - write(","); - writeLine(); - write("this"); - - // Optionally emit the lexical arguments. - if (hasLexicalArguments) { - write(", arguments"); - } - - // If the function has an explicit type annotation for a promise, emit the - // constructor. - if (promiseConstructor) { - // If we did not have lexical arguments, supply undefined (void 0) for - // the `arguments` parameter. - if (!hasLexicalArguments) { - write(", void 0"); - } - - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - write(")"); // If this is not an async arrow, emit the closing brace of the outer function body. diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js index 257b147dbc7b2..2c2f1091b1537 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.js +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -4,6 +4,5 @@ var foo = async (): Promise => { }; //// [asyncArrowFunction1_es6.js] -var foo = () => __awaiter(function* () { -}, -this, void 0, Promise); +var foo = () => __awaiter([this, Promise], function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js index 5353903d10e94..0a39441edf795 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.js +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -4,6 +4,5 @@ var foo = async (a = await): Promise => { } //// [asyncArrowFunction6_es6.js] -var foo = (a = yield ) => __awaiter(function* () { -}, -this, void 0, Promise); +var foo = (a = yield ) => __awaiter([this, Promise], function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js index b3c5f536550d6..bb17963bfd371 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.js +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -7,10 +7,8 @@ var bar = async (): Promise => { } //// [asyncArrowFunction7_es6.js] -var bar = () => __awaiter(function* () { +var bar = () => __awaiter([this, Promise], function* () { // 'await' here is an identifier, and not an await expression. - var foo = (a = yield ) => __awaiter(function* () { - }, - this, void 0, Promise); -}, -this, void 0, Promise); + var foo = (a = yield ) => __awaiter([this, Promise], function* () { + }); +}); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js index e4383a16220c6..2ec2325951055 100644 --- a/tests/baselines/reference/asyncArrowFunction8_es6.js +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -5,7 +5,6 @@ var foo = async (): Promise => { } //// [asyncArrowFunction8_es6.js] -var foo = () => __awaiter(function* () { +var foo = () => __awaiter([this, Promise], function* () { var v = { [yield ]: foo }; -}, -this, void 0, Promise); +}); diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js index 888c935cc3f47..8cac736ea1b6d 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -11,7 +11,6 @@ class C { class C { method() { function other() { } - var fn = () => __awaiter(function* (arguments) { return yield other.apply(this, arguments); }, - this, arguments); + var fn = () => __awaiter([this, , arguments], function* (arguments) { return yield other.apply(this, arguments); }); } } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js index 67279d7f1be09..b13815ffcbf41 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -9,7 +9,6 @@ class C { //// [asyncArrowFunctionCapturesThis_es6.js] class C { method() { - var fn = () => __awaiter(function* () { return yield this; }, - this); + var fn = () => __awaiter([this], function* () { return yield this; }); } } diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js new file mode 100644 index 0000000000000..2c0ffaf478a1c --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -0,0 +1,119 @@ +//// [asyncAwait_es6.ts] +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwait_es6.js] +var __awaiter = (this && this.__awaiter) || function (args, generator) { + var PromiseConstructor = args[1] || Promise; + return new PromiseConstructor(function (resolve, reject) { + generator = generator.call(args[0], args[2]); + function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f0() { + return __awaiter([this], function* () { }); +} +function f1() { + return __awaiter([this, Promise], function* () { }); +} +function f3() { + return __awaiter([this, MyPromise], function* () { }); +} +let f4 = function () { + return __awaiter([this], function* () { }); +}; +let f5 = function () { + return __awaiter([this, Promise], function* () { }); +}; +let f6 = function () { + return __awaiter([this, MyPromise], function* () { }); +}; +let f7 = () => __awaiter([this], function* () { }); +let f8 = () => __awaiter([this, Promise], function* () { }); +let f9 = () => __awaiter([this, MyPromise], function* () { }); +let f10 = () => __awaiter([this], function* () { return p; }); +let f11 = () => __awaiter([this], function* () { return mp; }); +let f12 = () => __awaiter([this, Promise], function* () { return mp; }); +let f13 = () => __awaiter([this, MyPromise], function* () { return p; }); +let o = { + m1() { + return __awaiter([this], function* () { }); + }, + m2() { + return __awaiter([this, Promise], function* () { }); + }, + m3() { + return __awaiter([this, MyPromise], function* () { }); + } +}; +class C { + m1() { + return __awaiter([this], function* () { }); + } + m2() { + return __awaiter([this, Promise], function* () { }); + } + m3() { + return __awaiter([this, MyPromise], function* () { }); + } + static m4() { + return __awaiter([this], function* () { }); + } + static m5() { + return __awaiter([this, Promise], function* () { }); + } + static m6() { + return __awaiter([this, MyPromise], function* () { }); + } +} +var M; +(function (M) { + function f1() { + return __awaiter([this], function* () { }); + } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols new file mode 100644 index 0000000000000..6cd18e254ba0e --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/async/es6/asyncAwait_es6.ts === +type MyPromise = Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) + +declare var MyPromise: typeof Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwait_es6.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwait_es6.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwait_es6.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwait_es6.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwait_es6.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwait_es6.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwait_es6.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwait_es6.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwait_es6.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(m1, Decl(asyncAwait_es6.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwait_es6.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +} + +module M { +>M : Symbol(M, Decl(asyncAwait_es6.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwait_es6.types b/tests/baselines/reference/asyncAwait_es6.types new file mode 100644 index 0000000000000..5f0cd2cc35a92 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.types @@ -0,0 +1,129 @@ +=== tests/cases/conformance/async/es6/asyncAwait_es6.ts === +type MyPromise = Promise; +>MyPromise : Promise +>T : T +>Promise : Promise +>T : T + +declare var MyPromise: typeof Promise; +>MyPromise : PromiseConstructor +>Promise : PromiseConstructor + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : Promise +>MyPromise : Promise + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => Promise +>MyPromise : Promise + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => Promise +>async function(): MyPromise { } : () => Promise +>MyPromise : Promise + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => Promise +>async (): MyPromise => { } : () => Promise +>MyPromise : Promise + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : Promise + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : Promise + +let f13 = async (): MyPromise => p; +>f13 : () => Promise +>async (): MyPromise => p : () => Promise +>MyPromise : Promise +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): Promise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => Promise +>MyPromise : Promise +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js index dbf2d489a92ff..7cc10548371c7 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -4,7 +4,6 @@ async function await(): Promise { //// [asyncFunctionDeclaration11_es6.js] function await() { - return __awaiter(function* () { - }, - this, void 0, Promise); + return __awaiter([this, Promise], function* () { + }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js index 35f6af6b2ff30..f17b5c894f8cf 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -7,9 +7,8 @@ async function foo(): Promise { //// [asyncFunctionDeclaration13_es6.js] function foo() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { // Legal to use 'await' in a type context. var v; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js index 3610cabbdec63..7fee3f4802abb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -5,8 +5,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration14_es6.js] function foo() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { return; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js index e3e1fb650964a..3e58785802185 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -4,7 +4,6 @@ async function foo(): Promise { //// [asyncFunctionDeclaration1_es6.js] function foo() { - return __awaiter(function* () { - }, - this, void 0, Promise); + return __awaiter([this, Promise], function* () { + }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js index 3c1b16cea96a0..33645996cd880 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -4,7 +4,6 @@ async function foo(a = await): Promise { //// [asyncFunctionDeclaration6_es6.js] function foo(a = yield ) { - return __awaiter(function* () { - }, - this, void 0, Promise); + return __awaiter([this, Promise], function* () { + }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js index 0b2f643e469e5..667250e45db61 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -7,13 +7,11 @@ async function bar(): Promise { //// [asyncFunctionDeclaration7_es6.js] function bar() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { // 'await' here is an identifier, and not a yield expression. function foo(a = yield ) { - return __awaiter(function* () { - }, - this, void 0, Promise); + return __awaiter([this, Promise], function* () { + }); } - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js index 7f23510f942d6..dab1b75076e68 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -5,8 +5,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration9_es6.js] function foo() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { var v = { [yield ]: foo }; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js index 0531f7643fcb0..11b630355d40d 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -9,10 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression1_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = (yield p) || a; "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js index 36545440f1f1f..e8f610ae10ac2 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -9,10 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression2_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = (yield p) && a; "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js index bfe95956ebc4a..770bf75d5a1e1 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -9,10 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression3_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = (yield p) + a; "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js index fa2dd17143e55..f756d6604bb0f 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -9,10 +9,9 @@ async function func(): Promise { //// [awaitBinaryExpression4_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = yield p, a; "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js index 615320e8ebb0c..c66cfbbd57a2b 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -10,11 +10,10 @@ async function func(): Promise { //// [awaitBinaryExpression5_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var o; o.a = yield p; "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js index 9e329e14ad2dd..db4e0c96abf9f 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.js +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression1_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = fn(a, a, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js index 4f8e088b55dd1..47b1e062ae5b8 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.js +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression2_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = fn(yield p, a, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js index 54b5d8411d728..e7a09f9b9b883 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.js +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression3_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = fn(a, yield p, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js index 9e32395df83e0..59449e4f6a14b 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.js +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression4_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = (yield pfn)(a, a, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js index 76ccf06b1050c..c5e28deee89bc 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.js +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression5_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = o.fn(a, a, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js index 90b96a06ad741..62fde8c799ca3 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.js +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression6_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = o.fn(yield p, a, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js index e9a2edb8a9142..f717d76c51dee 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.js +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression7_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = o.fn(a, yield p, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js index e172dde417d31..e6e2cee172bc2 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.js +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -13,10 +13,9 @@ async function func(): Promise { //// [awaitCallExpression8_es6.js] function func() { - return __awaiter(function* () { + return __awaiter([this, Promise], function* () { "before"; var b = (yield po).fn(a, a, a); "after"; - }, - this, void 0, Promise); + }); } diff --git a/tests/cases/conformance/async/es6/asyncAwait_es6.ts b/tests/cases/conformance/async/es6/asyncAwait_es6.ts new file mode 100644 index 0000000000000..8e72197a98d9a --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncAwait_es6.ts @@ -0,0 +1,40 @@ +// @target: ES6 +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file From df13b8ffd199223881daf9231cdd63ec6f6b716f Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Jun 2015 11:43:16 -0700 Subject: [PATCH 088/250] Update comment. --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3fd917bc00e27..0fcc478d2b110 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11684,6 +11684,9 @@ namespace ts { var cancellationToken: CancellationTokenObject; function getDiagnostics(sourceFile: SourceFile, ct: CancellationTokenObject): Diagnostic[] { try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. cancellationToken = ct; return getDiagnosticsWorker(sourceFile); } From c9c0f3a4adc2bbe031c402ab70f6707828ff8e35 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Jun 2015 12:04:26 -0700 Subject: [PATCH 089/250] PR feedback. --- src/compiler/checker.ts | 6 +++--- src/compiler/core.ts | 21 ------------------- src/compiler/program.ts | 22 ++++++++++---------- src/compiler/types.ts | 22 +++++++++++--------- src/harness/fourslash.ts | 10 ++++----- src/harness/harnessLanguageService.ts | 29 ++++++++++++--------------- src/services/navigateTo.ts | 2 +- src/services/services.ts | 21 ++++++++++++++++++- src/services/shims.ts | 4 ++-- src/services/signatureHelp.ts | 2 +- 10 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0fcc478d2b110..8fd7f1a75d97d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -167,7 +167,7 @@ namespace ts { return checker; - function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationTokenObject) { + function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. getDiagnostics(sourceFile, cancellationToken); @@ -11681,8 +11681,8 @@ namespace ts { } } - var cancellationToken: CancellationTokenObject; - function getDiagnostics(sourceFile: SourceFile, ct: CancellationTokenObject): Diagnostic[] { + var cancellationToken: CancellationToken; + function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken): Diagnostic[] { try { // Record the cancellation token so it can be checked later on during checkSourceElement. // Do this in a finally block so we can ensure that it gets reset back to nothing after diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 49371dbccd2cd..52eae6e37c1e9 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -798,25 +798,4 @@ namespace ts { Debug.assert(false, message); } } -} - -namespace ts { - export class OperationCanceledException { } - - export class CancellationTokenObject { - public static None: CancellationTokenObject = new CancellationTokenObject(null) - - constructor(private cancellationToken: CancellationToken) { - } - - public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - } - - public throwIfCancellationRequested(): void { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - } - } } \ No newline at end of file diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 443f5f92b49ea..f0277e60d0d2c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -104,7 +104,7 @@ namespace ts { }; } - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[] { + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] { let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), @@ -233,11 +233,11 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationTokenObject): EmitResult { + function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); } - function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationTokenObject): EmitResult { + function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones @@ -272,8 +272,8 @@ namespace ts { function getDiagnosticsHelper( sourceFile: SourceFile, - getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationTokenObject) => Diagnostic[], - cancellationToken: CancellationTokenObject): Diagnostic[] { + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[], + cancellationToken: CancellationToken): Diagnostic[] { if (sourceFile) { return getDiagnostics(sourceFile, cancellationToken); } @@ -289,19 +289,19 @@ namespace ts { return sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return sourceFile.parseDiagnostics; } @@ -321,7 +321,7 @@ namespace ts { } } - function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { let typeChecker = getDiagnosticsProducingTypeChecker(); @@ -334,7 +334,7 @@ namespace ts { }); } - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationTokenObject): Diagnostic[] { + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { if (!isDeclarationFile(sourceFile)) { let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 799c291f46a5d..662c10f4235ae 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1210,13 +1210,13 @@ namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationTokenObject): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source fils in the program. @@ -1324,9 +1324,9 @@ namespace ts { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; // Should not be called directly. Should only be accessed through the Program instance. - /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[]; + /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; - /* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): EmitResolver; + /* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; /* @internal */ getNodeCount(): number; /* @internal */ getIdentifierCount(): number; @@ -2052,14 +2052,18 @@ namespace ts { verticalTab = 0x0B, // \v } + export class OperationCanceledException { } + export interface CancellationToken { isCancellationRequested(): boolean; + + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; } export interface CompilerHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getDefaultLibFileName(options: CompilerOptions): string; - getCancellationToken? (): CancellationToken; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5915698462ca3..41dda5bc9b395 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -190,14 +190,14 @@ module FourSlash { return "\nMarker: " + currentTestState.lastKnownMarker + "\nChecking: " + msg + "\n\n"; } - export class TestCancellationToken implements ts.CancellationToken { + export class TestCancellationToken implements ts.HostCancellationToken { // 0 - cancelled // >0 - not cancelled // <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled - private static NotCancelled: number = -1; - private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCancelled; - public isCancellationRequested(): boolean { + private static NotCanceled: number = -1; + private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled; + public isCancellationRequested(): boolean { if (this.numberOfCallsBeforeCancellation < 0) { return false; } @@ -216,7 +216,7 @@ module FourSlash { } public resetCancelled(): void { - this.numberOfCallsBeforeCancellation = TestCancellationToken.NotCancelled; + this.numberOfCallsBeforeCancellation = TestCancellationToken.NotCanceled; } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8eb778175334c..6cb92df59489a 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -103,14 +103,11 @@ module Harness.LanguageService { } } - class CancellationToken { - public static None: CancellationToken = new CancellationToken(null); - - constructor(private cancellationToken: ts.CancellationToken) { - } + class DefaultHostCancellationToken implements ts.HostCancellationToken { + public static Instance = new DefaultHostCancellationToken(); public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return false; } } @@ -124,8 +121,8 @@ module Harness.LanguageService { export class LanguageServiceAdapterHost { protected fileNameToScript: ts.Map = {}; - constructor(protected cancellationToken: ts.CancellationToken = CancellationToken.None, - protected settings = ts.getDefaultCompilerOptions()) { + constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, + protected settings = ts.getDefaultCompilerOptions()) { } public getNewLine(): string { @@ -173,8 +170,8 @@ module Harness.LanguageService { /// Native adapter class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { - getCompilationSettings(): ts.CompilerOptions { return this.settings; } - getCancellationToken(): ts.CancellationToken { return this.cancellationToken; } + getCompilationSettings() { return this.settings; } + getCancellationToken() { return this.cancellationToken; } getCurrentDirectory(): string { return ""; } getDefaultLibFileName(): string { return ""; } getScriptFileNames(): string[] { return this.getFilenames(); } @@ -194,7 +191,7 @@ module Harness.LanguageService { export class NativeLanugageServiceAdapter implements LanguageServiceAdapter { private host: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new NativeLanguageServiceHost(cancellationToken, options); } getHost() { return this.host; } @@ -206,7 +203,7 @@ module Harness.LanguageService { /// Shim adapter class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost { private nativeHost: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { super(cancellationToken, options); this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options); } @@ -218,7 +215,7 @@ module Harness.LanguageService { positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); } getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); } - getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); } + getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); } getCurrentDirectory(): string { return this.nativeHost.getCurrentDirectory(); } getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); } getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); } @@ -399,7 +396,7 @@ module Harness.LanguageService { export class ShimLanugageServiceAdapter implements LanguageServiceAdapter { private host: ShimLanguageServiceHost; private factory: ts.TypeScriptServicesFactory; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new ShimLanguageServiceHost(cancellationToken, options); this.factory = new TypeScript.Services.TypeScriptServicesFactory(); } @@ -446,7 +443,7 @@ module Harness.LanguageService { class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost { private client: ts.server.SessionClient; - constructor(cancellationToken: ts.CancellationToken, settings: ts.CompilerOptions) { + constructor(cancellationToken: ts.HostCancellationToken, settings: ts.CompilerOptions) { super(cancellationToken, settings); } @@ -575,7 +572,7 @@ module Harness.LanguageService { export class ServerLanugageServiceAdapter implements LanguageServiceAdapter { private host: SessionClientHost; private client: ts.server.SessionClient; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { // This is the main host that tests use to direct tests var clientHost = new SessionClientHost(cancellationToken, options); var client = new ts.server.SessionClient(clientHost); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index a4cc7ec2ad515..bc506bc22f90f 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -2,7 +2,7 @@ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; - export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[] { + export function getNavigateToItems(program: Program, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[] { let patternMatcher = createPatternMatcher(searchValue); let rawItems: RawNavigateToItem[] = []; diff --git a/src/services/services.ts b/src/services/services.ts index f7f7dfcf6b305..efb7a61a8ddb1 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -944,6 +944,10 @@ namespace ts { } } + export interface HostCancellationToken { + isCancellationRequested(): boolean; + } + // // Public interface of the host of a language service instance. // @@ -955,7 +959,7 @@ namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): CancellationToken; + getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: CompilerOptions): string; log? (s: string): void; @@ -2379,6 +2383,21 @@ namespace ts { return ScriptElementKind.unknown; } + class CancellationTokenObject implements CancellationToken { + constructor(private cancellationToken: HostCancellationToken) { + } + + public isCancellationRequested() { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } + export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService { let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); let ruleProvider: formatting.RulesProvider; diff --git a/src/services/shims.ts b/src/services/shims.ts index 2e8b3eb774d59..f56cef82f9d0c 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -51,7 +51,7 @@ namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): ScriptSnapshotShim; getLocalizedDiagnosticMessages(): string; - getCancellationToken(): CancellationToken; + getCancellationToken(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: string): string; getNewLine?(): string; @@ -326,7 +326,7 @@ namespace ts { } } - public getCancellationToken(): CancellationToken { + public getCancellationToken(): HostCancellationToken { return this.shimHost.getCancellationToken(); } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index fce4e2c302519..44b022a7b1285 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -178,7 +178,7 @@ namespace ts.SignatureHelp { argumentCount: number; } - export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationTokenObject): SignatureHelpItems { + export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems { let typeChecker = program.getTypeChecker(); // Decide whether to show signature help From 5ca3955473e5242c18e09b178dd69dc0bfb3dfd9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 12:19:07 -0700 Subject: [PATCH 090/250] check for inheriting abstract member functions --- src/compiler/checker.ts | 120 ++++++++++++------ .../diagnosticInformationMap.generated.ts | 2 + src/compiler/diagnosticMessages.json | 8 ++ 3 files changed, 88 insertions(+), 42 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fac2ee3b4c557..2f7a66ad78c1e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1978,7 +1978,7 @@ namespace ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -2172,8 +2172,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -3686,8 +3686,8 @@ namespace ts { let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; let type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -4561,7 +4561,24 @@ namespace ts { let requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); for (let targetProp of properties) { let sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { + + if (sourceProp === targetProp) { // source inherits targetProp and doesn't redeclare/override it. + + if (source.flags & TypeFlags.Class && target.flags & TypeFlags.Class) { + + let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + let sourceDecl = getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration); + + // if target is a class and it has an abstract method, then source, inheriting that method, must be declared abstract. + if (targetPropFlags & NodeFlags.Abstract && !(sourceDecl.flags & NodeFlags.Abstract)) { + if (reportErrors) { + reportError(Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2, + typeToString(source), typeToString(target), symbolToString(targetProp)); + } + return Ternary.False; + } + } + } else { // sourceProp !== targetProp -- ie: source and target have distinct declarations with the same name if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { if (reportErrors) { @@ -4571,24 +4588,24 @@ namespace ts { } } else if (!(targetProp.flags & SymbolFlags.Prototype)) { - let sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - let targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) { + let sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & NodeFlags.Private || targetPropFlags & NodeFlags.Private) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & NodeFlags.Private && targetFlags & NodeFlags.Private) { + if (sourcePropFlags & NodeFlags.Private && targetPropFlags & NodeFlags.Private) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), - typeToString(sourceFlags & NodeFlags.Private ? source : target), - typeToString(sourceFlags & NodeFlags.Private ? target : source)); + typeToString(sourcePropFlags & NodeFlags.Private ? source : target), + typeToString(sourcePropFlags & NodeFlags.Private ? target : source)); } } return Ternary.False; } } - else if (targetFlags & NodeFlags.Protected) { + else if (targetPropFlags & NodeFlags.Protected) { let sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; let sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; let targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -4600,7 +4617,7 @@ namespace ts { return Ternary.False; } } - else if (sourceFlags & NodeFlags.Protected) { + else if (sourcePropFlags & NodeFlags.Protected) { if (reportErrors) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -5993,20 +6010,20 @@ namespace 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; } } } @@ -6637,7 +6654,7 @@ namespace ts { return s.valueDeclaration ? s.valueDeclaration.kind : SyntaxKind.PropertyDeclaration; } - function getDeclarationFlagsFromSymbol(s: Symbol) { + function getDeclarationFlagsFromSymbol(s: Symbol): NodeFlags { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } @@ -8101,8 +8118,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -8290,7 +8307,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // fall-through + // fall-through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -8318,8 +8335,8 @@ namespace ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { let 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; @@ -9258,7 +9275,7 @@ namespace ts { } // abstract functions cannot have an implementation - if(currentNodeFlags & NodeFlags.Abstract) { + if (currentNodeFlags & NodeFlags.Abstract) { error(node, Diagnostics.Abstract_member_functions_cannot_have_an_implementation) } } @@ -9505,7 +9522,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // fall-through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -10627,6 +10644,9 @@ namespace ts { checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + + + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. @@ -10662,6 +10682,11 @@ namespace ts { } forEach(node.members, checkSourceElement); + + // Classes containing abstract members must be marked abstract + if (!(node.flags & NodeFlags.Abstract) && forEach(node.members, (element: ClassElement) => element.flags & NodeFlags.Abstract)) { + error(node, Diagnostics.Classes_containing_abstract_functions_must_be_marked_abstract); + } if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -10700,8 +10725,19 @@ namespace ts { } let derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - if (derived) { - let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + + if (!derived) { // derived class inherits base without override/redeclaration + let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); + Debug.assert(derivedClassDecl !== undefined); + + // It is an error to inherit an abstract member without implementing it or being declared abstract. + if ((baseDeclarationFlags & NodeFlags.Abstract) && !(derivedClassDecl.flags & NodeFlags.Abstract)) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2, + typeToString(type), typeToString(baseType), symbolToString(baseProperty)); + } + + } else { // derived !== undefined -- derived overrides base let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { // either base or derived property is private - not override, skip it @@ -11990,7 +12026,7 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // fall-through + // fall-through case SyntaxKind.NumericLiteral: // index access @@ -12163,7 +12199,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -12414,11 +12450,11 @@ namespace ts { // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case SyntaxKind.ClassDeclaration: return "Function"; - case SyntaxKind.PropertyDeclaration: return serializeTypeNode((node).type); - case SyntaxKind.Parameter: return serializeTypeNode((node).type); - case SyntaxKind.GetAccessor: return serializeTypeNode((node).type); - case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); + case SyntaxKind.ClassDeclaration: return "Function"; + case SyntaxKind.PropertyDeclaration: return serializeTypeNode((node).type); + case SyntaxKind.Parameter: return serializeTypeNode((node).type); + case SyntaxKind.GetAccessor: return serializeTypeNode((node).type); + case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (isFunctionLike(node)) { return "Function"; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index d1cd9b4ba39d8..a29aed6615f02 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -396,6 +396,8 @@ namespace ts { Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, All_overload_signatures_must_match_with_respect_to_modifier_0: { code: 2512, category: DiagnosticCategory.Error, key: "All overload signatures must match with respect to modifier '{0}'." }, Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract member function '{0}' on type '{1}' cannot be called via super expression." }, + Classes_containing_abstract_functions_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract functions must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." }, 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 ddfc885dcf6a1..859565c181a3d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1571,6 +1571,14 @@ "category": "Error", "code": 2513 }, + "Classes containing abstract functions must be marked abstract.": { + "category": "Error", + "code": 2514 + }, + "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." : { + "category": "Error", + "code": 2515 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From 91e3a5cce2906474f6e6af2d34df145ddc0c9bb8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 12:27:48 -0700 Subject: [PATCH 091/250] updated baselines --- .../reference/augmentedTypesClass2.errors.txt | 8 ++--- .../augmentedTypesInterface.errors.txt | 8 ++--- .../classAndInterfaceWithSameName.errors.txt | 16 +++++----- .../reference/clinterfaces.errors.txt | 32 +++++++++---------- .../baselines/reference/declInput.errors.txt | 8 ++--- ...ifiersAcrossContainerBoundaries.errors.txt | 8 ++--- ...IdentifiersAcrossFileBoundaries.errors.txt | 16 +++++----- .../interfaceDeclaration2.errors.txt | 8 ++--- .../reference/mergedClassInterface.errors.txt | 16 +++++----- .../reference/nameCollisions.errors.txt | 16 +++++----- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 5 ++- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 5 ++- 12 files changed, 72 insertions(+), 74 deletions(-) diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 9d0b7b25c3414..da963c59d94bd 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 8ee7dc4e1e80b..44c47e70ab3df 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index 170ff29226b2d..b2b59c290093d 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. @@ -31,7 +31,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName. interface D { // error ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index 1d5ecd136f066..8d48f29aed708 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 4e12c802bee61..76257de6ea9ba 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/declInput.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(1,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index f8b5c5595154a..67ee1d9cc371e 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index dcb2440aa2680..c98e0e9a8c63a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file1.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/file1.ts(3,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. -tests/cases/compiler/file2.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/file2.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged @@ -15,10 +15,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. interface I { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. @@ -42,10 +42,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file2.ts (6 errors) ==== class I { } // error -- cannot merge interface with non-ambient class ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C1 { } // error -- cannot merge interface with non-ambient class ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 2789657a20208..1d5807b9b1b8b 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: Only an ambien interface I2 { } ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt index 6177b5fa8713b..37bd595c0b736 100644 --- a/tests/baselines/reference/mergedClassInterface.errors.txt +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== @@ -17,19 +17,19 @@ tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: class C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C5 { x1: number; diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index bc7ec75257310..2aba1c43f86d3 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: Only an ambient cla class cli { } ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index aabebad055226..a51eb18d98efc 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,5 +1,4 @@ -lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 8b1c5fbe0e2a7..d41c3d0cdbf03 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,5 +1,4 @@ -lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { From 851c7e4bf9d2fb270a209a8a6defd3c5c9846932 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 12:35:06 -0700 Subject: [PATCH 092/250] fixed comment, spacing --- src/compiler/binder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f1d8b141a103b..07279e93b5513 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -176,7 +176,7 @@ namespace ts { /** * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. * @param symbolTable - The symbol table which node will be added to. - * @param parent - If node is in a class, parent denotes the parent declaration. + * @param parent - node's parent declaration. * @param node - The declaration to be added to the symbol table * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. @@ -211,11 +211,11 @@ namespace ts { symbol = hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(SymbolFlags.None, name)); - + if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; + classifiableNames[name] = name; } - + if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; From 556cb70c1d0de4d450baadf48279b7f0ca3d954e Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:00:36 -0700 Subject: [PATCH 093/250] Utilities + types setup for JSX and As --- src/compiler/core.ts | 4 +- src/compiler/types.ts | 91 +++++++++++++++++++++++++++++++++++++++ src/compiler/utilities.ts | 16 ++++--- 3 files changed, 104 insertions(+), 7 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ced477eeeec54..7b35c5e0d6587 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -702,9 +702,9 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedExtensions = [".ts", ".d.ts"]; + export const supportedExtensions = [".tsx", ".ts", ".d.ts"]; - const extensionsToRemove = [".d.ts", ".ts", ".js"]; + const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { for (let ext of extensionsToRemove) { if (fileExtensionIs(path, ext)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f9a2fa3b7b434..d78d38d5ba710 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -48,6 +48,7 @@ namespace ts { SemicolonToken, CommaToken, LessThanToken, + LessThanSlashToken, GreaterThanToken, LessThanEqualsToken, GreaterThanEqualsToken, @@ -217,6 +218,8 @@ namespace ts { ClassExpression, OmittedExpression, ExpressionWithTypeArguments, + AsExpression, + // Misc TemplateSpan, SemicolonClassElement, @@ -265,6 +268,16 @@ namespace ts { // Module references ExternalModuleReference, + //JSX + JsxElement, + JsxSelfClosingElement, + JsxOpeningElement, + JsxText, + JsxClosingElement, + JsxAttribute, + JsxSpreadAttribute, + JsxExpression, + // Clauses CaseClause, DefaultClause, @@ -396,6 +409,17 @@ namespace ts { HasAggregatedChildData = 1 << 8 } + export const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1 << 0, + IntrinsicIndexedElement = 1 << 1, + ClassElement = 1 << 2, + UnknownElement = 1 << 3, + + IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement + } + + /* @internal */ export const enum RelationComparisonResult { Succeeded = 1, // Should be truthy @@ -799,11 +823,66 @@ namespace ts { export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + export interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } + export interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } + export type AssertionExpression = TypeAssertion | AsExpression; + + /// A JSX expression of the form ... + export interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + + /// The opening element of a ... JsxElement + export interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + + /// A JSX expression of the form + export interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + + /// Either the opening tag in a ... pair, or the lone in a self-closing form + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + + export interface JsxAttribute extends Node { + name: Identifier; + /// JSX attribute initializers are optional; is sugar for + initializer?: Expression; + } + + export interface JsxSpreadAttribute extends Node { + expression: Expression; + } + + export interface JsxClosingElement extends Node { + tagName: EntityName; + } + + export interface JsxExpression extends Expression { + expression?: Expression; + } + + export interface JsxText extends Node { + _jsxTextExpressionBrand: any; + /// Used by the emitter to avoid recomputation + formattedReactText?: string; + } + + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; + export interface Statement extends Node { _statementBrand: any; } @@ -1144,6 +1223,7 @@ namespace ts { amdDependencies: {path: string; name: string}[]; moduleName: string; referencedFiles: FileReference[]; + isTSXFile: boolean; /** * lib.d.ts should have a reference comment like @@ -1323,6 +1403,9 @@ namespace ts { getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; + // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; @@ -1603,6 +1686,7 @@ namespace ts { assignmentChecks?: Map; // Cache of assignment checks hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side + jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with } export const enum TypeFlags { @@ -1834,6 +1918,7 @@ namespace ts { help?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + jsx?: JsxEmit; listFiles?: boolean; locale?: string; mapRoot?: string; @@ -1877,6 +1962,12 @@ namespace ts { System = 4, } + export const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2 + } + export const enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ee75454ad9331..7ec599babbced 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -169,13 +169,13 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } - export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string { + export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string { if (nodeIsMissing(node)) { return ""; } let text = sourceFile.text; - return text.substring(skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : skipTrivia(text, node.pos), node.end); } export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string { @@ -186,8 +186,8 @@ namespace ts { return sourceText.substring(skipTrivia(sourceText, node.pos), node.end); } - export function getTextOfNode(node: Node): string { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + export function getTextOfNode(node: Node, includeTrivia = false): string { + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' @@ -850,6 +850,7 @@ namespace ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AsExpression: case SyntaxKind.TypeAssertionExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.FunctionExpression: @@ -866,6 +867,8 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.OmittedExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.YieldExpression: return true; case SyntaxKind.QualifiedName: @@ -912,7 +915,8 @@ namespace ts { return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || forInStatement.expression === node; case SyntaxKind.TypeAssertionExpression: - return node === (parent).expression; + case SyntaxKind.AsExpression: + return node === (parent).expression; case SyntaxKind.TemplateSpan: return node === (parent).expression; case SyntaxKind.ComputedPropertyName: @@ -1886,6 +1890,8 @@ namespace ts { case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.ParenthesizedExpression: From a4045e539b4f115f854d3cb3351089e62a59f3f0 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:00:54 -0700 Subject: [PATCH 094/250] Scanner / parser for JSX and As --- src/compiler/parser.ts | 230 +++++++++++++++++++++++++++++++++++++++- src/compiler/scanner.ts | 65 +++++++++++- 2 files changed, 292 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a507125d4bb90..d89ab3a771bdd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -162,6 +162,9 @@ namespace ts { return visitNode(cbNode, (node).left) || visitNode(cbNode, (node).operatorToken) || visitNode(cbNode, (node).right); + case SyntaxKind.AsExpression: + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).type); case SyntaxKind.ConditionalExpression: return visitNode(cbNode, (node).condition) || visitNode(cbNode, (node).questionToken) || @@ -319,6 +322,25 @@ namespace ts { return visitNode(cbNode, (node).expression); case SyntaxKind.MissingDeclaration: return visitNodes(cbNodes, node.decorators); + + case SyntaxKind.JsxElement: + return visitNode(cbNode, (node).openingElement) || + visitNodes(cbNodes, (node).children) || + visitNode(cbNode, (node).closingElement); + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: + return visitNode(cbNode, (node).tagName) || + visitNodes(cbNodes, (node).attributes); + case SyntaxKind.JsxAttribute: + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).initializer); + case SyntaxKind.JsxSpreadAttribute: + return visitNode(cbNode, (node).expression); + case SyntaxKind.JsxExpression: + return visitNode(cbNode, (node).expression); + case SyntaxKind.JsxClosingElement: + return visitNode(cbNode, (node).tagName); + case SyntaxKind.JSDocTypeExpression: return visitNode(cbNode, (node).type); case SyntaxKind.JSDocUnionType: @@ -634,6 +656,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0; + sourceFile.isTSXFile = fileExtensionIs(sourceFile.fileName, ".tsx"); return sourceFile; } @@ -804,6 +827,10 @@ namespace ts { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier(): SyntaxKind { + return token = scanner.scanJsxIdentifier(); + } + function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -1175,6 +1202,10 @@ namespace ts { return isHeritageClause(); case ParsingContext.ImportOrExportSpecifiers: return isIdentifierOrKeyword(); + case ParsingContext.JsxAttributes: + return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken; + case ParsingContext.JsxChildren: + return token === SyntaxKind.LessThanToken || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.JsxText; case ParsingContext.JSDocFunctionParameters: case ParsingContext.JSDocTypeArguments: case ParsingContext.JSDocTupleTypes: @@ -1265,6 +1296,11 @@ namespace ts { return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.OpenParenToken; case ParsingContext.HeritageClauses: return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken; + case ParsingContext.JsxAttributes: + // For error recovery, include } here (otherwise an over-braced {expr}} will close the surrounding statement block and mess up the entire file). + return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.SlashToken || token === SyntaxKind.CloseBraceToken; + case ParsingContext.JsxChildren: + return token === SyntaxKind.LessThanSlashToken; case ParsingContext.JSDocFunctionParameters: return token === SyntaxKind.CloseParenToken || token === SyntaxKind.ColonToken || token === SyntaxKind.CloseBraceToken; case ParsingContext.JSDocTypeArguments: @@ -1481,6 +1517,12 @@ namespace ts { // name list, and there can be left hand side expressions (which can have type // arguments.) case ParsingContext.HeritageClauseElement: + + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case ParsingContext.JsxAttributes: + case ParsingContext.JsxChildren: + } return false; @@ -1639,6 +1681,8 @@ namespace ts { case ParsingContext.TupleElementTypes: return Diagnostics.Type_expected; case ParsingContext.HeritageClauses: return Diagnostics.Unexpected_token_expected; case ParsingContext.ImportOrExportSpecifiers: return Diagnostics.Identifier_expected; + case ParsingContext.JsxAttributes: return Diagnostics.Identifier_expected; + case ParsingContext.JsxChildren: return Diagnostics.Identifier_expected; case ParsingContext.JSDocFunctionParameters: return Diagnostics.Parameter_declaration_expected; case ParsingContext.JSDocTypeArguments: return Diagnostics.Type_argument_expected; case ParsingContext.JSDocTupleTypes: return Diagnostics.Type_expected; @@ -2794,6 +2838,32 @@ namespace ts { return Tristate.False; } + // JSX overrides + if (sourceFile.isTSXFile) { + let isArrowFunctionInJsx = lookAhead(() => { + let third = nextToken(); + let fourth = nextToken(); + if (third === SyntaxKind.ExtendsKeyword) { + switch (fourth) { + case SyntaxKind.EqualsToken: + case SyntaxKind.GreaterThanToken: + return false; + default: + return true; + } + } + else if (third === SyntaxKind.CommaToken) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return Tristate.Unknown; + } else { + return Tristate.False; + } + } + // This *could* be a parenthesized arrow function. return Tristate.Unknown; } @@ -2910,7 +2980,23 @@ namespace ts { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === SyntaxKind.AsKeyword) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; @@ -2947,6 +3033,7 @@ namespace ts { case SyntaxKind.GreaterThanEqualsToken: case SyntaxKind.InstanceOfKeyword: case SyntaxKind.InKeyword: + case SyntaxKind.AsKeyword: return 7; case SyntaxKind.LessThanLessThanToken: case SyntaxKind.GreaterThanGreaterThanToken: @@ -2974,6 +3061,13 @@ namespace ts { return finishNode(node); } + function makeAsExpression(left: Expression, right: TypeNode): AsExpression { + let node = createNode(SyntaxKind.AsExpression, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { let node = createNode(SyntaxKind.PrefixUnaryExpression); node.operator = token; @@ -3019,7 +3113,7 @@ namespace ts { case SyntaxKind.VoidKeyword: return parseVoidExpression(); case SyntaxKind.LessThanToken: - return parseTypeAssertion(); + return sourceFile.isTSXFile ? parseJsxElementOrSelfClosingElement() : parseTypeAssertion(); default: return parsePostfixExpressionOrHigher(); } @@ -3146,6 +3240,136 @@ namespace ts { node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } + + function parseJsxChild(): JsxChild { + let result: JsxChild = undefined; + switch (token) { + case SyntaxKind.JsxText: + result = createNode(SyntaxKind.JsxText); + token = scanner.scanJsxToken(); + result = finishNode(result); + break; + case SyntaxKind.OpenBraceToken: + result = parseJsxExpression(); + break; + default: + Debug.assert(token === SyntaxKind.LessThanToken); + result = parseJsxElementOrSelfClosingElement(); + break; + } + token = scanner.reScanJsxToken(); + Debug.assert(result !== undefined, "parsed some JSX child"); + return result; + } + + function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement { + let opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === SyntaxKind.JsxOpeningElement) { + let node = createNode(SyntaxKind.JsxElement, opening.pos); + node.openingElement = opening; + + // Rescan since parsing the > messed up the scanner state + token = scanner.reScanJsxToken(); + node.children = parseList(ParsingContext.JsxChildren, parseJsxChild); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + Debug.assert(opening.kind === SyntaxKind.JsxSelfClosingElement); + // Nothing else to do for self-closing elements + return opening; + } + } + + function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement { + let fullStart = scanner.getStartPos(); + + parseExpected(SyntaxKind.LessThanToken); + + let tagName = parseJsxElementName(); + let attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); + let node: JsxOpeningLikeElement; + if (token === SyntaxKind.SlashToken) { + node = createNode(SyntaxKind.JsxSelfClosingElement, fullStart); + + nextToken(); + } + else { + node = createNode(SyntaxKind.JsxOpeningElement, fullStart); + } + parseExpected(SyntaxKind.GreaterThanToken); + + node.tagName = tagName; + node.attributes = attributes; + + return finishNode(node); + } + + function parseJsxElementName(): EntityName { + scanJsxIdentifier(); + let elementName: EntityName = parseIdentifier(); + while (parseOptional(SyntaxKind.DotToken)) { + scanJsxIdentifier(); + let node = createNode(SyntaxKind.QualifiedName, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + + function parseJsxExpression(): JsxExpression { + let node = createNode(SyntaxKind.JsxExpression); + + parseExpected(SyntaxKind.OpenBraceToken); + if (token !== SyntaxKind.CloseBraceToken) { + node.expression = parseExpression(); + } + parseExpected(SyntaxKind.CloseBraceToken); + + return finishNode(node); + } + + function parseJsxAttribute(): JsxAttribute | JsxSpreadAttribute { + if (token === SyntaxKind.OpenBraceToken) { + return parseJsxSpreadAttribute(); + } + + scanJsxIdentifier(); + let node = createNode(SyntaxKind.JsxAttribute); + node.name = parseIdentifierName(); + if (parseOptional(SyntaxKind.EqualsToken)) { + switch (token) { + case SyntaxKind.LessThanToken: + node.initializer = parseJsxElementOrSelfClosingElement(); + break; + case SyntaxKind.StringLiteral: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + + function parseJsxSpreadAttribute(): JsxSpreadAttribute { + let node = createNode(SyntaxKind.JsxSpreadAttribute); + parseExpected(SyntaxKind.OpenBraceToken); + parseExpected(SyntaxKind.DotDotDotToken); + node.expression = parseExpression(); + parseExpected(SyntaxKind.CloseBraceToken); + return finishNode(node); + } + + function parseJsxClosingElement(): JsxClosingElement { + let node = createNode(SyntaxKind.JsxClosingElement); + parseExpected(SyntaxKind.LessThanSlashToken); + node.tagName = parseJsxElementName(); + parseExpected(SyntaxKind.GreaterThanToken); + return finishNode(node); + } function parseTypeAssertion(): TypeAssertion { let node = createNode(SyntaxKind.TypeAssertionExpression); @@ -4881,6 +5105,8 @@ namespace ts { ArrayBindingElements, // Binding elements in array binding list ArgumentExpressions, // Expressions in argument list ObjectLiteralMembers, // Members in object literal + JsxAttributes, // Attributes in jsx element + JsxChildren, // Things between opening and closing JSX tags ArrayLiteralMembers, // Members in array literal Parameters, // Parameters in parameter list TypeParameters, // Type parameters in type parameter list diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index bcc31c39002e3..4ce0dadc1cdfb 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -21,6 +21,9 @@ namespace ts { reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; scan(): SyntaxKind; // Sets the text for the scanner to scan. An optional subrange starting point and length // can be provided to have the scanner only scan a portion of the text. @@ -130,6 +133,7 @@ namespace ts { "++": SyntaxKind.PlusPlusToken, "--": SyntaxKind.MinusMinusToken, "<<": SyntaxKind.LessThanLessThanToken, + ">": SyntaxKind.GreaterThanGreaterThanToken, ">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken, "&": SyntaxKind.AmpersandToken, @@ -621,7 +625,7 @@ namespace ts { ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - + /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, @@ -665,6 +669,9 @@ namespace ts { reScanGreaterToken, reScanSlashToken, reScanTemplateToken, + scanJsxIdentifier, + reScanJsxToken, + scanJsxToken, scan, setText, setScriptTarget, @@ -1481,6 +1488,62 @@ namespace ts { return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken(): SyntaxKind { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + + function scanJsxToken(): SyntaxKind { + startPos = tokenPos = pos; + + if (pos >= end) { + return token = SyntaxKind.EndOfFileToken; + } + + let char = text.charCodeAt(pos); + if (char === CharacterCodes.lessThan) { + if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + return token = SyntaxKind.LessThanSlashToken; + } + pos++; + return token = SyntaxKind.LessThanToken; + } + + if (char === CharacterCodes.openBrace) { + pos++; + return token = SyntaxKind.OpenBraceToken; + } + + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) { + break; + } + } + return token = SyntaxKind.JsxText; + } + + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier(): SyntaxKind { + if (token === SyntaxKind.Identifier) { + let firstCharPosition = pos; + while (pos < end) { + let ch = text.charCodeAt(pos); + if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + function speculationHelper(callback: () => T, isLookahead: boolean): T { let savePos = pos; let saveStartPos = startPos; From 6dfe3d72cff72b7bc6d2fd8989f6030a7a0eb704 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:01:31 -0700 Subject: [PATCH 095/250] JSX/as support in tsc.js + error messages --- src/compiler/commandLineParser.ts | 25 +++++- .../diagnosticInformationMap.generated.ts | 19 ++++ src/compiler/diagnosticMessages.json | 88 +++++++++++++++++-- 3 files changed, 125 insertions(+), 7 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 07bccf4a5efa3..648724ad94ec8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -38,6 +38,16 @@ namespace ts { name: "inlineSources", type: "boolean", }, + { + name: "jsx", + type: { + "preserve": JsxEmit.Preserve, + "react": JsxEmit.React + }, + paramType: Diagnostics.KIND, + description: Diagnostics.Specifies_how_to_transform_JSX_syntax_during_compilation, + error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean", @@ -408,10 +418,21 @@ namespace ts { } else { var exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; - if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { + if (fileExtensionIs(name, ".d.ts")) { + let baseName = name.substr(0, name.length - ".d.ts".length); + if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { + fileNames.push(name); + } + } + else if (fileExtensionIs(name, ".ts")) { + if (!contains(sysFiles, name + "x")) { + fileNames.push(name) + } + } + else { fileNames.push(name); } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 09b009711fee2..bd3737ee4bf64 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -389,6 +389,17 @@ namespace ts { No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, + The_global_type_JSX_Element_must_exist_when_using_JSX: { code: 2602, category: DiagnosticCategory.Error, key: "The global type 'JSX.Element' must exist when using JSX." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_0_is_not_a_constructor_function: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element '{0}' is not a constructor function." }, + JSX_element_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 2609, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface JSX.{0} exists" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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}'." }, @@ -531,6 +542,8 @@ namespace ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specifies_how_to_transform_JSX_syntax_during_compilation: { code: 6080, category: DiagnosticCategory.Message, key: "Specifies how to transform JSX syntax during compilation." }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for --jsx must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, @@ -569,5 +582,11 @@ namespace ts { decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fee46a84c1e4e..23ab3b89f70e5 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -686,7 +686,7 @@ "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": { "category": "Error", "code": 1219 - }, + }, "Generators are only available when targeting ECMAScript 6 or higher.": { "category": "Error", "code": 1220 @@ -1546,6 +1546,52 @@ "code": 2510 }, + "JSX element attributes type '{0}' must be an object type.": { + "category": "Error", + "code": 2600 + }, + "The return type of a JSX element constructor must return an object type.": { + "category": "Error", + "code": 2601 + }, + "The global type 'JSX.Element' must exist when using JSX.": { + "category": "Error", + "code": 2602 + }, + "Property '{0}' in type '{1}' is not assignable to type '{2}'": { + "category": "Error", + "code": 2603 + }, + "JSX element '{0}' is not a constructor function.": { + "category": "Error", + "code": 2604 + }, + "JSX element '{0}' is not a constructor function for JSX elements.": { + "category": "Error", + "code": 2605 + }, + "Property '{0}' of JSX spread attribute is not assignable to target property.": { + "category": "Error", + "code": 2606 + }, + "JSX element class does not support attributes because it does not have a '{0}' property": { + "category": "Error", + "code": 2607 + }, + "The global type 'JSX.{0}' may not have more than one property": { + "category": "Error", + "code": 2608 + }, + "JSX element implicitly has type 'any' because no interface JSX.{0} exists": { + "category": "Error", + "code": 2609 + }, + + "Cannot emit namespaced JSX elements in React": { + "category": "Error", + "code": 2650 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -1914,7 +1960,7 @@ "category": "Error", "code": 5050 }, - "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { + "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, @@ -2107,14 +2153,22 @@ "category": "Message", "code": 6060 }, - "NEWLINE": { - "category": "Message", + "NEWLINE": { + "category": "Message", "code": 6061 }, "Argument for '--newLine' option must be 'CRLF' or 'LF'.": { - "category": "Error", + "category": "Error", "code": 6062 }, + "Specifies how to transform JSX syntax during compilation.": { + "category": "Message", + "code": 6080 + }, + "Argument for --jsx must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { "category": "Error", "code": 6064 @@ -2268,5 +2322,29 @@ "'class' expressions are not currently supported.": { "category": "Error", "code": 9003 + }, + "'class' declarations are only supported directly inside a module or as a top level declaration.": { + "category": "Error", + "code": 9004 + }, + "JSX attributes must only be assigned a non-empty 'expression'.": { + "category": "Error", + "code": 17000 + }, + "JSX elements cannot have multiple attributes with the same name.": { + "category": "Error", + "code": 17001 + }, + "Expected corresponding JSX closing tag for '{0}'.": { + "category": "Error", + "code": 17002 + }, + "JSX attribute expected.": { + "category": "Error", + "code": 17003 + }, + "Cannot use JSX unless the '--jsx' flag is provided.": { + "category": "Error", + "code": 17004 } } From 195db034f8ebaf8d709acba295876f06d81a8ce9 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:01:42 -0700 Subject: [PATCH 096/250] Checker work for JSX + As --- src/compiler/checker.ts | 550 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 527 insertions(+), 23 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 68a0916f74332..3ee4b57b44a87 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -74,6 +74,9 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + + getJsxElementAttributesType, + getJsxIntrinsicTagNames }; let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); @@ -113,6 +116,8 @@ namespace ts { let globalRegExpType: ObjectType; let globalTemplateStringsArrayType: ObjectType; let globalESSymbolType: ObjectType; + let jsxElementType: ObjectType; + let jsxIntrinsicElementsType: ObjectType; let globalIterableType: GenericType; let globalIteratorType: GenericType; let globalIterableIteratorType: GenericType; @@ -159,6 +164,14 @@ namespace ts { } }; + let JsxNames = { + JSX: 'JSX', + IntrinsicElements: 'IntrinsicElements', + ElementClass: 'ElementClass', + ElementAttributesPropertyNameContainer: 'ElementAttributesProperty', + Element: 'Element' + }; + let subtypeRelation: Map = {}; let assignableRelation: Map = {}; let identityRelation: Map = {}; @@ -1986,7 +1999,7 @@ namespace ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -3762,6 +3775,12 @@ namespace ts { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function getExportedTypeOfNamespace(namespace: string, name: string): Type { + var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + return (typeSymbol && getDeclaredTypeOfSymbol(typeSymbol)) || unknownType; + } + function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -4249,8 +4268,8 @@ namespace ts { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage): boolean { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); + function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source: Signature, target: Signature): boolean { @@ -5505,6 +5524,7 @@ namespace ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.DeleteExpression: @@ -5531,6 +5551,11 @@ namespace ts { case SyntaxKind.ThrowStatement: case SyntaxKind.TryStatement: case SyntaxKind.CatchClause: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.JsxOpeningElement: return forEachChild(node, isAssignedIn); } return false; @@ -6297,6 +6322,26 @@ namespace ts { return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr: JsxExpression|JsxSpreadAttribute): Type { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === SyntaxKind.JsxAttribute) { + let attrib = expr.parent; + let attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + else if (expr.kind === SyntaxKind.JsxSpreadAttribute) { + return getJsxElementAttributesType(expr.parent); + } + else { + return undefined; + } + } + // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node: Expression): Type { @@ -6324,7 +6369,8 @@ namespace ts { case SyntaxKind.NewExpression: return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: - return getTypeFromTypeNode((parent).type); + case SyntaxKind.AsExpression: + return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node); case SyntaxKind.PropertyAssignment: @@ -6338,6 +6384,9 @@ namespace ts { return getContextualTypeForSubstitutionExpression(parent.parent, node); case SyntaxKind.ParenthesizedExpression: return getContextualType(parent); + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxSpreadAttribute: + return getContextualTypeForJsxExpression(parent); } return undefined; } @@ -6478,7 +6527,6 @@ namespace ts { let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); - if (restElementType) { elementTypes.push(restElementType); } @@ -6638,6 +6686,412 @@ namespace ts { } } + + function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { + checkJsxOpeningLikeElement(node); + return jsxElementType; + } + + function checkJsxElement(node: JsxElement) { + // Check that the closing tag matches + let expectedClosingTag = getTextOfNode(node.openingElement.tagName); + if (expectedClosingTag !== getTextOfNode(node.closingElement.tagName)) { + error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, expectedClosingTag); + } + + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + + // Check children + for (var i = 0, n = node.children.length; i < n; i++) { + if (node.children[i].kind === SyntaxKind.JsxExpression) { + checkJsxExpression(node.children[i]); + } + else if (node.children[i].kind === SyntaxKind.JsxElement) { + checkJsxElement(node.children[i]); + } + else if (node.children[i].kind === SyntaxKind.JsxSelfClosingElement) { + checkJsxSelfClosingElement(node.children[i]); + } + else { + // No checks for JSX Text + Debug.assert(node.children[i].kind === SyntaxKind.JsxText); + } + } + + return jsxElementType; + } + + /// Returns true iff the JSX element name would be a valid identifier, ignoring restrictions about keywords not being identifiers + function isIdentifierLike(name: string) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf('-') < 0; + } + + /// Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + function isJsxIntrinsicIdentifier(tagName: Identifier|QualifiedName) { + if (tagName.kind === SyntaxKind.QualifiedName) { + return false; + } + else { + let firstChar = (tagName).text.charAt(0); + return firstChar.toLowerCase() === firstChar; + } + } + + function checkJsxAttribute(node: JsxAttribute, elementAttributesType: Type, nameTable: Map) { + var correspondingPropType: Type = undefined; + + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isIdentifierLike(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (!correspondingPropType) { + // If there's no corresponding property with this name, error + if (isIdentifierLike(node.name.text)) { + error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + } + + let exprType: Type; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + + nameTable[node.name.text] = true; + return exprType; + } + + function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { + let type = checkExpression(node.expression); + let props = getPropertiesOfType(type); + for (var i = 0; i < props.length; i++) { + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[props[i].name]) { + let targetPropSym = getPropertyOfType(elementAttributesType, props[i].name); + if (targetPropSym) { + let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, props[i].name); + checkTypeAssignableTo(getTypeOfSymbol(props[i]), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + + nameTable[props[i].name] = true; + } + } + } + + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, undefined); + let intrinsicsSymbol = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.IntrinsicElements, SymbolFlags.Type); + let intrinsicsType = intrinsicsSymbol && getDeclaredTypeOfSymbol(intrinsicsSymbol); + jsxIntrinsicElementsType = intrinsicsType || unknownType; + } + return jsxIntrinsicElementsType; + } + + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node: JsxOpeningLikeElement): Symbol { + let flags: JsxFlags = JsxFlags.UnknownElement; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + + function lookupIntrinsicTag(node: JsxOpeningLikeElement): Symbol { + let intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + let intrinsicProp = getPropertyOfType(intrinsicElementsType, getTextOfNode(node.tagName)); + if (intrinsicProp) { + links.jsxFlags |= JsxFlags.IntrinsicNamedElement; + return intrinsicProp; + } + + // Intrinsic string indexer case + let indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); + if (indexSignatureType) { + links.jsxFlags |= JsxFlags.IntrinsicIndexedElement; + return intrinsicElementsType.symbol; + } + + // Wasn't found + error(node, Diagnostics.Property_0_does_not_exist_on_type_1, getTextOfNode(node.tagName), 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + + function lookupClassTag(node: JsxOpeningLikeElement): Symbol { + let valueSym: Symbol; + + // Look up the value in the current scope + if (node.tagName.kind === SyntaxKind.Identifier) { + valueSym = getResolvedSymbol(node.tagName); + } + else { + valueSym = checkQualifiedName(node.tagName).symbol; + } + + if (valueSym !== unknownSymbol) { + links.jsxFlags |= JsxFlags.ClassElement; + } + + return valueSym || unknownSymbol; + } + } + + /// Given a JSX element that is a class element, finds the Element Instance Type. If the + /// element is not a class element, or the class element type cannot be determined, returns 'undefined'. + /// For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + function getJsxElementInstanceType(node: JsxOpeningLikeElement) { + if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) { + // There is no such thing as an instance type for a non-class element + return undefined; + } + + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + + // Resolve the signatures, preferring constructors + var signatures = getSignaturesOfType(valueType, SignatureKind.Construct); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, SignatureKind.Call); + } + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, Diagnostics.JSX_element_0_is_not_a_constructor_function, getTextOfNode(node.tagName)); + return undefined; + } + + else { + // Check that the constructor/factory returns an object type + var returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); + if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + + // Issue an error if this return type isn't assignable to JSX.ElementClass + // TODO: Move this to a 'check' function + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_0_is_not_a_constructor_function_for_JSX_elements); + } + + return returnType; + } + } + + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means all + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined); + // JSX.ElementAttributesProperty [symbol] + let attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type); + // JSX.ElementAttributesProperty [type] + let attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + let attribProperties = attribPropType && getPropertiesOfType(attribPropType); + + if (attribProperties) { + if (attribProperties.length === 0) { + return ''; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + return undefined; + } + } + + /// Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + /// us which attributes are valid on a given element. + function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { + let links = getNodeLinks(node); + if (!links.resolvedType) { + let sym = getJsxElementTagSymbol(node); + + if (links.jsxFlags & JsxFlags.ClassElement) { + let elemInstanceType = getJsxElementInstanceType(node); + + if (isTypeAny(elemInstanceType)) { + return links.resolvedType = anyType; + } + + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedType = anyType; + } + else if (propsName === '') { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedType = attributesType; + } + else if (!(attributesType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedType = anyType; + } + else { + return links.resolvedType = attributesType; + } + } + } + else if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) { + return links.resolvedType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) { + return links.resolvedType = getIndexTypeOfSymbol(sym, IndexKind.String); + } + else { + // Resolution failed + return links.resolvedType = anyType; + } + } + + return links.resolvedType; + } + + /// Given a JSX attribute, returns the symbol for the corresponds property + /// of the element attributes type. Will return unknownSymbol for attributes + /// that have no matching element attributes type property. + function getJsxAttributePropertySymbol(attrib: JsxAttribute): Symbol { + let attributesType = getJsxElementAttributesType(attrib.parent); + let prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + + function getJsxGlobalElementClassType(): Type { + var jsxNS = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + if (jsxNS) { + let sym = getSymbol(jsxNS.exports, JsxNames.ElementClass, SymbolFlags.Type); + let elemClassType = sym && getDeclaredTypeOfSymbol(sym); + return elemClassType; + } + else { + return undefined; + } + } + + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames(): Symbol[] { + let intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + + function checkJsxPreconditions(errorNode: Node) { + // Preconditions for using JSX + if ((compilerOptions.jsx || JsxEmit.None) === JsxEmit.None) { + error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + + if (jsxElementType === unknownType) { + error(errorNode, Diagnostics.The_global_type_JSX_Element_must_exist_when_using_JSX); + } + } + + function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + + var targetAttributesType = getJsxElementAttributesType(node); + + var nameTable: Map = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === SyntaxKind.JsxAttribute) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); + checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + } + + // Check that all required properties have been provided + if (targetAttributesType) { + let targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & SymbolFlags.Optional) && + nameTable[targetProperties[i].name] === undefined) { + + error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + + function checkJsxExpression(node: JsxExpression) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + /// is shorthand for + return booleanType; + } + } + // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s: Symbol) { @@ -7361,7 +7815,7 @@ namespace ts { if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - + let candidate: Signature; let typeArgumentsAreValid: boolean; let inferenceContext = originalCandidate.typeParameters @@ -7618,7 +8072,7 @@ namespace ts { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node: TypeAssertion): Type { + function checkAssertion(node: AssertionExpression) { let exprType = checkExpression(node.expression); let targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -7791,7 +8245,6 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - // Grammar checking let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { @@ -8275,7 +8728,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -8303,8 +8756,8 @@ namespace ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { let 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; @@ -8559,8 +9012,6 @@ namespace ts { return checkCallExpression(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertionExpression: - return checkTypeAssertion(node); case SyntaxKind.ParenthesizedExpression: return checkExpression((node).expression, contextualMapper); case SyntaxKind.ClassExpression: @@ -8570,6 +9021,9 @@ namespace ts { return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + return checkAssertion(node); case SyntaxKind.DeleteExpression: return checkDeleteExpression(node); case SyntaxKind.VoidExpression: @@ -8588,6 +9042,14 @@ namespace ts { return undefinedType; case SyntaxKind.YieldExpression: return checkYieldExpression(node); + case SyntaxKind.JsxExpression: + return checkJsxExpression(node); + case SyntaxKind.JsxElement: + return checkJsxElement(node); + case SyntaxKind.JsxSelfClosingElement: + return checkJsxSelfClosingElement(node); + case SyntaxKind.JsxOpeningElement: + Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -9483,7 +9945,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // fall-through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -10060,7 +10522,7 @@ namespace ts { if (allowStringInput) { return checkElementTypeOfArrayOrString(inputType, errorNode); } - + if (isArrayLikeType(inputType)) { let indexType = getIndexTypeOfType(inputType, IndexKind.Number); if (indexType) { @@ -11145,7 +11607,7 @@ namespace ts { // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); + let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= NodeCheckFlags.LexicalModuleMergesWithClass; @@ -11569,6 +12031,7 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.TemplateSpan: case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: @@ -11606,6 +12069,12 @@ namespace ts { case SyntaxKind.EnumMember: case SyntaxKind.ExportAssignment: case SyntaxKind.SourceFile: + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.JsxOpeningElement: forEachChild(node, checkFunctionExpressionBodies); break; } @@ -11890,6 +12359,9 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === SyntaxKind.JsxOpeningElement) || (entityName.parent.kind === SyntaxKind.JsxSelfClosingElement)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (isExpression(entityName)) { if (nodeIsMissing(entityName)) { // Missing entity name. @@ -11924,6 +12396,9 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } + else if (entityName.parent.kind === SyntaxKind.JsxAttribute) { + return getJsxAttributePropertySymbol(entityName.parent); + } // Do we want to return undefined here? return undefined; @@ -12051,6 +12526,7 @@ namespace ts { return unknownType; } + function getTypeOfExpression(expr: Expression): Type { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; @@ -12381,7 +12857,7 @@ namespace ts { break; } } - + return "Object"; } @@ -12507,7 +12983,7 @@ namespace ts { let isVariableDeclarationOrBindingElement = n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n); - let symbol = + let symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -12535,7 +13011,7 @@ namespace ts { if (!signature) { return unknownType; } - + let instantiatedSignature = getSignatureInstantiation(signature, typeArguments); return getOrCreateTypeFromSignature(instantiatedSignature); } @@ -12594,6 +13070,7 @@ namespace ts { globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeOfNamespace("JSX", JsxNames.Element); getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); @@ -12626,7 +13103,6 @@ namespace ts { } // GRAMMAR CHECKING - function checkGrammarDecorators(node: Node): boolean { if (!node.decorators) { return false; @@ -13078,13 +13554,13 @@ namespace ts { let currentKind: number; if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { // Grammar checking for computedPropertName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if ( prop.kind === SyntaxKind.MethodDeclaration) { + else if (prop.kind === SyntaxKind.MethodDeclaration) { currentKind = Property; } else if (prop.kind === SyntaxKind.GetAccessor) { @@ -13120,6 +13596,29 @@ namespace ts { } } + function checkGrammarJsxElement(node: JsxOpeningElement|JsxSelfClosingElement) { + const seen: Map = {}; + for (let attr of node.attributes) { + if (attr.kind === SyntaxKind.JsxSpreadAttribute) { + continue; + } + + let jsxAttr = (attr); + let name = jsxAttr.name; + if (!hasProperty(seen, name.text)) { + seen[name.text] = true; + } + else { + return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + + let initializer = jsxAttr.initializer; + if (initializer && initializer.kind === SyntaxKind.JsxExpression && !(initializer).expression) { + return grammarErrorOnNode(jsxAttr.initializer, Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInStatement | ForOfStatement): boolean { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; @@ -13348,7 +13847,7 @@ namespace ts { } } - let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); + let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -13496,6 +13995,11 @@ namespace ts { } } + function isEvalOrArgumentsIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && + ((node).text === "eval" || (node).text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { if (node.typeParameters) { return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); From f5336db82ae301f8ac35d69d532270d051a76e81 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:01:49 -0700 Subject: [PATCH 097/250] Emitter for JSX --- src/compiler/emitter.ts | 325 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 310 insertions(+), 15 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 469b13294addf..265690cd68023 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -47,16 +47,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } };`; + let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; let newLine = host.getNewLine(); + let jsxDesugaring = host.getCompilerOptions().jsx === JsxEmit.React; if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, (!sourceFile.isTSXFile || jsxDesugaring) ? ".js" : ".jsx"); emitFile(jsFilePath, sourceFile); } }); @@ -68,7 +70,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, (host.getSourceFiles().every(f => !f.isTSXFile) || jsxDesugaring) ? ".js" : ".jsx"); emitFile(jsFilePath, targetSourceFile); } else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -1106,6 +1108,203 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(span.literal); } + function jsxEmitReact(node: JsxElement|JsxSelfClosingElement) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name: Identifier|QualifiedName) { + if (name.kind === SyntaxKind.Identifier) { + var ch = (name).text.charAt(0); + if (ch.toUpperCase() === ch) { + emit(name); + } + else { + write('"'); + emit(name); + write('"'); + } + return ch.toUpperCase() !== ch; + } + else { + Debug.assert(name.kind === SyntaxKind.QualifiedName); + emit(name); + } + } + + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name: Identifier) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node: JsxAttribute) { + emitAttributeName(node.name); + write(': '); + emit(node.initializer); + } + + function emitJsxElement(openingNode: JsxOpeningElement|JsxSelfClosingElement, children?: JsxChild[]) { + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + write('React.createElement('); + emitTagName(openingNode.tagName); + write(', '); + + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants 'null' + write('null'); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + let attrs = openingNode.attributes; + if (attrs.some(attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { + write('React.__spread('); + + let haveOpenedObjectLiteral = false; + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { + if (haveOpenedObjectLiteral) { + write('}'); + haveOpenedObjectLiteral = false; + } + if (i > 0) write(', '); + emit((attrs[i]).expression); + } + else { + Debug.assert(attrs[i].kind === SyntaxKind.JsxAttribute); + if (haveOpenedObjectLiteral) { + write(', '); + } + else { + haveOpenedObjectLiteral = true; + if (i > 0) write(', '); + write('{'); + } + emitJsxAttribute(attrs[i]); + } + } + if (haveOpenedObjectLiteral) write('}'); + + write(')'); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write('{'); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) write(', '); + emitJsxAttribute(attrs[i]); + } + write('}'); + } + } + + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === SyntaxKind.JsxExpression && !((children[i]).expression)) continue; + + // Don't emit empty strings + if (children[i].kind === SyntaxKind.JsxText && !shouldEmitJsxText(children[i])) continue; + + write(', '); + emit(children[i]); + } + } + + // Closing paren + write(')'); // closes 'React.createElement(' + emitTrailingComments(openingNode); + } + + if (node.kind === SyntaxKind.JsxElement) { + emitJsxElement((node).openingElement, (node).children); + } + else { + Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement); + emitJsxElement(node); + } + } + + function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { + function emitJsxAttribute(node: JsxAttribute) { + emit(node.name); + write('='); + emit(node.initializer); + } + + function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { + write('{...'); + emit(node.expression); + write('}'); + } + + function emitAttributes(attribs: NodeArray) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) write(' '); + + if (attribs[i].kind === SyntaxKind.JsxSpreadAttribute) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + Debug.assert(attribs[i].kind === SyntaxKind.JsxAttribute); + emitJsxAttribute(attribs[i]); + } + } + } + + function emitJsxOpeningOrSelfClosingElement(node: JsxOpeningElement|JsxSelfClosingElement) { + write('<'); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === SyntaxKind.JsxSelfClosingElement)) { + write(' '); + } + + emitAttributes(node.attributes); + + if (node.kind === SyntaxKind.JsxSelfClosingElement) { + write('/>'); + } + else { + write('>'); + } + } + + function emitJsxClosingElement(node: JsxClosingElement) { + write(''); + } + + function emitJsxElement(node: JsxElement) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + + emitJsxClosingElement(node.closingElement); + } + + if (node.kind === SyntaxKind.JsxElement) { + emitJsxElement(node); + } + else { + Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. @@ -1182,6 +1381,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.IfStatement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: case SyntaxKind.NewExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PostfixUnaryExpression: @@ -1658,8 +1859,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function parenthesizeForAccess(expr: Expression): LeftHandSideExpression { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === SyntaxKind.TypeAssertionExpression) { - expr = (expr).expression; + while (expr.kind === SyntaxKind.TypeAssertionExpression || expr.kind === SyntaxKind.AsExpression) { + expr = (expr).expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -1805,8 +2006,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function skipParentheses(node: Expression): Expression { - while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression) { - node = (node).expression; + while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression) { + node = (node).expression; } return node; } @@ -1956,12 +2157,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // not the user. If we didn't want them, the emitter would not have put them // there. if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) { - if (node.expression.kind === SyntaxKind.TypeAssertionExpression) { + if (node.expression.kind === SyntaxKind.TypeAssertionExpression || node.expression.kind === SyntaxKind.AsExpression) { let operand = (node.expression).expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === SyntaxKind.TypeAssertionExpression) { + while (operand.kind === SyntaxKind.TypeAssertionExpression || operand.kind === SyntaxKind.AsExpression) { operand = (operand).expression; } @@ -3807,7 +4008,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitClassLikeDeclarationForES6AndHigher(node); } } - + function emitClassLikeDeclarationForES6AndHigher(node: ClassLikeDeclaration) { let thisNodeIsDecorated = nodeIsDecorated(node); if (node.kind === SyntaxKind.ClassDeclaration) { @@ -4066,7 +4267,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(".prototype"); } } - + function emitDecoratorsOfClass(node: ClassLikeDeclaration) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, NodeFlags.Static); @@ -4978,7 +5179,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let started = false; for (let importNode of externalImports) { // do not create variable declaration for exports and imports that lack import clause - let skipNode = + let skipNode = importNode.kind === SyntaxKind.ExportDeclaration || (importNode.kind === SyntaxKind.ImportDeclaration && !(importNode).importClause) @@ -5075,7 +5276,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("};"); return emitExportStarFunction(exportedNamesStorageRef); - + function emitExportStarFunction(localNames: string): string { const exportStarFunction = makeUniqueName("exportStar"); @@ -5102,7 +5303,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return exportStarFunction; } - + function writeExportedName(node: Identifier | Declaration): void { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export @@ -5398,7 +5599,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (importNode.kind === SyntaxKind.ImportDeclaration && (importNode).importClause.namedBindings) { - + let namedBindings = (importNode).importClause.namedBindings; if (namedBindings.kind === SyntaxKind.NamespaceImport) { // emit re-export for namespace @@ -5657,6 +5858,91 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } + function emitJsxElement(node: JsxElement|JsxSelfClosingElement) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + jsxEmitReact(node); + break; + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + + function trimReactWhitespace(node: JsxText): string { + // Could be empty string, do not use !node.formattedReactText + if (node.formattedReactText !== undefined) { + return node.formattedReactText; + } + + let lines: string[] = []; + let text = getTextOfNode(node); + let firstNonWhitespace = 0; + let lastNonWhitespace = -1; + + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (c === CharacterCodes.lineFeed || c === CharacterCodes.carriageReturn) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + lines.push(text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); + } + firstNonWhitespace = -1; + } + else if (!isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + lines.push(text.substr(firstNonWhitespace)); + } + + return node.formattedReactText = lines.join('" + \' \' + "'); + } + + function shouldEmitJsxText(node: JsxText) { + if (compilerOptions.jsx === JsxEmit.React) { + return trimReactWhitespace(node).length > 0; + } + else { + return true; + } + } + + function emitJsxText(node: JsxText) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + write('"'); + write(trimReactWhitespace(node)); + write('"'); + break; + + case JsxEmit.Preserve: + default: // Emit JSX-preserve as default when no --jsx flag is specified + write(getTextOfNode(node, true)); + break; + } + } + + function emitJsxExpression(node: JsxExpression) { + if (node.expression && node.expression.kind !== SyntaxKind.OmittedExpression) { + switch (compilerOptions.jsx) { + case JsxEmit.Preserve: + default: + write('{'); + emit(node.expression); + write('}'); + break; + case JsxEmit.React: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements: Node[], startWithNewLine: boolean): number { for (let i = 0; i < statements.length; ++i) { if (isPrologueDirective(statements[i])) { @@ -5799,7 +6085,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (node.kind !== SyntaxKind.Block && node.parent && node.parent.kind === SyntaxKind.ArrowFunction && - (node.parent).body === node && + (node.parent).body === node && compilerOptions.target <= ScriptTarget.ES5) { return false; @@ -5844,6 +6130,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTemplateExpression(node); case SyntaxKind.TemplateSpan: return emitTemplateSpan(node); + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + return emitJsxElement(node); + case SyntaxKind.JsxText: + return emitJsxText(node); + case SyntaxKind.JsxExpression: + return emitJsxExpression(node); case SyntaxKind.QualifiedName: return emitQualifiedName(node); case SyntaxKind.ObjectBindingPattern: @@ -5874,6 +6167,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTaggedTemplateExpression(node); case SyntaxKind.TypeAssertionExpression: return emit((node).expression); + case SyntaxKind.AsExpression: + return emit((node).expression); case SyntaxKind.ParenthesizedExpression: return emitParenExpression(node); case SyntaxKind.FunctionDeclaration: From 6d01a44be05f71730c6c5701dc2796a36a7627e3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:02:02 -0700 Subject: [PATCH 098/250] Formatting and LS for JSX and As --- src/services/formatting/rules.ts | 1 + src/services/formatting/tokenRange.ts | 2 +- src/services/services.ts | 197 ++++++++++++++++---------- 3 files changed, 125 insertions(+), 75 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index abb08f5bf22bf..8c20bab92adb9 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -470,6 +470,7 @@ namespace ts.formatting { switch (context.contextNode.kind) { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: + case SyntaxKind.AsExpression: case SyntaxKind.TypePredicate: return true; diff --git a/src/services/formatting/tokenRange.ts b/src/services/formatting/tokenRange.ts index 3391365f32830..19185cdf78d3f 100644 --- a/src/services/formatting/tokenRange.ts +++ b/src/services/formatting/tokenRange.ts @@ -112,7 +112,7 @@ namespace ts.formatting { static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia])); static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword); static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator); - static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.IsKeyword]); + static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]); static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]); static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); diff --git a/src/services/services.ts b/src/services/services.ts index 70022cfe0bf47..7e1aba31d540e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -198,8 +198,8 @@ namespace ts { list._children = []; let pos = nodes.pos; - - + + for (let node of nodes) { if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); @@ -737,6 +737,7 @@ namespace ts { public amdDependencies: { name: string; path: string }[]; public moduleName: string; public referencedFiles: FileReference[]; + public isTSXFile: boolean; public syntacticDiagnostics: Diagnostic[]; public referenceDiagnostics: Diagnostic[]; @@ -875,7 +876,7 @@ namespace ts { case SyntaxKind.SetAccessor: case SyntaxKind.TypeLiteral: addDeclaration(node); - // fall through + // fall through case SyntaxKind.Constructor: case SyntaxKind.VariableStatement: case SyntaxKind.VariableDeclarationList: @@ -1095,7 +1096,7 @@ namespace ts { export const definition = "definition"; export const reference = "reference"; export const writtenReference = "writtenReference"; - } + } export interface HighlightSpan { textSpan: TextSpan; @@ -1610,6 +1611,7 @@ namespace ts { return { target: ScriptTarget.ES5, module: ModuleKind.None, + jsx: JsxEmit.Preserve }; } @@ -2895,11 +2897,18 @@ namespace ts { return undefined; } + let location = getTouchingPropertyName(sourceFile, position); + let options = program.getCompilerOptions(); + let jsx = options.jsx !== JsxEmit.None; + let target = options.target; + // Find the node where completion is requested on, in the case of a completion after // a dot, it is the member access expression other wise, it is a request for all // visible symbols in the scope, and the node is the current location. let node = currentToken; let isRightOfDot = false; + let isRightOfOpenTag = false; + if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { node = (contextToken.parent).expression; isRightOfDot = true; @@ -2907,11 +2916,11 @@ namespace ts { else if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { node = (contextToken.parent).left; isRightOfDot = true; + } else if (contextToken && contextToken.kind === SyntaxKind.LessThanToken && sourceFile.isTSXFile) { + isRightOfOpenTag = true; + location = contextToken; } - let location = getTouchingPropertyName(sourceFile, position); - var target = program.getCompilerOptions().target; - let semanticStart = new Date().getTime(); let isMemberCompletion: boolean; let isNewIdentifierLocation: boolean; @@ -2920,6 +2929,17 @@ namespace ts { if (isRightOfDot) { getTypeScriptMemberSymbols(); } + else if (isRightOfOpenTag) { + // TODO include all in-scope value identifiers + let tagSymbols = typeChecker.getJsxIntrinsicTagNames();; + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & SymbolFlags.Value))); + } else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -2931,7 +2951,7 @@ namespace ts { log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -2986,6 +3006,7 @@ namespace ts { function tryGetGlobalSymbols(): boolean { let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); + let jsxElement: JsxElement, jsxSelfClosingElement: JsxSelfClosingElement; if (containingObjectLiteral) { // Object literal expression, look up possible property names from contextual type isMemberCompletion = true; @@ -3001,6 +3022,7 @@ namespace ts { // Add filtered items to the completion list symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } + return true; } else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { // cursor is in import clause @@ -3022,51 +3044,77 @@ namespace ts { //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; } + return true; } - else { - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - - if (previousToken !== contextToken) { - Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - let adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - - let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + else if (getAncestor(contextToken, SyntaxKind.JsxElement) || getAncestor(contextToken, SyntaxKind.JsxSelfClosingElement)) { + // Go up until we hit either the element or expression + let jsxNode = contextToken; - /// TODO filter meaning based on the current context - let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + while (jsxNode) { + if (jsxNode.kind === SyntaxKind.JsxExpression) { + // Defer to global completion if we're inside an {expression} + break; + } else if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement || jsxNode.kind === SyntaxKind.JsxElement) { + let attrsType: Type; + if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement) { + // Cursor is inside a JSX self-closing element + attrsType = typeChecker.getJsxElementAttributesType(jsxNode); + } + else { + Debug.assert(jsxNode.kind === SyntaxKind.JsxElement); + // Cursor is inside a JSX element + attrsType = typeChecker.getJsxElementAttributesType((jsxNode).openingElement); + } + symbols = typeChecker.getPropertiesOfType(attrsType); + isMemberCompletion = true; + return true; + } + jsxNode = jsxNode.parent; + } } + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + + if (previousToken !== contextToken) { + Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + let adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + + let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + + /// TODO filter meaning based on the current context + let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; } @@ -4200,7 +4248,7 @@ namespace ts { function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { let results = getOccurrencesAtPositionCore(fileName, position); - + if (results) { let sourceFile = getCanonicalFileName(normalizeSlashes(fileName)); @@ -4869,7 +4917,7 @@ namespace ts { return convertReferences(referencedSymbols); } - function findReferences(fileName: string, position: number): ReferencedSymbol[]{ + function findReferences(fileName: string, position: number): ReferencedSymbol[] { var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. @@ -5804,7 +5852,7 @@ namespace ts { } function isTypeReference(node: Node): boolean { - if (isRightSideOfQualifiedNameOrPropertyAccess(node) ) { + if (isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } @@ -5973,13 +6021,13 @@ namespace ts { return BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } - function getNavigationBarItems(fileName: string): NavigationBarItem[]{ + function getNavigationBarItems(fileName: string): NavigationBarItem[] { let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); return NavigationBar.getNavigationBarItems(sourceFile); } - function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } @@ -6108,7 +6156,7 @@ namespace ts { return result; } - function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); } @@ -6471,14 +6519,14 @@ namespace ts { function getMatchingTokenKind(token: Node): ts.SyntaxKind { switch (token.kind) { - case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken - case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken; - case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken; - case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken; - case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken - case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken; - case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken; - case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken; + case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken + case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken; + case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken; + case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken; + case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken + case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken; + case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken; + case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken; } return undefined; @@ -6693,6 +6741,7 @@ namespace ts { if (defaultLibFileName) { for (let current of declarations) { let sourceFile = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); if (sourceFile && getCanonicalFileName(ts.normalizePath(sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } @@ -6921,7 +6970,7 @@ namespace ts { case ClassificationType.stringLiteral: return TokenClass.StringLiteral; case ClassificationType.whiteSpace: return TokenClass.Whitespace; case ClassificationType.punctuation: return TokenClass.Punctuation; - case ClassificationType.identifier: + case ClassificationType.identifier: case ClassificationType.className: case ClassificationType.enumName: case ClassificationType.interfaceName: @@ -6976,7 +7025,7 @@ namespace ts { case EndOfLineState.InTemplateMiddleOrTail: text = "}\n" + text; offset = 2; - // fallthrough + // fallthrough case EndOfLineState.InTemplateSubstitutionPosition: templateStack.push(SyntaxKind.TemplateHead); break; @@ -7015,9 +7064,9 @@ namespace ts { if (!isTrivia(token)) { if ((token === SyntaxKind.SlashToken || token === SyntaxKind.SlashEqualsToken) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { - token = SyntaxKind.RegularExpressionLiteral; - } + if (scanner.reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { + token = SyntaxKind.RegularExpressionLiteral; + } } else if (lastNonTriviaToken === SyntaxKind.DotToken && isKeyword(token)) { token = SyntaxKind.Identifier; @@ -7030,7 +7079,7 @@ namespace ts { token = SyntaxKind.Identifier; } else if (lastNonTriviaToken === SyntaxKind.Identifier && - token === SyntaxKind.LessThanToken) { + token === SyntaxKind.LessThanToken) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; @@ -7041,10 +7090,10 @@ namespace ts { angleBracketStack--; } else if (token === SyntaxKind.AnyKeyword || - token === SyntaxKind.StringKeyword || - token === SyntaxKind.NumberKeyword || - token === SyntaxKind.BooleanKeyword || - token === SyntaxKind.SymbolKeyword) { + token === SyntaxKind.StringKeyword || + token === SyntaxKind.NumberKeyword || + token === SyntaxKind.BooleanKeyword || + token === SyntaxKind.SymbolKeyword) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -7280,7 +7329,7 @@ namespace ts { declare let __dirname: string; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ From e34d8cdccbd127e9e99b93960db4afafaa61e246 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:02:22 -0700 Subject: [PATCH 099/250] Test support for TSX files --- src/harness/compilerRunner.ts | 16 ++++++++-------- src/harness/harness.ts | 33 ++++++++++++++++++++++++++++----- src/harness/runnerbase.ts | 2 +- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 21e88b9e41aa4..1b399e1b70635 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -149,7 +149,7 @@ class CompilerBaselineRunner extends RunnerBase { // check errors it('Correct errors for ' + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => { + Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.tsx?$/, '.errors.txt'), (): string => { if (result.errors.length === 0) return null; return getErrorBaseline(toBeCompiled, otherFiles, result); }); @@ -159,7 +159,7 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it('Correct sourcemap content for ' + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { - Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => { + Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.tsx?$/, '.sourcemap.txt'), () => { var record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. @@ -177,7 +177,7 @@ class CompilerBaselineRunner extends RunnerBase { } // check js output - Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.ts/, '.js'), () => { + Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.tsx?/, '.js'), () => { var tsCode = ''; var tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { @@ -235,7 +235,7 @@ class CompilerBaselineRunner extends RunnerBase { throw new Error('Number of sourcemap files should be same as js files.'); } - Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => { + Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.tsx?/, '.js.map'), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. // Baselining isn't required here because there is no output. @@ -320,11 +320,11 @@ class CompilerBaselineRunner extends RunnerBase { let pullExtension = isSymbolBaseLine ? '.symbols.pull' : '.types.pull'; if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.ts/, pullExtension), () => pullBaseLine); + Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); } else { - Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); } } @@ -391,7 +391,7 @@ class CompilerBaselineRunner extends RunnerBase { // this will set up a series of describe/it blocks to run between the setup and cleanup phases if (this.tests.length === 0) { - var testFiles = this.enumerateFiles(this.basePath, /\.ts$/, { recursive: true }); + var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); testFiles.forEach(fn => { fn = fn.replace(/\\/g, "/"); this.checkTestCodeOutput(fn); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6a55948815010..0ea7db33fe106 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -212,7 +212,7 @@ module Utils { } var result = ""; - ts.forEach(Object.getOwnPropertyNames(flags),(v: any) => { + ts.forEach(Object.getOwnPropertyNames(flags), (v: any) => { if (isFinite(v)) { v = +v; if (f === +v) { @@ -410,7 +410,7 @@ module Harness { deleteFile(fileName: string): void; listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; - getMemoryUsage? (): number; + getMemoryUsage?(): number; } module IOImpl { @@ -794,7 +794,7 @@ module Harness { public reset() { this.fileCollection = {}; } - public toArray(): { fileName: string; file: WriterAggregator; }[]{ + public toArray(): { fileName: string; file: WriterAggregator; }[] { var result: { fileName: string; file: WriterAggregator; }[] = []; for (var p in this.fileCollection) { if (this.fileCollection.hasOwnProperty(p)) { @@ -1166,6 +1166,12 @@ module Harness { options.inlineSources = setting.value === 'true'; break; + case 'jsx': + options.jsx = setting.value.toLowerCase() === 'react' ? ts.JsxEmit.React : + setting.value.toLowerCase() === 'preserve' ? ts.JsxEmit.Preserve : + ts.JsxEmit.None; + break; + default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1229,7 +1235,7 @@ module Harness { } var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; - + return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); } @@ -1428,6 +1434,10 @@ module Harness { return stringEndsWith(fileName, '.ts'); } + export function isTSX(fileName: string) { + return stringEndsWith(fileName, '.tsx'); + } + export function isDTS(fileName: string) { return stringEndsWith(fileName, '.d.ts'); } @@ -1435,6 +1445,9 @@ module Harness { export function isJS(fileName: string) { return stringEndsWith(fileName, '.js'); } + export function isJSX(fileName: string) { + return stringEndsWith(fileName, '.jsx'); + } export function isJSMap(fileName: string) { return stringEndsWith(fileName, '.js.map'); @@ -1455,7 +1468,7 @@ module Harness { if (isDTS(emittedFile.fileName)) { // .d.ts file, add to declFiles emit this.declFilesCode.push(emittedFile); - } else if (isJS(emittedFile.fileName)) { + } else if (isJS(emittedFile.fileName) || isJSX(emittedFile.fileName)) { // .js file, add to files this.files.push(emittedFile); } else if (isJSMap(emittedFile.fileName)) { @@ -1495,6 +1508,16 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines + // List of allowed metadata names + var fileMetadataNames = ["filename", "comments", "declaration", "module", + "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", + "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", + "errortruncation", "usecasesensitivefilenames", "preserveconstenums", + "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", + "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", + "inlinesources", "emitdecoratormetadata", "experimentaldecorators", + "skipdefaultlibcheck", "jsx"]; + function extractCompilerSettings(content: string): CompilerSetting[] { var opts: CompilerSetting[] = []; diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 269e889704c87..fa8d9d2c59759 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -27,7 +27,7 @@ class RunnerBase { var fixedPath = path; // full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point - var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.ts/g; + var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; var fullPathList = fixedPath.match(fullPath); if (fullPathList) { fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match))); From fa198a5cef50c4767e39f0414a6db45abfc86ea4 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:02:47 -0700 Subject: [PATCH 100/250] Fourslash tests for JSX and As --- tests/cases/fourslash/asOperatorFormatting.ts | 7 +++++ .../fourslash/server/tsxIncrementalServer.ts | 13 +++++++++ tests/cases/fourslash/tsxCompletion1.ts | 14 +++++++++ tests/cases/fourslash/tsxCompletion2.ts | 15 ++++++++++ .../fourslash/tsxGoToDefinitionClasses.ts | 23 +++++++++++++++ .../fourslash/tsxGoToDefinitionIntrinsics.ts | 29 +++++++++++++++++++ tests/cases/fourslash/tsxIncremental.ts | 13 +++++++++ tests/cases/fourslash/tsxParsing.ts | 5 ++++ tests/cases/fourslash/tsxRename1.ts | 17 +++++++++++ tests/cases/fourslash/tsxRename2.ts | 17 +++++++++++ tests/cases/fourslash/tsxRename3.ts | 20 +++++++++++++ 11 files changed, 173 insertions(+) create mode 100644 tests/cases/fourslash/asOperatorFormatting.ts create mode 100644 tests/cases/fourslash/server/tsxIncrementalServer.ts create mode 100644 tests/cases/fourslash/tsxCompletion1.ts create mode 100644 tests/cases/fourslash/tsxCompletion2.ts create mode 100644 tests/cases/fourslash/tsxGoToDefinitionClasses.ts create mode 100644 tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts create mode 100644 tests/cases/fourslash/tsxIncremental.ts create mode 100644 tests/cases/fourslash/tsxParsing.ts create mode 100644 tests/cases/fourslash/tsxRename1.ts create mode 100644 tests/cases/fourslash/tsxRename2.ts create mode 100644 tests/cases/fourslash/tsxRename3.ts diff --git a/tests/cases/fourslash/asOperatorFormatting.ts b/tests/cases/fourslash/asOperatorFormatting.ts new file mode 100644 index 0000000000000..f697ffd8bb6c2 --- /dev/null +++ b/tests/cases/fourslash/asOperatorFormatting.ts @@ -0,0 +1,7 @@ +/// + +//// /**/var x = 3 as number; + +goTo.marker(); +format.document(); +verify.currentLineContentIs("var x = 3 as number;"); diff --git a/tests/cases/fourslash/server/tsxIncrementalServer.ts b/tests/cases/fourslash/server/tsxIncrementalServer.ts new file mode 100644 index 0000000000000..9ae51406c2fa8 --- /dev/null +++ b/tests/cases/fourslash/server/tsxIncrementalServer.ts @@ -0,0 +1,13 @@ +/// + +//// /**/ + +goTo.marker(); +edit.insert("<"); +edit.insert("div"); +edit.insert(" "); +edit.insert(" id"); +edit.insert("="); +edit.insert("\"foo"); +edit.insert("\""); +edit.insert(">"); diff --git a/tests/cases/fourslash/tsxCompletion1.ts b/tests/cases/fourslash/tsxCompletion1.ts new file mode 100644 index 0000000000000..f638b0b6e4fa8 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion1.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); diff --git a/tests/cases/fourslash/tsxCompletion2.ts b/tests/cases/fourslash/tsxCompletion2.ts new file mode 100644 index 0000000000000..d33f910687719 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion2.ts @@ -0,0 +1,15 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props; } +//// } +//// class MyComp { props: { ONE: string; TWO: number } } +//// var x = ; + +goTo.marker(); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); diff --git a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts new file mode 100644 index 0000000000000..11ff3afeb8ae3 --- /dev/null +++ b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts @@ -0,0 +1,23 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { } +//// interface ElementAttributesProperty { props; } +//// } +//// /*ct*/class MyClass { +//// props: { +//// /*pt*/foo: string; +//// } +//// } +//// var x = ; +//// var y = ; + +goTo.marker('c'); +goTo.definition(); +verify.caretAtMarker('ct'); + +goTo.marker('p'); +goTo.definition(); +verify.caretAtMarker('pt'); diff --git a/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts new file mode 100644 index 0000000000000..bbdf395e4789a --- /dev/null +++ b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts @@ -0,0 +1,29 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// /*dt*/div: { +//// /*pt*/name?: string; +//// isOpen?: boolean; +//// }; +//// /*st*/span: { n: string; }; +//// } +//// } +//// var x = ; +//// var y = ; +//// var z =
; + +goTo.marker('ds'); +goTo.definition(); +verify.caretAtMarker('dt'); + +goTo.marker('ss'); +goTo.definition(); +verify.caretAtMarker('st'); + +goTo.marker('ps'); +goTo.definition(); +verify.caretAtMarker('pt'); + diff --git a/tests/cases/fourslash/tsxIncremental.ts b/tests/cases/fourslash/tsxIncremental.ts new file mode 100644 index 0000000000000..c901401fff979 --- /dev/null +++ b/tests/cases/fourslash/tsxIncremental.ts @@ -0,0 +1,13 @@ +/// + +//// /**/ + +goTo.marker(); +edit.insert("<"); +edit.insert("div"); +edit.insert(" "); +edit.insert(" id"); +edit.insert("="); +edit.insert("\"foo"); +edit.insert("\""); +edit.insert(">"); diff --git a/tests/cases/fourslash/tsxParsing.ts b/tests/cases/fourslash/tsxParsing.ts new file mode 100644 index 0000000000000..e5b2e7ea841ae --- /dev/null +++ b/tests/cases/fourslash/tsxParsing.ts @@ -0,0 +1,5 @@ +//// var x =
; +//// var y = /**/x; + +goTo.marker(); +verify.quickInfoExists(); diff --git a/tests/cases/fourslash/tsxRename1.ts b/tests/cases/fourslash/tsxRename1.ts new file mode 100644 index 0000000000000..3fb973ec99621 --- /dev/null +++ b/tests/cases/fourslash/tsxRename1.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// [|div|]: { +//// name?: string; +//// isOpen?: boolean; +//// }; +//// span: { n: string; }; +//// } +//// } +//// var x = <[|di/*ds*/v|] />; + +goTo.marker('ds'); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename2.ts b/tests/cases/fourslash/tsxRename2.ts new file mode 100644 index 0000000000000..d0f5737214b96 --- /dev/null +++ b/tests/cases/fourslash/tsxRename2.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { +//// [|name|]?: string; +//// isOpen?: boolean; +//// }; +//// span: { n: string; }; +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename3.ts b/tests/cases/fourslash/tsxRename3.ts new file mode 100644 index 0000000000000..1ab9c8a591595 --- /dev/null +++ b/tests/cases/fourslash/tsxRename3.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// [|name|]?: string; +//// size?: number; +//// } +//// +//// +//// var x = ; + +goTo.marker(); +verify.renameLocations(false, false); From 2b44dcac4d3e5d40a0ad0f46d534ad26ba3050da Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:03:14 -0700 Subject: [PATCH 101/250] Conformance tests for 'as' operator --- .../conformance/expressions/asOperator/asOperator1.ts | 8 ++++++++ .../conformance/expressions/asOperator/asOperator2.ts | 1 + .../conformance/expressions/asOperator/asOperator3.ts | 10 ++++++++++ .../expressions/asOperator/asOperatorASI.ts | 10 ++++++++++ .../expressions/asOperator/asOperatorAmbiguity.ts | 8 ++++++++ .../expressions/asOperator/asOperatorContextualType.ts | 2 ++ .../expressions/asOperator/asOperatorNames.ts | 4 ++++ 7 files changed, 43 insertions(+) create mode 100644 tests/cases/conformance/expressions/asOperator/asOperator1.ts create mode 100644 tests/cases/conformance/expressions/asOperator/asOperator2.ts create mode 100644 tests/cases/conformance/expressions/asOperator/asOperator3.ts create mode 100644 tests/cases/conformance/expressions/asOperator/asOperatorASI.ts create mode 100644 tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts create mode 100644 tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts create mode 100644 tests/cases/conformance/expressions/asOperator/asOperatorNames.ts diff --git a/tests/cases/conformance/expressions/asOperator/asOperator1.ts b/tests/cases/conformance/expressions/asOperator/asOperator1.ts new file mode 100644 index 0000000000000..cf953d75ab46e --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator1.ts @@ -0,0 +1,8 @@ +var as = 43; +var x = undefined as number; +var y = (null as string).length; +var z = Date as any as string; + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +j = ''; diff --git a/tests/cases/conformance/expressions/asOperator/asOperator2.ts b/tests/cases/conformance/expressions/asOperator/asOperator2.ts new file mode 100644 index 0000000000000..1fa5f2c938d78 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator2.ts @@ -0,0 +1 @@ +var x = 23 as string; diff --git a/tests/cases/conformance/expressions/asOperator/asOperator3.ts b/tests/cases/conformance/expressions/asOperator/asOperator3.ts new file mode 100644 index 0000000000000..4c136247e001f --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator3.ts @@ -0,0 +1,10 @@ +declare function tag(...x: any[]): any; + +var a = `${123 + 456 as number}`; +var b = `leading ${123 + 456 as number}`; +var c = `${123 + 456 as number} trailing`; +var d = `Hello ${123} World` as string; +var e = `Hello` as string; +var f = 1 + `${1} end of string` as string; +var g = tag `Hello ${123} World` as string; +var h = tag `Hello` as string; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts b/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts new file mode 100644 index 0000000000000..a4dd44a15add1 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts @@ -0,0 +1,10 @@ +class Foo { } +declare function as(...args: any[]); + +// Example 1 +var x = 10 +as `Hello world`; // should not error + +// Example 2 +var y = 20 +as(Foo); // should emit diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts b/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts new file mode 100644 index 0000000000000..e4921314ba7e7 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts @@ -0,0 +1,8 @@ +interface A { x: T; } +interface B { m: string; } + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +var y = x as A[]; +var z = y[0].m; // z should be string + diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts b/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts new file mode 100644 index 0000000000000..d3a23e224ba3d --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts @@ -0,0 +1,2 @@ +// should error +var x = (v => v) as (x: number) => string; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts b/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts new file mode 100644 index 0000000000000..a0b54d43e8451 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts @@ -0,0 +1,4 @@ +var a = 20; +var b = a as string; +var as = "hello"; +var as1 = as as string; From bc9b53a6fe3ef8f6bcad049ec05270ec35626470 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:03:43 -0700 Subject: [PATCH 102/250] Conformance tests for JSX --- .../conformance/jsx/jsxAndTypeAssertion.tsx | 22 ++++ .../conformance/jsx/jsxEsprimaFbTestSuite.tsx | 54 ++++++++ .../jsx/jsxInvalidEsprimaTestSuite.tsx | 36 ++++++ .../conformance/jsx/jsxReactTestSuite.tsx | 117 ++++++++++++++++++ .../conformance/jsx/tsxAttributeErrors.tsx | 26 ++++ .../jsx/tsxAttributeInvalidNames.tsx | 12 ++ .../jsx/tsxAttributeResolution.tsx | 9 ++ .../jsx/tsxAttributeResolution1.jsx | 15 +++ .../jsx/tsxAttributeResolution1.tsx | 33 +++++ .../jsx/tsxAttributeResolution2.jsx | 5 + .../jsx/tsxAttributeResolution2.tsx | 19 +++ .../jsx/tsxAttributeResolution3.jsx | 21 ++++ .../jsx/tsxAttributeResolution3.tsx | 41 ++++++ .../jsx/tsxAttributeResolution4.jsx | 4 + .../jsx/tsxAttributeResolution4.tsx | 17 +++ .../jsx/tsxAttributeResolution5.jsx | 11 ++ .../jsx/tsxAttributeResolution5.tsx | 32 +++++ .../jsx/tsxAttributeResolution6.tsx | 19 +++ .../jsx/tsxAttributeResolution7.tsx | 16 +++ .../conformance/jsx/tsxElementResolution.tsx | 25 ++++ .../conformance/jsx/tsxElementResolution1.jsx | 4 + .../conformance/jsx/tsxElementResolution1.tsx | 14 +++ .../jsx/tsxElementResolution10.tsx | 21 ++++ .../jsx/tsxElementResolution11.jsx | 6 + .../jsx/tsxElementResolution11.tsx | 25 ++++ .../jsx/tsxElementResolution12.jsx | 9 ++ .../jsx/tsxElementResolution12.tsx | 32 +++++ .../jsx/tsxElementResolution13.jsx | 2 + .../jsx/tsxElementResolution13.tsx | 12 ++ .../jsx/tsxElementResolution14.jsx | 2 + .../jsx/tsxElementResolution14.tsx | 11 ++ .../jsx/tsxElementResolution15.jsx | 2 + .../jsx/tsxElementResolution15.tsx | 13 ++ .../jsx/tsxElementResolution16.jsx | 2 + .../jsx/tsxElementResolution16.tsx | 10 ++ .../jsx/tsxElementResolution17.tsx | 27 ++++ .../jsx/tsxElementResolution18.tsx | 9 ++ .../conformance/jsx/tsxElementResolution2.tsx | 14 +++ .../conformance/jsx/tsxElementResolution3.tsx | 14 +++ .../conformance/jsx/tsxElementResolution4.tsx | 18 +++ .../conformance/jsx/tsxElementResolution5.tsx | 8 ++ .../conformance/jsx/tsxElementResolution6.tsx | 10 ++ .../conformance/jsx/tsxElementResolution7.jsx | 14 +++ .../conformance/jsx/tsxElementResolution7.tsx | 22 ++++ .../conformance/jsx/tsxElementResolution8.jsx | 15 +++ .../conformance/jsx/tsxElementResolution8.tsx | 36 ++++++ .../conformance/jsx/tsxElementResolution9.jsx | 6 + .../conformance/jsx/tsxElementResolution9.tsx | 27 ++++ tests/cases/conformance/jsx/tsxEmit1.jsx | 34 +++++ tests/cases/conformance/jsx/tsxEmit1.tsx | 41 ++++++ tests/cases/conformance/jsx/tsxEmit2.tsx | 15 +++ tests/cases/conformance/jsx/tsxEmit3.jsx | 41 ++++++ tests/cases/conformance/jsx/tsxEmit3.tsx | 41 ++++++ .../jsx/tsxGenericArrowFunctionParsing.tsx | 28 +++++ tests/cases/conformance/jsx/tsxNoJsx.tsx | 3 + .../cases/conformance/jsx/tsxParseTests1.tsx | 8 ++ tests/cases/conformance/jsx/tsxReactEmit1.tsx | 41 ++++++ tests/cases/conformance/jsx/tsxReactEmit2.tsx | 15 +++ tests/cases/conformance/jsx/tsxReactEmit3.tsx | 8 ++ tests/cases/conformance/jsx/tsxReactEmit4.tsx | 15 +++ .../jsx/tsxReactEmitWhitespace.tsx | 52 ++++++++ tests/cases/conformance/jsx/tsxTypeErrors.tsx | 34 +++++ 62 files changed, 1295 insertions(+) create mode 100644 tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx create mode 100644 tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx create mode 100644 tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx create mode 100644 tests/cases/conformance/jsx/jsxReactTestSuite.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeErrors.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution1.jsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution1.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution2.jsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution2.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution3.jsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution3.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution4.jsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution4.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution5.jsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution5.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution6.tsx create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution7.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution1.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution1.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution10.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution11.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution11.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution12.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution12.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution13.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution13.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution14.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution14.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution15.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution15.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution16.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution16.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution17.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution18.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution2.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution3.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution4.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution5.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution6.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution7.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution7.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution8.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution8.tsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution9.jsx create mode 100644 tests/cases/conformance/jsx/tsxElementResolution9.tsx create mode 100644 tests/cases/conformance/jsx/tsxEmit1.jsx create mode 100644 tests/cases/conformance/jsx/tsxEmit1.tsx create mode 100644 tests/cases/conformance/jsx/tsxEmit2.tsx create mode 100644 tests/cases/conformance/jsx/tsxEmit3.jsx create mode 100644 tests/cases/conformance/jsx/tsxEmit3.tsx create mode 100644 tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx create mode 100644 tests/cases/conformance/jsx/tsxNoJsx.tsx create mode 100644 tests/cases/conformance/jsx/tsxParseTests1.tsx create mode 100644 tests/cases/conformance/jsx/tsxReactEmit1.tsx create mode 100644 tests/cases/conformance/jsx/tsxReactEmit2.tsx create mode 100644 tests/cases/conformance/jsx/tsxReactEmit3.tsx create mode 100644 tests/cases/conformance/jsx/tsxReactEmit4.tsx create mode 100644 tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx create mode 100644 tests/cases/conformance/jsx/tsxTypeErrors.tsx diff --git a/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx b/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx new file mode 100644 index 0000000000000..b20dea210a98f --- /dev/null +++ b/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx @@ -0,0 +1,22 @@ +// @jsx: preserve + +declare var createElement: any; + +class foo {} + +var x: any; +x = { test: }; + +x = ; + +x = hello {{}} ; + +x = {}}>hello; + +x = {}}>hello{{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + + diff --git a/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx b/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx new file mode 100644 index 0000000000000..163357454aacc --- /dev/null +++ b/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx @@ -0,0 +1,54 @@ +// @jsx: preserve +declare var React: any; +declare var 日本語; +declare var AbC_def; +declare var LeftRight; +declare var x; +declare var a; +declare var props; + +; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; + +; +; + +<日本語>; + + +bar +baz +; + + : } />; + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + +; + +; + +(
) < x; + +
; + +
; + +
; + + ; diff --git a/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx new file mode 100644 index 0000000000000..815cd4abb217d --- /dev/null +++ b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx @@ -0,0 +1,36 @@ +// @jsx: preserve +declare var React: any; + +; +; +<:a />; +; +; +
; +; +; +
; +
; + +
stuff
; +
stuff
; + +
>; + >; +; +; +}; +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/jsxReactTestSuite.tsx b/tests/cases/conformance/jsx/jsxReactTestSuite.tsx new file mode 100644 index 0000000000000..96b91987cbcc2 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxReactTestSuite.tsx @@ -0,0 +1,117 @@ +// @jsx: preserve + +declare var React: any; +declare var Component:any; +declare var Composite:any; +declare var Composite2:any; +declare var Child:any; +declare var Namespace:any; +declare var foo: any; +declare var bar: any; +declare var y:any; +declare var x:any; +declare var z:any; +declare var hasOwnProperty:any; + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+
+
; + + + + {this.props.children} +; + + + +; + +var x = +
+
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+ +
+); + +
 
; + +
 
; + +testing; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + + +; + +Text; + + diff --git a/tests/cases/conformance/jsx/tsxAttributeErrors.tsx b/tests/cases/conformance/jsx/tsxAttributeErrors.tsx new file mode 100644 index 0000000000000..477135e15441f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeErrors.tsx @@ -0,0 +1,26 @@ +// @jsx: preserve + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } +} + +// Error, number is not assignable to string +
; + +// Error, string is not assignable to number +
; + +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; + +// No errors here +; diff --git a/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx new file mode 100644 index 0000000000000..a3a8d2935355b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Invalid names +; +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution.tsx new file mode 100644 index 0000000000000..a7519d00c9416 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution.tsx @@ -0,0 +1,9 @@ +/// @jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + x: { y: number; z: string; }; + } +} + + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx new file mode 100644 index 0000000000000..fb54f9d7c82b3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx @@ -0,0 +1,15 @@ +// OK +; // OK +; // OK +; // OK +; // OK +; // OK +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property +; // Error, missing reqd +; // Error, reqd is not string diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx new file mode 100644 index 0000000000000..edb203655efa8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx @@ -0,0 +1,33 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + } +} +interface Attribs1 { + x?: number; + s?: string; +} + +// OK +; // OK +; // OK +; // OK + +; // OK +; // OK + +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property + +; // Error, missing reqd +; // Error, reqd is not string + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx new file mode 100644 index 0000000000000..7c47046dcdeb5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx @@ -0,0 +1,5 @@ +// OK +; // OK +; // OK +// Errors +; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx new file mode 100644 index 0000000000000..c9bc2de978a75 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + c1?: (x: string) => void; +} + +// OK + x.length} />; // OK + x.leng} />; // OK + + +// Errors + x.leng} />; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx new file mode 100644 index 0000000000000..46cb5d8ff6980 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx @@ -0,0 +1,21 @@ +// OK +var obj1 = { x: 'foo' }; +; +// Error, x is not string +var obj2 = { x: 32 }; +; +// Error, x is missing +var obj3 = { y: 32 }; +; +// OK +var obj4 = { x: 32, y: 32 }; +; +// Error +var obj5 = { x: 32, y: 32 }; +; +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; +; +// Error +var obj7 = { x: 'foo' }; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx new file mode 100644 index 0000000000000..dc0c2fed8d638 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x: string; + y?: number; + z?: string; +} + +// OK +var obj1 = { x: 'foo' }; + + +// Error, x is not string +var obj2 = { x: 32 }; + + +// Error, x is missing +var obj3 = { y: 32 }; + + +// OK +var obj4 = { x: 32, y: 32 }; + + +// Error +var obj5 = { x: 32, y: 32 }; + + +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; + + +// Error +var obj7 = { x: 'foo' }; + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx new file mode 100644 index 0000000000000..da2e1d12038c2 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx @@ -0,0 +1,4 @@ +// OK +; +// Error, no member 'len' on 'string' +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx new file mode 100644 index 0000000000000..caaad3559c31a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx @@ -0,0 +1,17 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x(n: string): void; +} + +// OK + 0} } />; + +// Error, no member 'len' on 'string' + n.len} } />; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx new file mode 100644 index 0000000000000..3e4c89d06fb8a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx @@ -0,0 +1,11 @@ +function make1(obj) { + return ; // OK +} +function make2(obj) { + return ; // Error (x is number, not string) +} +function make3(obj) { + return ; // Error, missing x +} +; // Error, missing x +; // OK diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx new file mode 100644 index 0000000000000..dd16ade10e31e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx @@ -0,0 +1,32 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } +} +interface Attribs1 { + x: string; +} + +interface Attribs2 { + toString(): string; +} + +function make1 (obj: T) { + return ; // OK +} + +function make2 (obj: T) { + return ; // Error (x is number, not string) +} + +function make3 (obj: T) { + return ; // Error, missing x +} + + +; // Error, missing x +; // OK diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx new file mode 100644 index 0000000000000..b083247ba7a62 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } +} + +// Error +; +; +; + +// OK +; +; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx new file mode 100644 index 0000000000000..1fc6a8731875c --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx @@ -0,0 +1,16 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Error +; + +// OK +; +; +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution.tsx b/tests/cases/conformance/jsx/tsxElementResolution.tsx new file mode 100644 index 0000000000000..e5c3c191f05a9 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution.tsx @@ -0,0 +1,25 @@ +//@jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } +} + +class foundFirst { } +class Other {} + +module Dotted { + export class Name { } +} + +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.jsx b/tests/cases/conformance/jsx/tsxElementResolution1.jsx new file mode 100644 index 0000000000000..97357dbba8e74 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution1.jsx @@ -0,0 +1,4 @@ +// OK +
; +// Fail +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.tsx b/tests/cases/conformance/jsx/tsxElementResolution1.tsx new file mode 100644 index 0000000000000..b9c1b91d05e31 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution1.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +// OK +
; + +// Fail +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution10.tsx b/tests/cases/conformance/jsx/tsxElementResolution10.tsx new file mode 100644 index 0000000000000..526c0529e1bda --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution10.tsx @@ -0,0 +1,21 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): { x: number }; +} +var Obj1: Obj1type; +; // Error, no render member + +interface Obj2type { + (n: string): { x: number; render: any; }; +} +var Obj2: Obj2type; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.jsx b/tests/cases/conformance/jsx/tsxElementResolution11.jsx new file mode 100644 index 0000000000000..6349906508c23 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution11.jsx @@ -0,0 +1,6 @@ +var Obj1; +; // OK +var Obj2; +; // Error +var Obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.tsx b/tests/cases/conformance/jsx/tsxElementResolution11.tsx new file mode 100644 index 0000000000000..0fc74335500df --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution11.tsx @@ -0,0 +1,25 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number }; +} +var Obj2: Obj2type; +; // Error + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.jsx b/tests/cases/conformance/jsx/tsxElementResolution12.jsx new file mode 100644 index 0000000000000..ef137fd0e2960 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution12.jsx @@ -0,0 +1,9 @@ +var obj1; +; // OK +var obj2; +; // OK +var obj3; +; // Error +var obj4; +; // OK +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.tsx b/tests/cases/conformance/jsx/tsxElementResolution12.tsx new file mode 100644 index 0000000000000..a5d8f2d812b4b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution12.tsx @@ -0,0 +1,32 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number; pr: any }; +} +var obj2: Obj2type; +; // OK + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // Error + +interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; +} +var Obj4: Obj4type; +; // OK +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.jsx b/tests/cases/conformance/jsx/tsxElementResolution13.jsx new file mode 100644 index 0000000000000..6a55efa612d9f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution13.jsx @@ -0,0 +1,2 @@ +var obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.tsx b/tests/cases/conformance/jsx/tsxElementResolution13.tsx new file mode 100644 index 0000000000000..32ee20afbfe19 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution13.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } +} + +interface Obj1 { + new(n: string): any; +} +var obj1: Obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.jsx b/tests/cases/conformance/jsx/tsxElementResolution14.jsx new file mode 100644 index 0000000000000..29df7710af1fe --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution14.jsx @@ -0,0 +1,2 @@ +var obj1; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.tsx b/tests/cases/conformance/jsx/tsxElementResolution14.tsx new file mode 100644 index 0000000000000..f76af00bbeb5e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution14.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.jsx b/tests/cases/conformance/jsx/tsxElementResolution15.jsx new file mode 100644 index 0000000000000..6a55efa612d9f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution15.jsx @@ -0,0 +1,2 @@ +var obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.tsx b/tests/cases/conformance/jsx/tsxElementResolution15.tsx new file mode 100644 index 0000000000000..61cea63ce763c --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution15.tsx @@ -0,0 +1,13 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): {}; +} +var Obj1: Obj1type; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.jsx b/tests/cases/conformance/jsx/tsxElementResolution16.jsx new file mode 100644 index 0000000000000..e1987489bbb44 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution16.jsx @@ -0,0 +1,2 @@ +var obj1; +; // Error (JSX.Element is missing) diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.tsx b/tests/cases/conformance/jsx/tsxElementResolution16.tsx new file mode 100644 index 0000000000000..7d71b5f2b69b4 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution16.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // Error (JSX.Element is missing) diff --git a/tests/cases/conformance/jsx/tsxElementResolution17.tsx b/tests/cases/conformance/jsx/tsxElementResolution17.tsx new file mode 100644 index 0000000000000..97777d76a5884 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution17.tsx @@ -0,0 +1,27 @@ +//@jsx: preserve +//@module: amd + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +declare module 'elements1' { + class MyElement { + + } +} + +declare module 'elements2' { + class MyElement { + + } +} + +//@filename: consumer.tsx +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +import s2 = require('elements2'); +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution18.tsx b/tests/cases/conformance/jsx/tsxElementResolution18.tsx new file mode 100644 index 0000000000000..89081d7629f06 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution18.tsx @@ -0,0 +1,9 @@ +//@jsx: preserve +//@filename: file1.tsx +//@noimplicitany: true +declare module JSX { + interface Element { } +} + +// Error under implicit any +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution2.tsx b/tests/cases/conformance/jsx/tsxElementResolution2.tsx new file mode 100644 index 0000000000000..75e4956e728be --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution2.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: any; + } +} + +// OK +
; + +// OK +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution3.tsx b/tests/cases/conformance/jsx/tsxElementResolution3.tsx new file mode 100644 index 0000000000000..c3f057c4ff5ae --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution3.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } +} + +// OK +
; + +// Error +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution4.tsx b/tests/cases/conformance/jsx/tsxElementResolution4.tsx new file mode 100644 index 0000000000000..413ae6d5ed904 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution4.tsx @@ -0,0 +1,18 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } +} + +// OK +
; + +// OK +; + +// Error +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution5.tsx b/tests/cases/conformance/jsx/tsxElementResolution5.tsx new file mode 100644 index 0000000000000..c12c07d3e60b4 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution5.tsx @@ -0,0 +1,8 @@ +//@jsx: preserve +//@filename: file1.tsx +declare module JSX { + interface Element { } +} + +// OK, but implicit any +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution6.tsx b/tests/cases/conformance/jsx/tsxElementResolution6.tsx new file mode 100644 index 0000000000000..74d3324ea0f28 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution6.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +var div: any; +// Still an error +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.jsx b/tests/cases/conformance/jsx/tsxElementResolution7.jsx new file mode 100644 index 0000000000000..e95505539abba --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution7.jsx @@ -0,0 +1,14 @@ +var my; +(function (my) { +})(my || (my = {})); +// OK +; +// Error +; +var q; +(function (q) { + // OK + ; + // Error + ; +})(q || (q = {})); diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.tsx b/tests/cases/conformance/jsx/tsxElementResolution7.tsx new file mode 100644 index 0000000000000..c7ab23e76eab8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution7.tsx @@ -0,0 +1,22 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module my { + export var div: any; +} +// OK +; +// Error +; + +module q { + import mine = my; + // OK + ; + // Error + ; +} diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.jsx b/tests/cases/conformance/jsx/tsxElementResolution8.jsx new file mode 100644 index 0000000000000..e0f95dc6d2227 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution8.jsx @@ -0,0 +1,15 @@ +// Error +var div = 3; +
; +// OK +function fact() { return null; } +; +// Error +function fnum() { return 42; } +; +var obj1; +; // OK, prefer construct signatures +var obj2; +; // Error +var obj3; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.tsx b/tests/cases/conformance/jsx/tsxElementResolution8.tsx new file mode 100644 index 0000000000000..624302da06203 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution8.tsx @@ -0,0 +1,36 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +// Error +var Div = 3; +
; + +// OK +function Fact(): any { return null; } + + +// Error +function Fnum(): number{ return 42; } + + +interface Obj1 { + new(): {}; + (): number; +} +var Obj1: Obj1; +; // OK, prefer construct signatures + +interface Obj2 { + (): number; +} +var Obj2: Obj2; +; // Error + +interface Obj3 { +} +var Obj3: Obj3; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.jsx b/tests/cases/conformance/jsx/tsxElementResolution9.jsx new file mode 100644 index 0000000000000..2b62d86eac5f9 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution9.jsx @@ -0,0 +1,6 @@ +var obj1; +; // Error, return type is not an object type +var obj2; +; // Error, return type is not an object type +var obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.tsx b/tests/cases/conformance/jsx/tsxElementResolution9.tsx new file mode 100644 index 0000000000000..7165f8277b339 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution9.tsx @@ -0,0 +1,27 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; +} +var Obj1: Obj1; +; // Error, return type is not an object type + +interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; +} +var Obj2: Obj2; +; // Error, return type is not an object type + +interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; +} +var Obj3: Obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxEmit1.jsx b/tests/cases/conformance/jsx/tsxEmit1.jsx new file mode 100644 index 0000000000000..45ca6e2469f38 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit1.jsx @@ -0,0 +1,34 @@ +var p; +/* +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; +*/ +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 =
{function () { return _this; }}
; + var rewrites4 =
; + }; + return SomeClass; +})(); +/* +var q = () => this; +var rewrites2 =
{[p, ...p, p]}
; +var rewrites3 =
{{p}}
; + +var rewrites5 =
; +var rewrites6 =
; +*/ diff --git a/tests/cases/conformance/jsx/tsxEmit1.tsx b/tests/cases/conformance/jsx/tsxEmit1.tsx new file mode 100644 index 0000000000000..9f3d9ca3a5e25 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit1.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/cases/conformance/jsx/tsxEmit2.tsx b/tests/cases/conformance/jsx/tsxEmit2.tsx new file mode 100644 index 0000000000000..24f51a4583d86 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit2.tsx @@ -0,0 +1,15 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxEmit3.jsx b/tests/cases/conformance/jsx/tsxEmit3.jsx new file mode 100644 index 0000000000000..7c979051d00b3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit3.jsx @@ -0,0 +1,41 @@ +var M; +(function (M) { + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + M.Foo = Foo; + var S; + (function (S) { + var Bar = (function () { + function Bar() { + } + return Bar; + })(); + S.Bar = Bar; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.Foo + M.Foo, ; + var S; + (function (S) { + // Emit M.Foo + M.Foo, ; + // Emit S.Bar + S.Bar, ; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.S.Bar + M.S.Bar, ; +})(M || (M = {})); +var M; +(function (M_1) { + var M = 100; + // Emit M_1.Foo + M_1.Foo, ; +})(M || (M = {})); diff --git a/tests/cases/conformance/jsx/tsxEmit3.tsx b/tests/cases/conformance/jsx/tsxEmit3.tsx new file mode 100644 index 0000000000000..b3c3350dd116f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit3.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module M { + export class Foo { constructor() { } } + export module S { + export class Bar { } + + // Emit Foo + // Foo, ; + } +} + +module M { + // Emit M.Foo + Foo, ; + + export module S { + // Emit M.Foo + Foo, ; + + // Emit S.Bar + Bar, ; + } + +} + +module M { + // Emit M.S.Bar + S.Bar, ; +} + +module M { + var M = 100; + // Emit M_1.Foo + Foo, ; +} diff --git a/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx b/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx new file mode 100644 index 0000000000000..b3d3d34020a98 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx @@ -0,0 +1,28 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { isElement; } +} + +var T, T1, T2; + +// This is an element +var x1 = () => {}; +x1.isElement; + +// This is a generic function +var x2 = () => {}; +x2(); + +// This is a generic function +var x3 = () => {}; +x3(); + +// This is an element +var x4 = () => {}; +x4.isElement; + +// This is an element +var x5 = () => {}; +x5.isElement; + diff --git a/tests/cases/conformance/jsx/tsxNoJsx.tsx b/tests/cases/conformance/jsx/tsxNoJsx.tsx new file mode 100644 index 0000000000000..03b827b7e61cd --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNoJsx.tsx @@ -0,0 +1,3 @@ +//@jsx: preserve + +; diff --git a/tests/cases/conformance/jsx/tsxParseTests1.tsx b/tests/cases/conformance/jsx/tsxParseTests1.tsx new file mode 100644 index 0000000000000..7675aee796239 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxParseTests1.tsx @@ -0,0 +1,8 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx new file mode 100644 index 0000000000000..8ca8ef1ff4053 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit2.tsx b/tests/cases/conformance/jsx/tsxReactEmit2.tsx new file mode 100644 index 0000000000000..39a78a7da8791 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit2.tsx @@ -0,0 +1,15 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit3.tsx b/tests/cases/conformance/jsx/tsxReactEmit3.tsx new file mode 100644 index 0000000000000..eb63be44f3b7a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit3.tsx @@ -0,0 +1,8 @@ +//@jsx: react +//@filename: test.tsx + +declare module JSX { interface Element { } } + +declare var Foo, Bar, baz; + + q s ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx new file mode 100644 index 0000000000000..0987b89c97876 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -0,0 +1,15 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var openClosed1 =
+ + {blah} + +
; diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx new file mode 100644 index 0000000000000..38c966fa70026 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -0,0 +1,52 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +// Emit " " +
; +// Emit " ", p, " " +
{p}
; +// Emit only p +
+ {p} +
; + +// Emit only p +
+ {p} +
; + +// Emit " 3" +
3 +
; + +// Emit " 3 " +
3
; + +// Emit "3" +
+ 3 +
; + +// Emit no args +
+
; + +// Emit "foo" + ' ' + "bar" +
+ + foo + + bar + +
; + diff --git a/tests/cases/conformance/jsx/tsxTypeErrors.tsx b/tests/cases/conformance/jsx/tsxTypeErrors.tsx new file mode 100644 index 0000000000000..f8288b68ce336 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxTypeErrors.tsx @@ -0,0 +1,34 @@ +//@jsx: preserve + +// A built-in element (OK) +var a1 =
; + +// A built-in element with a mistyped property (error) +var a2 = + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
+ +// Mistyped html name (error) +var e1 = + +// A custom type +class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; + From a5c44a30121f220c684841968be486bc36586306 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:04:11 -0700 Subject: [PATCH 103/250] Baseline-accept --- tests/baselines/reference/APISample_linter.js | 22 +- tests/baselines/reference/asOperator1.js | 19 ++ tests/baselines/reference/asOperator1.symbols | 24 ++ tests/baselines/reference/asOperator1.types | 35 +++ .../reference/asOperator2.errors.txt | 8 + tests/baselines/reference/asOperator2.js | 6 + tests/baselines/reference/asOperator3.js | 22 ++ tests/baselines/reference/asOperator3.symbols | 31 ++ tests/baselines/reference/asOperator3.types | 63 ++++ tests/baselines/reference/asOperatorASI.js | 26 ++ .../baselines/reference/asOperatorASI.symbols | 23 ++ tests/baselines/reference/asOperatorASI.types | 28 ++ .../reference/asOperatorAmbiguity.errors.txt | 15 + .../reference/asOperatorAmbiguity.js | 16 + .../asOperatorContextualType.errors.txt | 10 + .../reference/asOperatorContextualType.js | 7 + .../reference/asOperatorNames.errors.txt | 11 + tests/baselines/reference/asOperatorNames.js | 12 + .../reference/jsxAndTypeAssertion.errors.txt | 125 ++++++++ .../reference/jsxAndTypeAssertion.js | 47 +++ .../jsxEsprimaFbTestSuite.errors.txt | 131 ++++++++ .../reference/jsxEsprimaFbTestSuite.js | 81 +++++ .../jsxInvalidEsprimaTestSuite.errors.txt | 283 ++++++++++++++++++ .../reference/jsxInvalidEsprimaTestSuite.js | 71 +++++ .../reference/jsxReactTestSuite.errors.txt | 246 +++++++++++++++ .../baselines/reference/jsxReactTestSuite.js | 171 +++++++++++ .../amd/invalidRootFile.errors.txt | 4 +- .../node/invalidRootFile.errors.txt | 4 +- .../reference/tsxAttributeErrors.errors.txt | 40 +++ .../baselines/reference/tsxAttributeErrors.js | 38 +++ .../tsxAttributeInvalidNames.errors.txt | 25 ++ .../reference/tsxAttributeInvalidNames.js | 16 + .../reference/tsxAttributeResolution.js | 14 + .../reference/tsxAttributeResolution.symbols | 18 ++ .../reference/tsxAttributeResolution.types | 18 ++ .../tsxAttributeResolution1.errors.txt | 53 ++++ .../reference/tsxAttributeResolution1.js | 50 ++++ .../tsxAttributeResolution2.errors.txt | 24 ++ .../reference/tsxAttributeResolution2.js | 26 ++ .../tsxAttributeResolution3.errors.txt | 59 ++++ .../reference/tsxAttributeResolution3.js | 64 ++++ .../tsxAttributeResolution4.errors.txt | 22 ++ .../reference/tsxAttributeResolution4.js | 23 ++ .../tsxAttributeResolution5.errors.txt | 45 +++ .../reference/tsxAttributeResolution5.js | 45 +++ .../tsxAttributeResolution6.errors.txt | 30 ++ .../reference/tsxAttributeResolution6.js | 29 ++ .../tsxAttributeResolution7.errors.txt | 21 ++ .../reference/tsxAttributeResolution7.js | 24 ++ .../reference/tsxElementResolution.errors.txt | 40 +++ .../reference/tsxElementResolution.js | 55 ++++ .../tsxElementResolution1.errors.txt | 18 ++ .../reference/tsxElementResolution1.js | 19 ++ .../tsxElementResolution10.errors.txt | 28 ++ .../reference/tsxElementResolution10.js | 27 ++ .../tsxElementResolution11.errors.txt | 30 ++ .../reference/tsxElementResolution11.js | 33 ++ .../tsxElementResolution12.errors.txt | 43 +++ .../reference/tsxElementResolution12.js | 43 +++ .../reference/tsxElementResolution13.js | 16 + .../reference/tsxElementResolution13.symbols | 26 ++ .../reference/tsxElementResolution13.types | 28 ++ .../reference/tsxElementResolution14.js | 15 + .../reference/tsxElementResolution14.symbols | 21 ++ .../reference/tsxElementResolution14.types | 23 ++ .../tsxElementResolution15.errors.txt | 18 ++ .../reference/tsxElementResolution15.js | 17 ++ .../tsxElementResolution16.errors.txt | 15 + .../reference/tsxElementResolution16.js | 14 + .../reference/tsxElementResolution17.js | 34 +++ .../reference/tsxElementResolution17.symbols | 38 +++ .../reference/tsxElementResolution17.types | 40 +++ .../tsxElementResolution18.errors.txt | 13 + .../reference/tsxElementResolution18.js | 12 + .../reference/tsxElementResolution2.js | 19 ++ .../reference/tsxElementResolution2.symbols | 23 ++ .../reference/tsxElementResolution2.types | 25 ++ .../tsxElementResolution3.errors.txt | 21 ++ .../reference/tsxElementResolution3.js | 19 ++ .../tsxElementResolution4.errors.txt | 26 ++ .../reference/tsxElementResolution4.js | 26 ++ .../reference/tsxElementResolution5.js | 12 + .../reference/tsxElementResolution5.symbols | 12 + .../reference/tsxElementResolution5.types | 14 + .../tsxElementResolution6.errors.txt | 15 + .../reference/tsxElementResolution6.js | 15 + .../tsxElementResolution7.errors.txt | 30 ++ .../reference/tsxElementResolution7.js | 39 +++ .../tsxElementResolution8.errors.txt | 50 ++++ .../reference/tsxElementResolution8.js | 53 ++++ .../tsxElementResolution9.errors.txt | 35 +++ .../reference/tsxElementResolution9.js | 35 +++ tests/baselines/reference/tsxEmit1.js | 75 +++++ tests/baselines/reference/tsxEmit1.symbols | 144 +++++++++ tests/baselines/reference/tsxEmit1.types | 194 ++++++++++++ tests/baselines/reference/tsxEmit2.js | 23 ++ tests/baselines/reference/tsxEmit2.symbols | 44 +++ tests/baselines/reference/tsxEmit2.types | 68 +++++ tests/baselines/reference/tsxEmit3.js | 84 ++++++ tests/baselines/reference/tsxEmit3.symbols | 75 +++++ tests/baselines/reference/tsxEmit3.types | 87 ++++++ .../tsxGenericArrowFunctionParsing.js | 46 +++ .../tsxGenericArrowFunctionParsing.symbols | 64 ++++ .../tsxGenericArrowFunctionParsing.types | 75 +++++ tests/baselines/reference/tsxNoJsx.errors.txt | 9 + tests/baselines/reference/tsxNoJsx.js | 7 + tests/baselines/reference/tsxParseTests1.js | 11 + .../reference/tsxParseTests1.symbols | 20 ++ .../baselines/reference/tsxParseTests1.types | 28 ++ tests/baselines/reference/tsxReactEmit1.js | 73 +++++ .../baselines/reference/tsxReactEmit1.symbols | 144 +++++++++ tests/baselines/reference/tsxReactEmit1.types | 194 ++++++++++++ tests/baselines/reference/tsxReactEmit2.js | 23 ++ .../baselines/reference/tsxReactEmit2.symbols | 44 +++ tests/baselines/reference/tsxReactEmit2.types | 68 +++++ tests/baselines/reference/tsxReactEmit3.js | 10 + .../baselines/reference/tsxReactEmit3.symbols | 18 ++ tests/baselines/reference/tsxReactEmit3.types | 25 ++ .../reference/tsxReactEmit4.errors.txt | 20 ++ tests/baselines/reference/tsxReactEmit4.js | 19 ++ .../reference/tsxReactEmitWhitespace.js | 75 +++++ .../reference/tsxReactEmitWhitespace.symbols | 77 +++++ .../reference/tsxReactEmitWhitespace.types | 101 +++++++ .../reference/tsxTypeErrors.errors.txt | 55 ++++ tests/baselines/reference/tsxTypeErrors.js | 60 ++++ 125 files changed, 5405 insertions(+), 15 deletions(-) create mode 100644 tests/baselines/reference/asOperator1.js create mode 100644 tests/baselines/reference/asOperator1.symbols create mode 100644 tests/baselines/reference/asOperator1.types create mode 100644 tests/baselines/reference/asOperator2.errors.txt create mode 100644 tests/baselines/reference/asOperator2.js create mode 100644 tests/baselines/reference/asOperator3.js create mode 100644 tests/baselines/reference/asOperator3.symbols create mode 100644 tests/baselines/reference/asOperator3.types create mode 100644 tests/baselines/reference/asOperatorASI.js create mode 100644 tests/baselines/reference/asOperatorASI.symbols create mode 100644 tests/baselines/reference/asOperatorASI.types create mode 100644 tests/baselines/reference/asOperatorAmbiguity.errors.txt create mode 100644 tests/baselines/reference/asOperatorAmbiguity.js create mode 100644 tests/baselines/reference/asOperatorContextualType.errors.txt create mode 100644 tests/baselines/reference/asOperatorContextualType.js create mode 100644 tests/baselines/reference/asOperatorNames.errors.txt create mode 100644 tests/baselines/reference/asOperatorNames.js create mode 100644 tests/baselines/reference/jsxAndTypeAssertion.errors.txt create mode 100644 tests/baselines/reference/jsxAndTypeAssertion.js create mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt create mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.js create mode 100644 tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt create mode 100644 tests/baselines/reference/jsxInvalidEsprimaTestSuite.js create mode 100644 tests/baselines/reference/jsxReactTestSuite.errors.txt create mode 100644 tests/baselines/reference/jsxReactTestSuite.js create mode 100644 tests/baselines/reference/tsxAttributeErrors.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeErrors.js create mode 100644 tests/baselines/reference/tsxAttributeInvalidNames.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeInvalidNames.js create mode 100644 tests/baselines/reference/tsxAttributeResolution.js create mode 100644 tests/baselines/reference/tsxAttributeResolution.symbols create mode 100644 tests/baselines/reference/tsxAttributeResolution.types create mode 100644 tests/baselines/reference/tsxAttributeResolution1.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution1.js create mode 100644 tests/baselines/reference/tsxAttributeResolution2.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution2.js create mode 100644 tests/baselines/reference/tsxAttributeResolution3.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution3.js create mode 100644 tests/baselines/reference/tsxAttributeResolution4.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution4.js create mode 100644 tests/baselines/reference/tsxAttributeResolution5.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution5.js create mode 100644 tests/baselines/reference/tsxAttributeResolution6.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution6.js create mode 100644 tests/baselines/reference/tsxAttributeResolution7.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution7.js create mode 100644 tests/baselines/reference/tsxElementResolution.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution.js create mode 100644 tests/baselines/reference/tsxElementResolution1.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution1.js create mode 100644 tests/baselines/reference/tsxElementResolution10.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution10.js create mode 100644 tests/baselines/reference/tsxElementResolution11.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution11.js create mode 100644 tests/baselines/reference/tsxElementResolution12.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution12.js create mode 100644 tests/baselines/reference/tsxElementResolution13.js create mode 100644 tests/baselines/reference/tsxElementResolution13.symbols create mode 100644 tests/baselines/reference/tsxElementResolution13.types create mode 100644 tests/baselines/reference/tsxElementResolution14.js create mode 100644 tests/baselines/reference/tsxElementResolution14.symbols create mode 100644 tests/baselines/reference/tsxElementResolution14.types create mode 100644 tests/baselines/reference/tsxElementResolution15.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution15.js create mode 100644 tests/baselines/reference/tsxElementResolution16.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution16.js create mode 100644 tests/baselines/reference/tsxElementResolution17.js create mode 100644 tests/baselines/reference/tsxElementResolution17.symbols create mode 100644 tests/baselines/reference/tsxElementResolution17.types create mode 100644 tests/baselines/reference/tsxElementResolution18.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution18.js create mode 100644 tests/baselines/reference/tsxElementResolution2.js create mode 100644 tests/baselines/reference/tsxElementResolution2.symbols create mode 100644 tests/baselines/reference/tsxElementResolution2.types create mode 100644 tests/baselines/reference/tsxElementResolution3.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution3.js create mode 100644 tests/baselines/reference/tsxElementResolution4.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution4.js create mode 100644 tests/baselines/reference/tsxElementResolution5.js create mode 100644 tests/baselines/reference/tsxElementResolution5.symbols create mode 100644 tests/baselines/reference/tsxElementResolution5.types create mode 100644 tests/baselines/reference/tsxElementResolution6.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution6.js create mode 100644 tests/baselines/reference/tsxElementResolution7.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution7.js create mode 100644 tests/baselines/reference/tsxElementResolution8.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution8.js create mode 100644 tests/baselines/reference/tsxElementResolution9.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution9.js create mode 100644 tests/baselines/reference/tsxEmit1.js create mode 100644 tests/baselines/reference/tsxEmit1.symbols create mode 100644 tests/baselines/reference/tsxEmit1.types create mode 100644 tests/baselines/reference/tsxEmit2.js create mode 100644 tests/baselines/reference/tsxEmit2.symbols create mode 100644 tests/baselines/reference/tsxEmit2.types create mode 100644 tests/baselines/reference/tsxEmit3.js create mode 100644 tests/baselines/reference/tsxEmit3.symbols create mode 100644 tests/baselines/reference/tsxEmit3.types create mode 100644 tests/baselines/reference/tsxGenericArrowFunctionParsing.js create mode 100644 tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols create mode 100644 tests/baselines/reference/tsxGenericArrowFunctionParsing.types create mode 100644 tests/baselines/reference/tsxNoJsx.errors.txt create mode 100644 tests/baselines/reference/tsxNoJsx.js create mode 100644 tests/baselines/reference/tsxParseTests1.js create mode 100644 tests/baselines/reference/tsxParseTests1.symbols create mode 100644 tests/baselines/reference/tsxParseTests1.types create mode 100644 tests/baselines/reference/tsxReactEmit1.js create mode 100644 tests/baselines/reference/tsxReactEmit1.symbols create mode 100644 tests/baselines/reference/tsxReactEmit1.types create mode 100644 tests/baselines/reference/tsxReactEmit2.js create mode 100644 tests/baselines/reference/tsxReactEmit2.symbols create mode 100644 tests/baselines/reference/tsxReactEmit2.types create mode 100644 tests/baselines/reference/tsxReactEmit3.js create mode 100644 tests/baselines/reference/tsxReactEmit3.symbols create mode 100644 tests/baselines/reference/tsxReactEmit3.types create mode 100644 tests/baselines/reference/tsxReactEmit4.errors.txt create mode 100644 tests/baselines/reference/tsxReactEmit4.js create mode 100644 tests/baselines/reference/tsxReactEmitWhitespace.js create mode 100644 tests/baselines/reference/tsxReactEmitWhitespace.symbols create mode 100644 tests/baselines/reference/tsxReactEmitWhitespace.types create mode 100644 tests/baselines/reference/tsxTypeErrors.errors.txt create mode 100644 tests/baselines/reference/tsxTypeErrors.js diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 9b2675535f22e..ca7078981f793 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,28 +75,28 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: - if (node.statement.kind !== 182 /* Block */) { + case 191 /* ForStatement */: + case 192 /* ForInStatement */: + case 190 /* WhileStatement */: + case 189 /* DoStatement */: + if (node.statement.kind !== 184 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 186 /* IfStatement */: + case 188 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 182 /* Block */) { + if (ifStatement.thenStatement.kind !== 184 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 182 /* Block */ && - ifStatement.elseStatement.kind !== 186 /* IfStatement */) { + ifStatement.elseStatement.kind !== 184 /* Block */ && + ifStatement.elseStatement.kind !== 188 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 172 /* BinaryExpression */: + case 173 /* BinaryExpression */: var op = node.operatorToken.kind; - if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { + if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); } break; diff --git a/tests/baselines/reference/asOperator1.js b/tests/baselines/reference/asOperator1.js new file mode 100644 index 0000000000000..1b23d0a86f7c9 --- /dev/null +++ b/tests/baselines/reference/asOperator1.js @@ -0,0 +1,19 @@ +//// [asOperator1.ts] +var as = 43; +var x = undefined as number; +var y = (null as string).length; +var z = Date as any as string; + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +j = ''; + + +//// [asOperator1.js] +var as = 43; +var x = undefined; +var y = null.length; +var z = Date; +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32; +j = ''; diff --git a/tests/baselines/reference/asOperator1.symbols b/tests/baselines/reference/asOperator1.symbols new file mode 100644 index 0000000000000..27353ec7b30fa --- /dev/null +++ b/tests/baselines/reference/asOperator1.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator1.ts === +var as = 43; +>as : Symbol(as, Decl(asOperator1.ts, 0, 3)) + +var x = undefined as number; +>x : Symbol(x, Decl(asOperator1.ts, 1, 3)) +>undefined : Symbol(undefined) + +var y = (null as string).length; +>y : Symbol(y, Decl(asOperator1.ts, 2, 3)) +>(null as string).length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + +var z = Date as any as string; +>z : Symbol(z, Decl(asOperator1.ts, 3, 3)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +>j : Symbol(j, Decl(asOperator1.ts, 6, 3)) + +j = ''; +>j : Symbol(j, Decl(asOperator1.ts, 6, 3)) + diff --git a/tests/baselines/reference/asOperator1.types b/tests/baselines/reference/asOperator1.types new file mode 100644 index 0000000000000..3f69871ea0942 --- /dev/null +++ b/tests/baselines/reference/asOperator1.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator1.ts === +var as = 43; +>as : number +>43 : number + +var x = undefined as number; +>x : number +>undefined as number : number +>undefined : undefined + +var y = (null as string).length; +>y : number +>(null as string).length : number +>(null as string) : string +>null as string : string +>null : null +>length : number + +var z = Date as any as string; +>z : string +>Date as any as string : string +>Date as any : any +>Date : DateConstructor + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +>j : string | number +>32 as number|string : string | number +>32 : number + +j = ''; +>j = '' : string +>j : string | number +>'' : string + diff --git a/tests/baselines/reference/asOperator2.errors.txt b/tests/baselines/reference/asOperator2.errors.txt new file mode 100644 index 0000000000000..3b074038c26b0 --- /dev/null +++ b/tests/baselines/reference/asOperator2.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/expressions/asOperator/asOperator2.ts(1,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + + +==== tests/cases/conformance/expressions/asOperator/asOperator2.ts (1 errors) ==== + var x = 23 as string; + ~~~~~~~~~~~~ +!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + \ No newline at end of file diff --git a/tests/baselines/reference/asOperator2.js b/tests/baselines/reference/asOperator2.js new file mode 100644 index 0000000000000..32962555d5107 --- /dev/null +++ b/tests/baselines/reference/asOperator2.js @@ -0,0 +1,6 @@ +//// [asOperator2.ts] +var x = 23 as string; + + +//// [asOperator2.js] +var x = 23; diff --git a/tests/baselines/reference/asOperator3.js b/tests/baselines/reference/asOperator3.js new file mode 100644 index 0000000000000..406eae1c9d68b --- /dev/null +++ b/tests/baselines/reference/asOperator3.js @@ -0,0 +1,22 @@ +//// [asOperator3.ts] +declare function tag(...x: any[]): any; + +var a = `${123 + 456 as number}`; +var b = `leading ${123 + 456 as number}`; +var c = `${123 + 456 as number} trailing`; +var d = `Hello ${123} World` as string; +var e = `Hello` as string; +var f = 1 + `${1} end of string` as string; +var g = tag `Hello ${123} World` as string; +var h = tag `Hello` as string; + +//// [asOperator3.js] +var a = "" + 123 + 456; +var b = "leading " + 123 + 456; +var c = 123 + 456 + " trailing"; +var d = ("Hello " + 123 + " World"); +var e = "Hello"; +var f = 1 + (1 + " end of string"); +var g = (_a = ["Hello ", " World"], _a.raw = ["Hello ", " World"], tag(_a, 123)); +var h = (_b = ["Hello"], _b.raw = ["Hello"], tag(_b)); +var _a, _b; diff --git a/tests/baselines/reference/asOperator3.symbols b/tests/baselines/reference/asOperator3.symbols new file mode 100644 index 0000000000000..d29a64d3c3a51 --- /dev/null +++ b/tests/baselines/reference/asOperator3.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator3.ts === +declare function tag(...x: any[]): any; +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) +>x : Symbol(x, Decl(asOperator3.ts, 0, 21)) + +var a = `${123 + 456 as number}`; +>a : Symbol(a, Decl(asOperator3.ts, 2, 3)) + +var b = `leading ${123 + 456 as number}`; +>b : Symbol(b, Decl(asOperator3.ts, 3, 3)) + +var c = `${123 + 456 as number} trailing`; +>c : Symbol(c, Decl(asOperator3.ts, 4, 3)) + +var d = `Hello ${123} World` as string; +>d : Symbol(d, Decl(asOperator3.ts, 5, 3)) + +var e = `Hello` as string; +>e : Symbol(e, Decl(asOperator3.ts, 6, 3)) + +var f = 1 + `${1} end of string` as string; +>f : Symbol(f, Decl(asOperator3.ts, 7, 3)) + +var g = tag `Hello ${123} World` as string; +>g : Symbol(g, Decl(asOperator3.ts, 8, 3)) +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) + +var h = tag `Hello` as string; +>h : Symbol(h, Decl(asOperator3.ts, 9, 3)) +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) + diff --git a/tests/baselines/reference/asOperator3.types b/tests/baselines/reference/asOperator3.types new file mode 100644 index 0000000000000..507dfd8b5726f --- /dev/null +++ b/tests/baselines/reference/asOperator3.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator3.ts === +declare function tag(...x: any[]): any; +>tag : (...x: any[]) => any +>x : any[] + +var a = `${123 + 456 as number}`; +>a : string +>`${123 + 456 as number}` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var b = `leading ${123 + 456 as number}`; +>b : string +>`leading ${123 + 456 as number}` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var c = `${123 + 456 as number} trailing`; +>c : string +>`${123 + 456 as number} trailing` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var d = `Hello ${123} World` as string; +>d : string +>`Hello ${123} World` as string : string +>`Hello ${123} World` : string +>123 : number + +var e = `Hello` as string; +>e : string +>`Hello` as string : string +>`Hello` : string + +var f = 1 + `${1} end of string` as string; +>f : string +>1 + `${1} end of string` as string : string +>1 + `${1} end of string` : string +>1 : number +>`${1} end of string` : string +>1 : number + +var g = tag `Hello ${123} World` as string; +>g : string +>tag `Hello ${123} World` as string : string +>tag `Hello ${123} World` : any +>tag : (...x: any[]) => any +>`Hello ${123} World` : string +>123 : number + +var h = tag `Hello` as string; +>h : string +>tag `Hello` as string : string +>tag `Hello` : any +>tag : (...x: any[]) => any +>`Hello` : string + diff --git a/tests/baselines/reference/asOperatorASI.js b/tests/baselines/reference/asOperatorASI.js new file mode 100644 index 0000000000000..1df39b36e50f5 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.js @@ -0,0 +1,26 @@ +//// [asOperatorASI.ts] +class Foo { } +declare function as(...args: any[]); + +// Example 1 +var x = 10 +as `Hello world`; // should not error + +// Example 2 +var y = 20 +as(Foo); // should emit + + +//// [asOperatorASI.js] +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +// Example 1 +var x = 10; +(_a = ["Hello world"], _a.raw = ["Hello world"], as(_a)); // should not error +// Example 2 +var y = 20; +as(Foo); // should emit +var _a; diff --git a/tests/baselines/reference/asOperatorASI.symbols b/tests/baselines/reference/asOperatorASI.symbols new file mode 100644 index 0000000000000..7def6d460c15c --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts === +class Foo { } +>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0)) + +declare function as(...args: any[]); +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) +>args : Symbol(args, Decl(asOperatorASI.ts, 1, 20)) + +// Example 1 +var x = 10 +>x : Symbol(x, Decl(asOperatorASI.ts, 4, 3)) + +as `Hello world`; // should not error +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) + +// Example 2 +var y = 20 +>y : Symbol(y, Decl(asOperatorASI.ts, 8, 3)) + +as(Foo); // should emit +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) +>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0)) + diff --git a/tests/baselines/reference/asOperatorASI.types b/tests/baselines/reference/asOperatorASI.types new file mode 100644 index 0000000000000..61c2d115cf4f6 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts === +class Foo { } +>Foo : Foo + +declare function as(...args: any[]); +>as : (...args: any[]) => any +>args : any[] + +// Example 1 +var x = 10 +>x : number +>10 : number + +as `Hello world`; // should not error +>as `Hello world` : any +>as : (...args: any[]) => any +>`Hello world` : string + +// Example 2 +var y = 20 +>y : number +>20 : number + +as(Foo); // should emit +>as(Foo) : any +>as : (...args: any[]) => any +>Foo : typeof Foo + diff --git a/tests/baselines/reference/asOperatorAmbiguity.errors.txt b/tests/baselines/reference/asOperatorAmbiguity.errors.txt new file mode 100644 index 0000000000000..cb7c6d4132c18 --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts(7,14): error TS2339: Property 'm' does not exist on type 'A'. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts (1 errors) ==== + interface A { x: T; } + interface B { m: string; } + + // Make sure this is a type assertion to an array type, and not nested comparison operators. + var x: any; + var y = x as A[]; + var z = y[0].m; // z should be string + ~ +!!! error TS2339: Property 'm' does not exist on type 'A'. + + \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorAmbiguity.js b/tests/baselines/reference/asOperatorAmbiguity.js new file mode 100644 index 0000000000000..6c336970b65fe --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.js @@ -0,0 +1,16 @@ +//// [asOperatorAmbiguity.ts] +interface A { x: T; } +interface B { m: string; } + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +var y = x as A[]; +var z = y[0].m; // z should be string + + + +//// [asOperatorAmbiguity.js] +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x; +var y = x; +var z = y[0].m; // z should be string diff --git a/tests/baselines/reference/asOperatorContextualType.errors.txt b/tests/baselines/reference/asOperatorContextualType.errors.txt new file mode 100644 index 0000000000000..c53b407b5cf02 --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts (1 errors) ==== + // should error + var x = (v => v) as (x: number) => string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other. +!!! error TS2352: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorContextualType.js b/tests/baselines/reference/asOperatorContextualType.js new file mode 100644 index 0000000000000..7b495ada8f403 --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.js @@ -0,0 +1,7 @@ +//// [asOperatorContextualType.ts] +// should error +var x = (v => v) as (x: number) => string; + +//// [asOperatorContextualType.js] +// should error +var x = (function (v) { return v; }); diff --git a/tests/baselines/reference/asOperatorNames.errors.txt b/tests/baselines/reference/asOperatorNames.errors.txt new file mode 100644 index 0000000000000..e3dfaab98845b --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/expressions/asOperator/asOperatorNames.ts(2,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorNames.ts (1 errors) ==== + var a = 20; + var b = a as string; + ~~~~~~~~~~~ +!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + var as = "hello"; + var as1 = as as string; + \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorNames.js b/tests/baselines/reference/asOperatorNames.js new file mode 100644 index 0000000000000..35e80d080e334 --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.js @@ -0,0 +1,12 @@ +//// [asOperatorNames.ts] +var a = 20; +var b = a as string; +var as = "hello"; +var as1 = as as string; + + +//// [asOperatorNames.js] +var a = 20; +var b = a; +var as = "hello"; +var as1 = as; diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt new file mode 100644 index 0000000000000..8e7132007d858 --- /dev/null +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -0,0 +1,125 @@ +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,13): error TS2304: Cannot find name 'test'. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,17): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,19): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(9,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(9,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,17): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,32): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,16): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,36): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,16): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,31): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,45): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(17,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(17,23): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,7): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,12): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,34): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,39): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,53): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,58): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS1005: ':' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'any'. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'foo'. + + +==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (28 errors) ==== + + declare var createElement: any; + + class foo {} + + var x: any; + x = { test: }; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~ +!!! error TS2304: Cannot find name 'test'. + ~ +!!! error TS1005: '}' expected. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + x = ; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + x = hello {{}} ; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '}' expected. + + x = {}}>hello; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '}' expected. + + + x = {}}>hello{{}}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '}' expected. + + + + x = x, x = ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + + + {{/foo/.test(x) ? : }} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + + + + ~~~~ + ~~~~ + + +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +!!! error TS1005: ':' expected. + +!!! error TS17002: Expected corresponding JSX closing tag for 'any'. + +!!! error TS17002: Expected corresponding JSX closing tag for 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxAndTypeAssertion.js b/tests/baselines/reference/jsxAndTypeAssertion.js new file mode 100644 index 0000000000000..26af23a2051bf --- /dev/null +++ b/tests/baselines/reference/jsxAndTypeAssertion.js @@ -0,0 +1,47 @@ +//// [jsxAndTypeAssertion.tsx] + +declare var createElement: any; + +class foo {} + +var x: any; +x = { test: }; + +x = ; + +x = hello {{}} ; + +x = {}}>hello; + +x = {}}>hello{{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + + + + +//// [jsxAndTypeAssertion.jsx] +var foo = (function () { + function foo() { + } + return foo; +})(); +var x; +x = {test}: }; + +x = ; + +x = hello {} }; + +x = }>hello} x=}>hello{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + : +} + + +}}>>; diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt new file mode 100644 index 0000000000000..b6c083e33096f --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt @@ -0,0 +1,131 @@ +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(9,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(18,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(21,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(23,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(29,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(29,11): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(29,19): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(31,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(33,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(35,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(37,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(37,6): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,17): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,29): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(43,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(45,2): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(47,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(49,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(51,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(53,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. + + +==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (24 errors) ==== + declare var React: any; + declare var 日本語; + declare var AbC_def; + declare var LeftRight; + declare var x; + declare var a; + declare var props; + + ; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + //; Namespace unsuported + + // {value} ; Namespace unsuported + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ; + ~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + <日本語>; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + bar + baz + ; + + : } />; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + {}; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + {/* this is a comment */}; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +
@test content
; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +

7x invalid-js-identifier
; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + right=monkeys /> gorillas />; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + (
) < x; + ~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +
; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +
; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +
; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + \ No newline at end of file diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.js b/tests/baselines/reference/jsxEsprimaFbTestSuite.js new file mode 100644 index 0000000000000..2050c39972c13 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.js @@ -0,0 +1,81 @@ +//// [jsxEsprimaFbTestSuite.tsx] +declare var React: any; +declare var 日本語; +declare var AbC_def; +declare var LeftRight; +declare var x; +declare var a; +declare var props; + +
; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; + +; +; + +<日本語>; + + +bar +baz +; + + : } />; + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + +; + +; + +(
) < x; + +
; + +
; + +
; + + ; + + +//// [jsxEsprimaFbTestSuite.jsx] +; +//; Namespace unsuported +// {value} ; Namespace unsuported +; +; +; +<日本語>; + +bar +baz +; + : }/>; +; +; +
@test content
; +

7x invalid-js-identifier
; + right=monkeys /> gorillas/>; +; +; +(
) < x; +
; +
; +
; + ; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt new file mode 100644 index 0000000000000..7f3d60f836102 --- /dev/null +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -0,0 +1,283 @@ +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,2): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS2304: Cannot find name 'd'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,4): error TS17002: Expected corresponding JSX closing tag for 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,13): error TS1002: Unterminated string literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS17002: Expected corresponding JSX closing tag for 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,12): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,14): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,4): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(19,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(20,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(20,23): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(21,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(21,50): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,10): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,20): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,15): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS1005: '...' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,17): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,29): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(30,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(31,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(34,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: '; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. + ; + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. + <:a />; + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. + ; + ~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS2304: Cannot find name 'd'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1003: Identifier expected. + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~ +!!! error TS17002: Expected corresponding JSX closing tag for 'a'. + ; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '}' expected. + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. +
; + ~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS1003: Identifier expected. +
; + ~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS1005: '...' expected. + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + +
stuff
; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '>' expected. + ~~~ +!!! error TS1109: Expression expected. +
stuff
; + ~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + ~ +!!! error TS1005: '>' expected. + ~~~ +!!! error TS1109: Expression expected. + +
>; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + >; + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ; + ~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1005: '{' expected. + ; + ~~~~~~~~~ + ~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. + }; + ~~~~~~~~~ + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~ +!!! error TS1003: Identifier expected. + +!!! error TS1005: '; +; +<:a />; +; +; +; +; +; +
; +
; + +
stuff
; +
stuff
; + +
>; + >; +; +; +}; +; + +//// [jsxInvalidEsprimaTestSuite.jsx] +< />; +; +< a=/>; + }> +; +; +; +; +
"app">; +
; + +
stuff
{}...props}>; +
stuff
{}...props}>; + +
>; + >; +; +}>; +}; +;>; diff --git a/tests/baselines/reference/jsxReactTestSuite.errors.txt b/tests/baselines/reference/jsxReactTestSuite.errors.txt new file mode 100644 index 0000000000000..4e9e5c42492d2 --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.errors.txt @@ -0,0 +1,246 @@ +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(21,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(22,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(22,8): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(23,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(23,19): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(24,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(28,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(32,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(33,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(37,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(55,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(58,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(62,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(69,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(73,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(79,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(81,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(83,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(85,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(87,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(89,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(91,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(94,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(97,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(99,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(101,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(103,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(105,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(107,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(109,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(112,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(112,38): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxReactTestSuite.tsx(114,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. + + +==== tests/cases/conformance/jsx/jsxReactTestSuite.tsx (35 errors) ==== + + declare var React: any; + declare var Component:any; + declare var Composite:any; + declare var Composite2:any; + declare var Child:any; + declare var Namespace:any; + declare var foo: any; + declare var bar: any; + declare var y:any; + declare var x:any; + declare var z:any; + declare var hasOwnProperty:any; + +
text
; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +
+ ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + {this.props.children} +
; + +
+ ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. +

+ ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + {foo}
{bar}
+ ~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. +
+ ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. +
; + + + + ~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + {this.props.children} + ; + + + ~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ; + + var x = +
+ ~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. +
; + + ( +
+ ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + {/* A comment at the end */} + {/* A second comment at the end */} +
+ ); + + ( +
+ ~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. +
+ ); + +
 
; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + +
 
; + ~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + testing; + ~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + Text; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + + \ No newline at end of file diff --git a/tests/baselines/reference/jsxReactTestSuite.js b/tests/baselines/reference/jsxReactTestSuite.js new file mode 100644 index 0000000000000..300274a161465 --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.js @@ -0,0 +1,171 @@ +//// [jsxReactTestSuite.tsx] + +declare var React: any; +declare var Component:any; +declare var Composite:any; +declare var Composite2:any; +declare var Child:any; +declare var Namespace:any; +declare var foo: any; +declare var bar: any; +declare var y:any; +declare var x:any; +declare var z:any; +declare var hasOwnProperty:any; + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+
+
; + + + + {this.props.children} +; + + + +; + +var x = +
+
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+ +
+); + +
 
; + +
 
; + +testing; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + + +; + +Text; + + + + +//// [jsxReactTestSuite.jsx] +
text
; +
+ {this.props.children} +
; +
+

+ {foo}
{bar}
+
+
; + + {this.props.children} +; + + +; +var x =
+
; +(
+ + + + + + +
+ + +
); +(
+ +
); +
 
; +
 
; +testing; +; +; +; +; +; +; +; +; +; +; +; +; +; +Text; diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index 656b6e1f2a2a1..bafcc39f48d33 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index 656b6e1f2a2a1..bafcc39f48d33 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeErrors.errors.txt b/tests/baselines/reference/tsxAttributeErrors.errors.txt new file mode 100644 index 0000000000000..30a897c5163b1 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeErrors.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeErrors.tsx (3 errors) ==== + + declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } + } + + // Error, number is not assignable to string +
; + ~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // Error, string is not assignable to number +
; + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + // Error, number is not assignable to string + var attribs = { text: 100 }; +
; + ~~~~~~~~~~~~ +!!! error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // No errors here + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeErrors.js b/tests/baselines/reference/tsxAttributeErrors.js new file mode 100644 index 0000000000000..2ab862e0efec9 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeErrors.js @@ -0,0 +1,38 @@ +//// [tsxAttributeErrors.tsx] + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } +} + +// Error, number is not assignable to string +
; + +// Error, string is not assignable to number +
; + +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; + +// No errors here +; + + +//// [tsxAttributeErrors.jsx] +// Error, number is not assignable to string +
; +// Error, string is not assignable to number +
; +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; +// No errors here +; diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt new file mode 100644 index 0000000000000..055062237d837 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(9,8): error TS1003: Identifier expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,8): error TS1003: Identifier expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,22): error TS1005: '; + ~~ +!!! error TS1003: Identifier expected. + ; + ~ +!!! error TS1003: Identifier expected. + +!!! error TS1005: '; +; + +//// [tsxAttributeInvalidNames.jsx] +// Invalid names + 32data={32} />; + -data={32} />;; diff --git a/tests/baselines/reference/tsxAttributeResolution.js b/tests/baselines/reference/tsxAttributeResolution.js new file mode 100644 index 0000000000000..3acd9b702e186 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.js @@ -0,0 +1,14 @@ +//// [tsxAttributeResolution.tsx] +/// @jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + x: { y: number; z: string; }; + } +} + + + + +//// [tsxAttributeResolution.jsx] +/// @jsx: preserve diff --git a/tests/baselines/reference/tsxAttributeResolution.symbols b/tests/baselines/reference/tsxAttributeResolution.symbols new file mode 100644 index 0000000000000..06a0b32f6379a --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution.tsx === +/// @jsx: preserve + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeResolution.tsx, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution.tsx, 2, 23)) + + x: { y: number; z: string; }; +>x : Symbol(x, Decl(tsxAttributeResolution.tsx, 3, 30)) +>y : Symbol(y, Decl(tsxAttributeResolution.tsx, 4, 6)) +>z : Symbol(z, Decl(tsxAttributeResolution.tsx, 4, 17)) + } +} + + + diff --git a/tests/baselines/reference/tsxAttributeResolution.types b/tests/baselines/reference/tsxAttributeResolution.types new file mode 100644 index 0000000000000..5e54c43bf80f4 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution.tsx === +/// @jsx: preserve + +declare namespace JSX { +>JSX : any + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + x: { y: number; z: string; }; +>x : { y: number; z: string; } +>y : number +>z : string + } +} + + + diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt new file mode 100644 index 0000000000000..54666f46abac9 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(22,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (6 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + } + } + interface Attribs1 { + x?: number; + s?: string; + } + + // OK + ; // OK + ; // OK + ; // OK + + ; // OK + ; // OK + + // Errors + ; // Error, '0' is not number + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ; // Error, no property "y" + ~ +!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ; // Error, no property "y" + ~ +!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ; // Error, "32" is not number + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + // TODO attribute 'var' should be parseable + // ; // Error, no 'var' property + + ; // Error, missing reqd + ~~~~~~~~~ +!!! error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. + ; // Error, reqd is not string + ~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution1.js b/tests/baselines/reference/tsxAttributeResolution1.js new file mode 100644 index 0000000000000..011ac8034e2ce --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution1.js @@ -0,0 +1,50 @@ +//// [tsxAttributeResolution1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + } +} +interface Attribs1 { + x?: number; + s?: string; +} + +// OK +; // OK +; // OK +; // OK + +; // OK +; // OK + +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property + +; // Error, missing reqd +; // Error, reqd is not string + + + +//// [tsxAttributeResolution1.jsx] +// OK +; // OK +; // OK +; // OK +; // OK +; // OK +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property +; // Error, missing reqd +; // Error, reqd is not string diff --git a/tests/baselines/reference/tsxAttributeResolution2.errors.txt b/tests/baselines/reference/tsxAttributeResolution2.errors.txt new file mode 100644 index 0000000000000..d213ccaf54eb5 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution2.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/jsx/tsxAttributeResolution2.tsx(17,21): error TS2339: Property 'leng' does not exist on type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution2.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + c1?: (x: string) => void; + } + + // OK + x.length} />; // OK + x.leng} />; // OK + + + // Errors + x.leng} />; // Error, no leng on 'string' + ~~~~ +!!! error TS2339: Property 'leng' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution2.js b/tests/baselines/reference/tsxAttributeResolution2.js new file mode 100644 index 0000000000000..564767e6169b5 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution2.js @@ -0,0 +1,26 @@ +//// [tsxAttributeResolution2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + c1?: (x: string) => void; +} + +// OK + x.length} />; // OK + x.leng} />; // OK + + +// Errors + x.leng} />; // Error, no leng on 'string' + + +//// [tsxAttributeResolution2.jsx] +// OK +; // OK +; // OK +// Errors +; // Error, no leng on 'string' diff --git a/tests/baselines/reference/tsxAttributeResolution3.errors.txt b/tests/baselines/reference/tsxAttributeResolution3.errors.txt new file mode 100644 index 0000000000000..c797362e8d770 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution3.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(19,8): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(23,1): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(31,15): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(39,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution3.tsx (4 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + x: string; + y?: number; + z?: string; + } + + // OK + var obj1 = { x: 'foo' }; + + + // Error, x is not string + var obj2 = { x: 32 }; + + ~~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // Error, x is missing + var obj3 = { y: 32 }; + + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + + // OK + var obj4 = { x: 32, y: 32 }; + + + // Error + var obj5 = { x: 32, y: 32 }; + + ~~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // OK + var obj6 = { x: 'ok', y: 32, extra: 100 }; + + + // Error + var obj7 = { x: 'foo' }; + + ~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution3.js b/tests/baselines/reference/tsxAttributeResolution3.js new file mode 100644 index 0000000000000..8cf853820e19a --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution3.js @@ -0,0 +1,64 @@ +//// [tsxAttributeResolution3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x: string; + y?: number; + z?: string; +} + +// OK +var obj1 = { x: 'foo' }; + + +// Error, x is not string +var obj2 = { x: 32 }; + + +// Error, x is missing +var obj3 = { y: 32 }; + + +// OK +var obj4 = { x: 32, y: 32 }; + + +// Error +var obj5 = { x: 32, y: 32 }; + + +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; + + +// Error +var obj7 = { x: 'foo' }; + + + +//// [tsxAttributeResolution3.jsx] +// OK +var obj1 = { x: 'foo' }; +; +// Error, x is not string +var obj2 = { x: 32 }; +; +// Error, x is missing +var obj3 = { y: 32 }; +; +// OK +var obj4 = { x: 32, y: 32 }; +; +// Error +var obj5 = { x: 32, y: 32 }; +; +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; +; +// Error +var obj7 = { x: 'foo' }; +; diff --git a/tests/baselines/reference/tsxAttributeResolution4.errors.txt b/tests/baselines/reference/tsxAttributeResolution4.errors.txt new file mode 100644 index 0000000000000..211a349b30456 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution4.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/jsx/tsxAttributeResolution4.tsx(15,26): error TS2339: Property 'len' does not exist on type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution4.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + x(n: string): void; + } + + // OK + 0} } />; + + // Error, no member 'len' on 'string' + n.len} } />; + ~~~ +!!! error TS2339: Property 'len' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution4.js b/tests/baselines/reference/tsxAttributeResolution4.js new file mode 100644 index 0000000000000..d56cb4cc2e808 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution4.js @@ -0,0 +1,23 @@ +//// [tsxAttributeResolution4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x(n: string): void; +} + +// OK + 0} } />; + +// Error, no member 'len' on 'string' + n.len} } />; + + +//// [tsxAttributeResolution4.jsx] +// OK +; +// Error, no member 'len' on 'string' +; diff --git a/tests/baselines/reference/tsxAttributeResolution5.errors.txt b/tests/baselines/reference/tsxAttributeResolution5.errors.txt new file mode 100644 index 0000000000000..1b42dd014655d --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution5.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(21,16): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution5.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } + } + interface Attribs1 { + x: string; + } + + interface Attribs2 { + toString(): string; + } + + function make1 (obj: T) { + return ; // OK + } + + function make2 (obj: T) { + return ; // Error (x is number, not string) + ~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + } + + function make3 (obj: T) { + return ; // Error, missing x + ~~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + } + + + ; // Error, missing x + ~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution5.js b/tests/baselines/reference/tsxAttributeResolution5.js new file mode 100644 index 0000000000000..34fe9a3bfb6c7 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution5.js @@ -0,0 +1,45 @@ +//// [tsxAttributeResolution5.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } +} +interface Attribs1 { + x: string; +} + +interface Attribs2 { + toString(): string; +} + +function make1 (obj: T) { + return ; // OK +} + +function make2 (obj: T) { + return ; // Error (x is number, not string) +} + +function make3 (obj: T) { + return ; // Error, missing x +} + + +; // Error, missing x +; // OK + + +//// [tsxAttributeResolution5.jsx] +function make1(obj) { + return ; // OK +} +function make2(obj) { + return ; // Error (x is number, not string) +} +function make3(obj) { + return ; // Error, missing x +} +; // Error, missing x +; // OK diff --git a/tests/baselines/reference/tsxAttributeResolution6.errors.txt b/tests/baselines/reference/tsxAttributeResolution6.errors.txt new file mode 100644 index 0000000000000..4f1960358a560 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution6.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(10,8): error TS2322: Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(11,8): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: boolean; }'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution6.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } + } + + // Error + ; + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + ; + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + ; + ~~~~~~~~~ +!!! error TS2324: Property 'n' is missing in type '{ n: boolean; }'. + + // OK + ; + ; + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution6.js b/tests/baselines/reference/tsxAttributeResolution6.js new file mode 100644 index 0000000000000..f4af0ba875acb --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution6.js @@ -0,0 +1,29 @@ +//// [tsxAttributeResolution6.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } +} + +// Error +; +; +; + +// OK +; +; +; + + +//// [tsxAttributeResolution6.jsx] +// Error +; +; +; +// OK +; +; +; diff --git a/tests/baselines/reference/tsxAttributeResolution7.errors.txt b/tests/baselines/reference/tsxAttributeResolution7.errors.txt new file mode 100644 index 0000000000000..4d05254ace8d5 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution7.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/jsx/tsxAttributeResolution7.tsx(9,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution7.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } + } + + // Error + ; + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // OK + ; + ; + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution7.js b/tests/baselines/reference/tsxAttributeResolution7.js new file mode 100644 index 0000000000000..7ebd2e8f4db8a --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution7.js @@ -0,0 +1,24 @@ +//// [tsxAttributeResolution7.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Error +; + +// OK +; +; +; + + +//// [tsxAttributeResolution7.jsx] +// Error +; +// OK +; +; +; diff --git a/tests/baselines/reference/tsxElementResolution.errors.txt b/tests/baselines/reference/tsxElementResolution.errors.txt new file mode 100644 index 0000000000000..4e5cb93b00769 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/jsx/tsxElementResolution.tsx(18,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxElementResolution.tsx(19,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxElementResolution.tsx(23,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxElementResolution.tsx(24,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. + + +==== tests/cases/conformance/jsx/tsxElementResolution.tsx (4 errors) ==== + + declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } + } + + class foundFirst { } + class Other {} + + module Dotted { + export class Name { } + } + + // Should find the intrinsic element, not the class element + var a = ; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + var b = ; + ~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + // TODO: This should not be a parse error (should + // parse a property name here, not identifier) + // var c = ; + var d = ; + ~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + var e = ; + ~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution.js b/tests/baselines/reference/tsxElementResolution.js new file mode 100644 index 0000000000000..e7a4ae95e9479 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.js @@ -0,0 +1,55 @@ +//// [tsxElementResolution.tsx] + +declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } +} + +class foundFirst { } +class Other {} + +module Dotted { + export class Name { } +} + +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; + + +//// [tsxElementResolution.jsx] +var foundFirst = (function () { + function foundFirst() { + } + return foundFirst; +})(); +var Other = (function () { + function Other() { + } + return Other; +})(); +var Dotted; +(function (Dotted) { + var Name = (function () { + function Name() { + } + return Name; + })(); + Dotted.Name = Name; +})(Dotted || (Dotted = {})); +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; diff --git a/tests/baselines/reference/tsxElementResolution1.errors.txt b/tests/baselines/reference/tsxElementResolution1.errors.txt new file mode 100644 index 0000000000000..b54430bd106c8 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution1.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution1.tsx(12,1): error TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxElementResolution1.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } + } + + // OK +
; + + // Fail + ; + ~~~~~~~~ +!!! error TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution1.js b/tests/baselines/reference/tsxElementResolution1.js new file mode 100644 index 0000000000000..c7e0536bde28e --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution1.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +// OK +
; + +// Fail +; + +//// [tsxElementResolution1.jsx] +// OK +
; +// Fail +; diff --git a/tests/baselines/reference/tsxElementResolution10.errors.txt b/tests/baselines/reference/tsxElementResolution10.errors.txt new file mode 100644 index 0000000000000..987851191c53d --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution10.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/jsx/tsxElementResolution10.tsx(13,1): error TS2605: JSX element '{ x: number; }' is not a constructor function for JSX elements. + Property 'render' is missing in type '{ x: number; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution10.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): { x: number }; + } + var Obj1: Obj1type; + ; // Error, no render member + ~~~~~~~~~~~~~~~ +!!! error TS2605: JSX element '{ x: number; }' is not a constructor function for JSX elements. +!!! error TS2605: Property 'render' is missing in type '{ x: number; }'. + + interface Obj2type { + (n: string): { x: number; render: any; }; + } + var Obj2: Obj2type; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution10.js b/tests/baselines/reference/tsxElementResolution10.js new file mode 100644 index 0000000000000..84c8619ab9635 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution10.js @@ -0,0 +1,27 @@ +//// [tsxElementResolution10.tsx] +declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): { x: number }; +} +var Obj1: Obj1type; +; // Error, no render member + +interface Obj2type { + (n: string): { x: number; render: any; }; +} +var Obj2: Obj2type; +; // OK + + +//// [tsxElementResolution10.jsx] +var Obj1; +; // Error, no render member +var Obj2; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution11.errors.txt b/tests/baselines/reference/tsxElementResolution11.errors.txt new file mode 100644 index 0000000000000..4f3ee00d82f00 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution11.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxElementResolution11.tsx(17,7): error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution11.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): any; + } + var Obj1: Obj1type; + ; // OK + + interface Obj2type { + new(n: string): { q?: number }; + } + var Obj2: Obj2type; + ; // Error + ~ +!!! error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + + interface Obj3type { + new(n: string): { x: number; }; + } + var Obj3: Obj3type; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution11.js b/tests/baselines/reference/tsxElementResolution11.js new file mode 100644 index 0000000000000..fb8572116b16f --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution11.js @@ -0,0 +1,33 @@ +//// [tsxElementResolution11.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number }; +} +var Obj2: Obj2type; +; // Error + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // OK + + +//// [tsxElementResolution11.jsx] +var Obj1; +; // OK +var Obj2; +; // Error +var Obj3; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution12.errors.txt b/tests/baselines/reference/tsxElementResolution12.errors.txt new file mode 100644 index 0000000000000..71a22b502aa34 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution12.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/jsx/tsxElementResolution12.tsx(17,2): error TS2304: Cannot find name 'Obj2'. +tests/cases/conformance/jsx/tsxElementResolution12.tsx(23,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property +tests/cases/conformance/jsx/tsxElementResolution12.tsx(30,7): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/jsx/tsxElementResolution12.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): any; + } + var Obj1: Obj1type; + ; // OK + + interface Obj2type { + new(n: string): { q?: number; pr: any }; + } + var obj2: Obj2type; + ; // OK + ~~~~ +!!! error TS2304: Cannot find name 'Obj2'. + + interface Obj3type { + new(n: string): { x: number; }; + } + var Obj3: Obj3type; + ; // Error + ~~~~~~~~~~~~~~~ +!!! error TS2607: JSX element class does not support attributes because it does not have a 'pr' property + + interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; + } + var Obj4: Obj4type; + ; // OK + ; // Error + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution12.js b/tests/baselines/reference/tsxElementResolution12.js new file mode 100644 index 0000000000000..12973efdda7a1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution12.js @@ -0,0 +1,43 @@ +//// [tsxElementResolution12.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number; pr: any }; +} +var obj2: Obj2type; +; // OK + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // Error + +interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; +} +var Obj4: Obj4type; +; // OK +; // Error + + +//// [tsxElementResolution12.jsx] +var Obj1; +; // OK +var obj2; +; // OK +var Obj3; +; // Error +var Obj4; +; // OK +; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.js b/tests/baselines/reference/tsxElementResolution13.js new file mode 100644 index 0000000000000..f8631bdec0c2b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.js @@ -0,0 +1,16 @@ +//// [tsxElementResolution13.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } +} + +interface Obj1 { + new(n: string): any; +} +var obj1: Obj1; +; // Error + + +//// [tsxElementResolution13.jsx] +var obj1; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.symbols b/tests/baselines/reference/tsxElementResolution13.symbols new file mode 100644 index 0000000000000..4022602e53a14 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsx/tsxElementResolution13.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution13.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution13.tsx, 0, 20)) + + interface ElementAttributesProperty { pr1: any; pr2: any; } +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(tsxElementResolution13.tsx, 1, 22)) +>pr1 : Symbol(pr1, Decl(tsxElementResolution13.tsx, 2, 38)) +>pr2 : Symbol(pr2, Decl(tsxElementResolution13.tsx, 2, 48)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution13.tsx, 3, 1)) + + new(n: string): any; +>n : Symbol(n, Decl(tsxElementResolution13.tsx, 6, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution13.tsx, 8, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution13.tsx, 3, 1)) + +; // Error +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types new file mode 100644 index 0000000000000..cd6265de0911a --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxElementResolution13.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface ElementAttributesProperty { pr1: any; pr2: any; } +>ElementAttributesProperty : ElementAttributesProperty +>pr1 : any +>pr2 : any +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): any; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // Error +> : JSX.Element +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution14.js b/tests/baselines/reference/tsxElementResolution14.js new file mode 100644 index 0000000000000..e1e440db5f3bc --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.js @@ -0,0 +1,15 @@ +//// [tsxElementResolution14.tsx] +declare module JSX { + interface Element { } +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // OK + + +//// [tsxElementResolution14.jsx] +var obj1; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution14.symbols b/tests/baselines/reference/tsxElementResolution14.symbols new file mode 100644 index 0000000000000..58236a4e462f6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxElementResolution14.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution14.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution14.tsx, 0, 20)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution14.tsx, 2, 1)) + + new(n: string): {}; +>n : Symbol(n, Decl(tsxElementResolution14.tsx, 5, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution14.tsx, 7, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution14.tsx, 2, 1)) + +; // OK +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types new file mode 100644 index 0000000000000..ef03187d28ecb --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxElementResolution14.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): {}; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // OK +> : JSX.Element +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution15.errors.txt b/tests/baselines/reference/tsxElementResolution15.errors.txt new file mode 100644 index 0000000000000..24480ab7f2b41 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution15.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution15.tsx(3,12): error TS2608: The global type 'JSX.ElementAttributesProperty' may not have more than one property + + +==== tests/cases/conformance/jsx/tsxElementResolution15.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2608: The global type 'JSX.ElementAttributesProperty' may not have more than one property + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): {}; + } + var Obj1: Obj1type; + ; // Error + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution15.js b/tests/baselines/reference/tsxElementResolution15.js new file mode 100644 index 0000000000000..831b3a54b413a --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution15.js @@ -0,0 +1,17 @@ +//// [tsxElementResolution15.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): {}; +} +var Obj1: Obj1type; +; // Error + + +//// [tsxElementResolution15.jsx] +var Obj1; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution16.errors.txt b/tests/baselines/reference/tsxElementResolution16.errors.txt new file mode 100644 index 0000000000000..3bdc9286c5679 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. + + +==== tests/cases/conformance/jsx/tsxElementResolution16.tsx (1 errors) ==== + declare module JSX { + } + + interface Obj1 { + new(n: string): {}; + } + var obj1: Obj1; + ; // Error (JSX.Element is missing) + ~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution16.js b/tests/baselines/reference/tsxElementResolution16.js new file mode 100644 index 0000000000000..c63c3b7f83a35 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.js @@ -0,0 +1,14 @@ +//// [tsxElementResolution16.tsx] +declare module JSX { +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // Error (JSX.Element is missing) + + +//// [tsxElementResolution16.jsx] +var obj1; +; // Error (JSX.Element is missing) diff --git a/tests/baselines/reference/tsxElementResolution17.js b/tests/baselines/reference/tsxElementResolution17.js new file mode 100644 index 0000000000000..cd8d7e13beb2f --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution17.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +declare module 'elements1' { + class MyElement { + + } +} + +declare module 'elements2' { + class MyElement { + + } +} + +//// [consumer.tsx] +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +import s2 = require('elements2'); +; + + +//// [file.jsx] +//// [consumer.jsx] +define(["require", "exports", 'elements1'], function (require, exports, s1) { + ; +}); diff --git a/tests/baselines/reference/tsxElementResolution17.symbols b/tests/baselines/reference/tsxElementResolution17.symbols new file mode 100644 index 0000000000000..0b4459552de39 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/consumer.tsx === +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +>s1 : Symbol(s1, Decl(consumer.tsx, 0, 0)) + +import s2 = require('elements2'); +>s2 : Symbol(s2, Decl(consumer.tsx, 2, 33)) + +; +>MyElement : Symbol(s1.MyElement, Decl(file.tsx, 6, 28)) + +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) +} + +declare module 'elements1' { + class MyElement { +>MyElement : Symbol(MyElement, Decl(file.tsx, 6, 28)) + + } +} + +declare module 'elements2' { + class MyElement { +>MyElement : Symbol(MyElement, Decl(file.tsx, 12, 28)) + + } +} + diff --git a/tests/baselines/reference/tsxElementResolution17.types b/tests/baselines/reference/tsxElementResolution17.types new file mode 100644 index 0000000000000..e6396a9a60be5 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsx/consumer.tsx === +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +>s1 : typeof s1 + +import s2 = require('elements2'); +>s2 : typeof s2 + +; +> : JSX.Element +>s1 : any +>MyElement : any + +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +declare module 'elements1' { + class MyElement { +>MyElement : MyElement + + } +} + +declare module 'elements2' { + class MyElement { +>MyElement : MyElement + + } +} + diff --git a/tests/baselines/reference/tsxElementResolution18.errors.txt b/tests/baselines/reference/tsxElementResolution18.errors.txt new file mode 100644 index 0000000000000..75d28616bf0d7 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution18.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsx/tsxElementResolution18.tsx(6,1): error TS2609: JSX element implicitly has type 'any' because no interface JSX.IntrinsicElements exists + + +==== tests/cases/conformance/jsx/tsxElementResolution18.tsx (1 errors) ==== + declare module JSX { + interface Element { } + } + + // Error under implicit any +
; + ~~~~~~~~~~~~~ +!!! error TS2609: JSX element implicitly has type 'any' because no interface JSX.IntrinsicElements exists + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution18.js b/tests/baselines/reference/tsxElementResolution18.js new file mode 100644 index 0000000000000..0b5138b7b4927 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution18.js @@ -0,0 +1,12 @@ +//// [tsxElementResolution18.tsx] +declare module JSX { + interface Element { } +} + +// Error under implicit any +
; + + +//// [tsxElementResolution18.jsx] +// Error under implicit any +
; diff --git a/tests/baselines/reference/tsxElementResolution2.js b/tests/baselines/reference/tsxElementResolution2.js new file mode 100644 index 0000000000000..1d06656d529a5 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: any; + } +} + +// OK +
; + +// OK +; + +//// [tsxElementResolution2.jsx] +// OK +
; +// OK +; diff --git a/tests/baselines/reference/tsxElementResolution2.symbols b/tests/baselines/reference/tsxElementResolution2.symbols new file mode 100644 index 0000000000000..2935bcd4f63d5 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxElementResolution2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + + [x: string]: any; +>x : Symbol(x, Decl(tsxElementResolution2.tsx, 3, 6)) + } +} + +// OK +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + +// OK +; +>span : Symbol(JSX.IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxElementResolution2.types b/tests/baselines/reference/tsxElementResolution2.types new file mode 100644 index 0000000000000..56ea51582539b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxElementResolution2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [x: string]: any; +>x : string + } +} + +// OK +
; +>
: JSX.Element +>div : any + +// OK +; +> : JSX.Element +>span : any + diff --git a/tests/baselines/reference/tsxElementResolution3.errors.txt b/tests/baselines/reference/tsxElementResolution3.errors.txt new file mode 100644 index 0000000000000..bc3c7c5ebfc55 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution3.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/jsx/tsxElementResolution3.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: string; }'. +tests/cases/conformance/jsx/tsxElementResolution3.tsx(12,7): error TS2339: Property 'w' does not exist on type '{ n: string; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution3.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } + } + + // OK +
; + + // Error + ; + ~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'n' is missing in type '{ n: string; }'. + ~ +!!! error TS2339: Property 'w' does not exist on type '{ n: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution3.js b/tests/baselines/reference/tsxElementResolution3.js new file mode 100644 index 0000000000000..607d1c5ec66fc --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution3.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } +} + +// OK +
; + +// Error +; + +//// [tsxElementResolution3.jsx] +// OK +
; +// Error +; diff --git a/tests/baselines/reference/tsxElementResolution4.errors.txt b/tests/baselines/reference/tsxElementResolution4.errors.txt new file mode 100644 index 0000000000000..0e383af5e7b13 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution4.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/jsx/tsxElementResolution4.tsx(16,1): error TS2324: Property 'm' is missing in type '{ m: string; }'. +tests/cases/conformance/jsx/tsxElementResolution4.tsx(16,7): error TS2339: Property 'q' does not exist on type '{ m: string; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution4.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } + } + + // OK +
; + + // OK + ; + + // Error + ; + ~~~~~~~~~~~~~ +!!! error TS2324: Property 'm' is missing in type '{ m: string; }'. + ~ +!!! error TS2339: Property 'q' does not exist on type '{ m: string; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution4.js b/tests/baselines/reference/tsxElementResolution4.js new file mode 100644 index 0000000000000..ea395cb507762 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution4.js @@ -0,0 +1,26 @@ +//// [tsxElementResolution4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } +} + +// OK +
; + +// OK +; + +// Error +; + + +//// [tsxElementResolution4.jsx] +// OK +
; +// OK +; +// Error +; diff --git a/tests/baselines/reference/tsxElementResolution5.js b/tests/baselines/reference/tsxElementResolution5.js new file mode 100644 index 0000000000000..8aadfec0f782e --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.js @@ -0,0 +1,12 @@ +//// [tsxElementResolution5.tsx] +declare module JSX { + interface Element { } +} + +// OK, but implicit any +
; + + +//// [tsxElementResolution5.jsx] +// OK, but implicit any +
; diff --git a/tests/baselines/reference/tsxElementResolution5.symbols b/tests/baselines/reference/tsxElementResolution5.symbols new file mode 100644 index 0000000000000..8bbbfaaeb689d --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsx/tsxElementResolution5.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution5.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution5.tsx, 0, 20)) +} + +// OK, but implicit any +
; +>n : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution5.types b/tests/baselines/reference/tsxElementResolution5.types new file mode 100644 index 0000000000000..ba3509f4fa135 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsx/tsxElementResolution5.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +// OK, but implicit any +
; +>
: JSX.Element +>div : any +>n : any + diff --git a/tests/baselines/reference/tsxElementResolution6.errors.txt b/tests/baselines/reference/tsxElementResolution6.errors.txt new file mode 100644 index 0000000000000..1336cc6df0c06 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxElementResolution6.tsx(8,1): error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxElementResolution6.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + var div: any; + // Still an error +
; + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution6.js b/tests/baselines/reference/tsxElementResolution6.js new file mode 100644 index 0000000000000..1b6d174fea8b0 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution6.js @@ -0,0 +1,15 @@ +//// [tsxElementResolution6.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +var div: any; +// Still an error +
; + + +//// [tsxElementResolution6.jsx] +var div; +// Still an error +
; diff --git a/tests/baselines/reference/tsxElementResolution7.errors.txt b/tests/baselines/reference/tsxElementResolution7.errors.txt new file mode 100644 index 0000000000000..b8549e19535ff --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution7.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxElementResolution7.tsx(12,5): error TS2339: Property 'other' does not exist on type 'typeof my'. +tests/cases/conformance/jsx/tsxElementResolution7.tsx(19,11): error TS2339: Property 'non' does not exist on type 'typeof my'. + + +==== tests/cases/conformance/jsx/tsxElementResolution7.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + module my { + export var div: any; + } + // OK + ; + // Error + ; + ~~~~~ +!!! error TS2339: Property 'other' does not exist on type 'typeof my'. + + module q { + import mine = my; + // OK + ; + // Error + ; + ~~~ +!!! error TS2339: Property 'non' does not exist on type 'typeof my'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution7.js b/tests/baselines/reference/tsxElementResolution7.js new file mode 100644 index 0000000000000..7df44b052a214 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution7.js @@ -0,0 +1,39 @@ +//// [tsxElementResolution7.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module my { + export var div: any; +} +// OK +; +// Error +; + +module q { + import mine = my; + // OK + ; + // Error + ; +} + + +//// [tsxElementResolution7.jsx] +var my; +(function (my) { +})(my || (my = {})); +// OK +; +// Error +; +var q; +(function (q) { + var mine = my; + // OK + ; + // Error + ; +})(q || (q = {})); diff --git a/tests/baselines/reference/tsxElementResolution8.errors.txt b/tests/baselines/reference/tsxElementResolution8.errors.txt new file mode 100644 index 0000000000000..644b43b471b50 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution8.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element 'Div' is not a constructor function. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(16,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(29,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element 'Obj3' is not a constructor function. + + +==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (4 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + // Error + var Div = 3; +
; + ~~~ +!!! error TS2604: JSX element 'Div' is not a constructor function. + + // OK + function Fact(): any { return null; } + + + // Error + function Fnum(): number{ return 42; } + + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj1 { + new(): {}; + (): number; + } + var Obj1: Obj1; + ; // OK, prefer construct signatures + + interface Obj2 { + (): number; + } + var Obj2: Obj2; + ; // Error + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj3 { + } + var Obj3: Obj3; + ; // Error + ~~~~ +!!! error TS2604: JSX element 'Obj3' is not a constructor function. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution8.js b/tests/baselines/reference/tsxElementResolution8.js new file mode 100644 index 0000000000000..4217761c4025c --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution8.js @@ -0,0 +1,53 @@ +//// [tsxElementResolution8.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +// Error +var Div = 3; +
; + +// OK +function Fact(): any { return null; } + + +// Error +function Fnum(): number{ return 42; } + + +interface Obj1 { + new(): {}; + (): number; +} +var Obj1: Obj1; +; // OK, prefer construct signatures + +interface Obj2 { + (): number; +} +var Obj2: Obj2; +; // Error + +interface Obj3 { +} +var Obj3: Obj3; +; // Error + + +//// [tsxElementResolution8.jsx] +// Error +var Div = 3; +
; +// OK +function Fact() { return null; } +; +// Error +function Fnum() { return 42; } +; +var Obj1; +; // OK, prefer construct signatures +var Obj2; +; // Error +var Obj3; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution9.errors.txt b/tests/baselines/reference/tsxElementResolution9.errors.txt new file mode 100644 index 0000000000000..f4412719b33b3 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/jsx/tsxElementResolution9.tsx(11,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution9.tsx(18,2): error TS2601: The return type of a JSX element constructor must return an object type. + + +==== tests/cases/conformance/jsx/tsxElementResolution9.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; + } + var Obj1: Obj1; + ; // Error, return type is not an object type + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; + } + var Obj2: Obj2; + ; // Error, return type is not an object type + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; + } + var Obj3: Obj3; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution9.js b/tests/baselines/reference/tsxElementResolution9.js new file mode 100644 index 0000000000000..c897a51eaeb56 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.js @@ -0,0 +1,35 @@ +//// [tsxElementResolution9.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; +} +var Obj1: Obj1; +; // Error, return type is not an object type + +interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; +} +var Obj2: Obj2; +; // Error, return type is not an object type + +interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; +} +var Obj3: Obj3; +; // OK + + +//// [tsxElementResolution9.jsx] +var Obj1; +; // Error, return type is not an object type +var Obj2; +; // Error, return type is not an object type +var Obj3; +; // OK diff --git a/tests/baselines/reference/tsxEmit1.js b/tests/baselines/reference/tsxEmit1.js new file mode 100644 index 0000000000000..baa75526dd775 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.js @@ -0,0 +1,75 @@ +//// [tsxEmit1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; + + +//// [tsxEmit1.jsx] +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 =
{function () { return _this; }}
; + var rewrites2 =
{[p].concat(p, [p])}
; + var rewrites3 =
{{ p: p }}
; + var rewrites4 =
; + var rewrites5 =
; + var rewrites6 =
; + }; + return SomeClass; +})(); +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols new file mode 100644 index 0000000000000..284f6cd9ce748 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -0,0 +1,144 @@ +=== tests/cases/conformance/jsx/tsxEmit1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit1.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxEmit1.tsx, 3, 3)) + } +} + +var p; +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +var selfClosed1 =
; +>selfClosed1 : Symbol(selfClosed1, Decl(tsxEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var selfClosed2 =
; +>selfClosed2 : Symbol(selfClosed2, Decl(tsxEmit1.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed3 =
; +>selfClosed3 : Symbol(selfClosed3, Decl(tsxEmit1.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed4 =
; +>selfClosed4 : Symbol(selfClosed4, Decl(tsxEmit1.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed5 =
; +>selfClosed5 : Symbol(selfClosed5, Decl(tsxEmit1.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed6 =
; +>selfClosed6 : Symbol(selfClosed6, Decl(tsxEmit1.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed7 =
; +>selfClosed7 : Symbol(selfClosed7, Decl(tsxEmit1.tsx, 14, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var openClosed1 =
; +>openClosed1 : Symbol(openClosed1, Decl(tsxEmit1.tsx, 16, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var openClosed2 =
foo
; +>openClosed2 : Symbol(openClosed2, Decl(tsxEmit1.tsx, 17, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed3 =
{p}
; +>openClosed3 : Symbol(openClosed3, Decl(tsxEmit1.tsx, 18, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed4 =
{p < p}
; +>openClosed4 : Symbol(openClosed4, Decl(tsxEmit1.tsx, 19, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +var openClosed5 =
{p > p}
; +>openClosed5 : Symbol(openClosed5, Decl(tsxEmit1.tsx, 20, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + f() { +>f : Symbol(f, Decl(tsxEmit1.tsx, 22, 17)) + + var rewrites1 =
{() => this}
; +>rewrites1 : Symbol(rewrites1, Decl(tsxEmit1.tsx, 24, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : Symbol(rewrites2, Decl(tsxEmit1.tsx, 25, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + + var rewrites3 =
{{p}}
; +>rewrites3 : Symbol(rewrites3, Decl(tsxEmit1.tsx, 26, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 26, 25)) + + var rewrites4 =
this}>
; +>rewrites4 : Symbol(rewrites4, Decl(tsxEmit1.tsx, 28, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + var rewrites5 =
; +>rewrites5 : Symbol(rewrites5, Decl(tsxEmit1.tsx, 29, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + + var rewrites6 =
; +>rewrites6 : Symbol(rewrites6, Decl(tsxEmit1.tsx, 30, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 30, 27)) + } +} + +var whitespace1 =
; +>whitespace1 : Symbol(whitespace1, Decl(tsxEmit1.tsx, 34, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var whitespace2 =
{p}
; +>whitespace2 : Symbol(whitespace2, Decl(tsxEmit1.tsx, 35, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var whitespace3 =
+>whitespace3 : Symbol(whitespace3, Decl(tsxEmit1.tsx, 36, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + + {p} +
; + diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types new file mode 100644 index 0000000000000..667ec11333770 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.types @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/tsxEmit1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p; +>p : any + +var selfClosed1 =
; +>selfClosed1 : JSX.Element +>
: JSX.Element +>div : any + +var selfClosed2 =
; +>selfClosed2 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed3 =
; +>selfClosed3 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed4 =
; +>selfClosed4 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed5 =
; +>selfClosed5 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed6 =
; +>selfClosed6 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed7 =
; +>selfClosed7 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>p : any +>y : any + +var openClosed1 =
; +>openClosed1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var openClosed2 =
foo
; +>openClosed2 : JSX.Element +>
foo
: JSX.Element +>div : any +>n : any +>div : any + +var openClosed3 =
{p}
; +>openClosed3 : JSX.Element +>
{p}
: JSX.Element +>div : any +>n : any +>p : any +>div : any + +var openClosed4 =
{p < p}
; +>openClosed4 : JSX.Element +>
{p < p}
: JSX.Element +>div : any +>n : any +>p < p : boolean +>p : any +>p : any +>div : any + +var openClosed5 =
{p > p}
; +>openClosed5 : JSX.Element +>
{p > p}
: JSX.Element +>div : any +>n : any +>p > p : boolean +>p : any +>p : any +>div : any + +class SomeClass { +>SomeClass : SomeClass + + f() { +>f : () => void + + var rewrites1 =
{() => this}
; +>rewrites1 : JSX.Element +>
{() => this}
: JSX.Element +>div : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : JSX.Element +>
{[p, ...p, p]}
: JSX.Element +>div : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites3 =
{{p}}
; +>rewrites3 : JSX.Element +>
{{p}}
: JSX.Element +>div : any +>{p} : { p: any; } +>p : any +>div : any + + var rewrites4 =
this}>
; +>rewrites4 : JSX.Element +>
this}>
: JSX.Element +>div : any +>a : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites5 =
; +>rewrites5 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites6 =
; +>rewrites6 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>{p} : { p: any; } +>p : any +>div : any + } +} + +var whitespace1 =
; +>whitespace1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var whitespace2 =
{p}
; +>whitespace2 : JSX.Element +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +var whitespace3 =
+>whitespace3 : JSX.Element +>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + diff --git a/tests/baselines/reference/tsxEmit2.js b/tests/baselines/reference/tsxEmit2.js new file mode 100644 index 0000000000000..1101df49a1c43 --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.js @@ -0,0 +1,23 @@ +//// [tsxEmit2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; + + +//// [tsxEmit2.jsx] +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols new file mode 100644 index 0000000000000..28f6a9f5026fe --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxEmit2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxEmit2.tsx, 3, 3)) + } +} + +var p1, p2, p3; +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) + +var spreads1 =
{p2}
; +>spreads1 : Symbol(spreads1, Decl(tsxEmit2.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + +var spreads2 =
{p2}
; +>spreads2 : Symbol(spreads2, Decl(tsxEmit2.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + +var spreads3 =
{p2}
; +>spreads3 : Symbol(spreads3, Decl(tsxEmit2.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads4 =
{p2}
; +>spreads4 : Symbol(spreads4, Decl(tsxEmit2.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads5 =
{p2}
; +>spreads5 : Symbol(spreads5, Decl(tsxEmit2.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxEmit2.types b/tests/baselines/reference/tsxEmit2.types new file mode 100644 index 0000000000000..f5633b739e3b1 --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsx/tsxEmit2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p1, p2, p3; +>p1 : any +>p2 : any +>p3 : any + +var spreads1 =
{p2}
; +>spreads1 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads2 =
{p2}
; +>spreads2 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads3 =
{p2}
; +>spreads3 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p3 : any +>p1 : any +>p2 : any +>div : any + +var spreads4 =
{p2}
; +>spreads4 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>x : any +>p3 : any +>p2 : any +>div : any + +var spreads5 =
{p2}
; +>spreads5 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p2 : any +>p1 : any +>y : any +>p3 : any +>p2 : any +>div : any + diff --git a/tests/baselines/reference/tsxEmit3.js b/tests/baselines/reference/tsxEmit3.js new file mode 100644 index 0000000000000..beae73e2bf142 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.js @@ -0,0 +1,84 @@ +//// [tsxEmit3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module M { + export class Foo { constructor() { } } + export module S { + export class Bar { } + + // Emit Foo + // Foo, ; + } +} + +module M { + // Emit M.Foo + Foo, ; + + export module S { + // Emit M.Foo + Foo, ; + + // Emit S.Bar + Bar, ; + } + +} + +module M { + // Emit M.S.Bar + S.Bar, ; +} + +module M { + var M = 100; + // Emit M_1.Foo + Foo, ; +} + + +//// [tsxEmit3.jsx] +var M; +(function (M) { + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + M.Foo = Foo; + var S; + (function (S) { + var Bar = (function () { + function Bar() { + } + return Bar; + })(); + S.Bar = Bar; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.Foo + M.Foo, ; + var S; + (function (S) { + // Emit M.Foo + M.Foo, ; + // Emit S.Bar + S.Bar, ; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.S.Bar + M.S.Bar, ; +})(M || (M = {})); +var M; +(function (M_1) { + var M = 100; + // Emit M_1.Foo + M_1.Foo, ; +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxEmit3.symbols b/tests/baselines/reference/tsxEmit3.symbols new file mode 100644 index 0000000000000..4ceed0b9b1e84 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.symbols @@ -0,0 +1,75 @@ +=== tests/cases/conformance/jsx/tsxEmit3.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit3.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit3.tsx, 0, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit3.tsx, 1, 22)) +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + export class Foo { constructor() { } } +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + export module S { +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) + + export class Bar { } +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) + + // Emit Foo + // Foo, ; + } +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + // Emit M.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + export module S { +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) + + // Emit M.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + // Emit S.Bar + Bar, ; +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) + } + +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + // Emit M.S.Bar + S.Bar, ; +>S.Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + var M = 100; +>M : Symbol(M, Decl(tsxEmit3.tsx, 35, 4)) + + // Emit M_1.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +} + diff --git a/tests/baselines/reference/tsxEmit3.types b/tests/baselines/reference/tsxEmit3.types new file mode 100644 index 0000000000000..4bb92d9aea57b --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.types @@ -0,0 +1,87 @@ +=== tests/cases/conformance/jsx/tsxEmit3.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +module M { +>M : typeof M + + export class Foo { constructor() { } } +>Foo : Foo + + export module S { +>S : typeof S + + export class Bar { } +>Bar : Bar + + // Emit Foo + // Foo, ; + } +} + +module M { +>M : typeof M + + // Emit M.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo + + export module S { +>S : typeof S + + // Emit M.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo + + // Emit S.Bar + Bar, ; +>Bar, : JSX.Element +>Bar : typeof Bar +> : JSX.Element +>Bar : typeof Bar + } + +} + +module M { +>M : typeof M + + // Emit M.S.Bar + S.Bar, ; +>S.Bar, : JSX.Element +>S.Bar : typeof S.Bar +>S : typeof S +>Bar : typeof S.Bar +> : JSX.Element +>S : any +>Bar : any +} + +module M { +>M : typeof M + + var M = 100; +>M : number +>100 : number + + // Emit M_1.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo +} + diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js new file mode 100644 index 0000000000000..f493347ca9c4a --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js @@ -0,0 +1,46 @@ +//// [tsxGenericArrowFunctionParsing.tsx] +declare module JSX { + interface Element { isElement; } +} + +var T, T1, T2; + +// This is an element +var x1 = () => {}; +x1.isElement; + +// This is a generic function +var x2 = () => {}; +x2(); + +// This is a generic function +var x3 = () => {}; +x3(); + +// This is an element +var x4 = () => {}; +x4.isElement; + +// This is an element +var x5 = () => {}; +x5.isElement; + + + +//// [tsxGenericArrowFunctionParsing.jsx] +var T, T1, T2; +// This is an element +var x1 = () => ; +x1.isElement; +// This is a generic function +var x2 = function () { }; +x2(); +// This is a generic function +var x3 = function () { }; +x3(); +// This is an element +var x4 = () => ; +x4.isElement; +// This is an element +var x5 = () => ; +x5.isElement; diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols new file mode 100644 index 0000000000000..8bd68b2e8e7e5 --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxGenericArrowFunctionParsing.tsx, 0, 0)) + + interface Element { isElement; } +>Element : Symbol(Element, Decl(tsxGenericArrowFunctionParsing.tsx, 0, 20)) +>isElement : Symbol(isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +} + +var T, T1, T2; +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>T1 : Symbol(T1, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 6)) +>T2 : Symbol(T2, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 10)) + +// This is an element +var x1 = () => {}; +>x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) + +x1.isElement; +>x1.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + +// This is a generic function +var x2 = () => {}; +>x2 : Symbol(x2, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 10)) + +x2(); +>x2 : Symbol(x2, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 3)) + +// This is a generic function +var x3 = () => {}; +>x3 : Symbol(x3, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 10)) +>T1 : Symbol(T1, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 12)) + +x3(); +>x3 : Symbol(x3, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 3)) + +// This is an element +var x4 = () => {}; +>x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>extends : Symbol(unknown) + +x4.isElement; +>x4.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + +// This is an element +var x5 = () => {}; +>x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>extends : Symbol(unknown) + +x5.isElement; +>x5.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + + diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types new file mode 100644 index 0000000000000..a7d98d35b640a --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types @@ -0,0 +1,75 @@ +=== tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx === +declare module JSX { +>JSX : any + + interface Element { isElement; } +>Element : Element +>isElement : any +} + +var T, T1, T2; +>T : any +>T1 : any +>T2 : any + +// This is an element +var x1 = () => {}; +>x1 : JSX.Element +>() => {} : JSX.Element +>T : any +>T : any + +x1.isElement; +>x1.isElement : any +>x1 : JSX.Element +>isElement : any + +// This is a generic function +var x2 = () => {}; +>x2 : () => void +>() => {} : () => void +>T : T + +x2(); +>x2() : void +>x2 : () => void + +// This is a generic function +var x3 = () => {}; +>x3 : () => void +>() => {} : () => void +>T : T +>T1 : T1 + +x3(); +>x3() : void +>x3 : () => void + +// This is an element +var x4 = () => {}; +>x4 : JSX.Element +>() => {} : JSX.Element +>T : any +>extends : any +>true : boolean +>T : any + +x4.isElement; +>x4.isElement : any +>x4 : JSX.Element +>isElement : any + +// This is an element +var x5 = () => {}; +>x5 : JSX.Element +>() => {} : JSX.Element +>T : any +>extends : any +>T : any + +x5.isElement; +>x5.isElement : any +>x5 : JSX.Element +>isElement : any + + diff --git a/tests/baselines/reference/tsxNoJsx.errors.txt b/tests/baselines/reference/tsxNoJsx.errors.txt new file mode 100644 index 0000000000000..9e5c6762c9eaf --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/jsx/tsxNoJsx.tsx(2,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. + + +==== tests/cases/conformance/jsx/tsxNoJsx.tsx (1 errors) ==== + + ; + ~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxNoJsx.js b/tests/baselines/reference/tsxNoJsx.js new file mode 100644 index 0000000000000..37663adf2a75f --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.js @@ -0,0 +1,7 @@ +//// [tsxNoJsx.tsx] + +; + + +//// [tsxNoJsx.jsx] +; diff --git a/tests/baselines/reference/tsxParseTests1.js b/tests/baselines/reference/tsxParseTests1.js new file mode 100644 index 0000000000000..7ab98cab31441 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.js @@ -0,0 +1,11 @@ +//// [tsxParseTests1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; + + +//// [tsxParseTests1.jsx] +var x =
; diff --git a/tests/baselines/reference/tsxParseTests1.symbols b/tests/baselines/reference/tsxParseTests1.symbols new file mode 100644 index 0000000000000..dbe11dbcbba35 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxParseTests1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxParseTests1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxParseTests1.tsx, 0, 20)) + + interface IntrinsicElements { div; span; } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxParseTests1.tsx, 1, 22)) +>div : Symbol(div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(span, Decl(tsxParseTests1.tsx, 2, 35)) +} + +var x =
; +>x : Symbol(x, Decl(tsxParseTests1.tsx, 5, 3)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(tsxParseTests1.tsx, 2, 35)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxParseTests1.types b/tests/baselines/reference/tsxParseTests1.types new file mode 100644 index 0000000000000..78e49a227e224 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxParseTests1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { div; span; } +>IntrinsicElements : IntrinsicElements +>div : any +>span : any +} + +var x =
; +>x : JSX.Element +>
: JSX.Element +>div : any +>
: JSX.Element +>div : any +>
: JSX.Element +>span : any +>
: JSX.Element +>div : any +>div : any +>span : any +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js new file mode 100644 index 0000000000000..c461987c77d0b --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -0,0 +1,73 @@ +//// [tsxReactEmit1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; + + +//// [tsxReactEmit1.js] +var p; +var selfClosed1 = React.createElement("div", null); +var selfClosed2 = React.createElement("div", {x: "1"}); +var selfClosed3 = React.createElement("div", {x: '1'}); +var selfClosed4 = React.createElement("div", {x: "1", y: '0'}); +var selfClosed5 = React.createElement("div", {x: 0, y: '0'}); +var selfClosed6 = React.createElement("div", {x: "1", y: '0'}); +var selfClosed7 = React.createElement("div", {x: p, y: 'p'}); +var openClosed1 = React.createElement("div", null); +var openClosed2 = React.createElement("div", {n: 'm'}, "foo"); +var openClosed3 = React.createElement("div", {n: 'm'}, p); +var openClosed4 = React.createElement("div", {n: 'm'}, p < p); +var openClosed5 = React.createElement("div", {n: 'm'}, p > p); +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 = React.createElement("div", null, function () { return _this; }); + var rewrites2 = React.createElement("div", null, [p].concat(p, [p])); + var rewrites3 = React.createElement("div", null, { p: p }); + var rewrites4 = React.createElement("div", {a: function () { return _this; }}); + var rewrites5 = React.createElement("div", {a: [p].concat(p, [p])}); + var rewrites6 = React.createElement("div", {a: { p: p }}); + }; + return SomeClass; +})(); +var whitespace1 = React.createElement("div", null, " "); +var whitespace2 = React.createElement("div", null, " ", p, " "); +var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols new file mode 100644 index 0000000000000..f35a78729151c --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -0,0 +1,144 @@ +=== tests/cases/conformance/jsx/tsxReactEmit1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmit1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmit1.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmit1.tsx, 3, 3)) + } +} + +var p; +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + +var selfClosed1 =
; +>selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var selfClosed2 =
; +>selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed3 =
; +>selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed4 =
; +>selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed5 =
; +>selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed6 =
; +>selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed7 =
; +>selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 14, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var openClosed1 =
; +>openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 16, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var openClosed2 =
foo
; +>openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 17, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed3 =
{p}
; +>openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 18, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed4 =
{p < p}
; +>openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 19, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + +var openClosed5 =
{p > p}
; +>openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 20, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 43)) + + f() { +>f : Symbol(f, Decl(tsxReactEmit1.tsx, 22, 17)) + + var rewrites1 =
{() => this}
; +>rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 24, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 43)) + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 25, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + + var rewrites3 =
{{p}}
; +>rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 26, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 26, 25)) + + var rewrites4 =
this}>
; +>rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 28, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 43)) + + var rewrites5 =
; +>rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 29, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + + var rewrites6 =
; +>rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 30, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 30, 27)) + } +} + +var whitespace1 =
; +>whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 34, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var whitespace2 =
{p}
; +>whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 35, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var whitespace3 =
+>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 36, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + + {p} +
; + diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types new file mode 100644 index 0000000000000..d58316b14cfd2 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/tsxReactEmit1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p; +>p : any + +var selfClosed1 =
; +>selfClosed1 : JSX.Element +>
: JSX.Element +>div : any + +var selfClosed2 =
; +>selfClosed2 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed3 =
; +>selfClosed3 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed4 =
; +>selfClosed4 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed5 =
; +>selfClosed5 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed6 =
; +>selfClosed6 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed7 =
; +>selfClosed7 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>p : any +>y : any + +var openClosed1 =
; +>openClosed1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var openClosed2 =
foo
; +>openClosed2 : JSX.Element +>
foo
: JSX.Element +>div : any +>n : any +>div : any + +var openClosed3 =
{p}
; +>openClosed3 : JSX.Element +>
{p}
: JSX.Element +>div : any +>n : any +>p : any +>div : any + +var openClosed4 =
{p < p}
; +>openClosed4 : JSX.Element +>
{p < p}
: JSX.Element +>div : any +>n : any +>p < p : boolean +>p : any +>p : any +>div : any + +var openClosed5 =
{p > p}
; +>openClosed5 : JSX.Element +>
{p > p}
: JSX.Element +>div : any +>n : any +>p > p : boolean +>p : any +>p : any +>div : any + +class SomeClass { +>SomeClass : SomeClass + + f() { +>f : () => void + + var rewrites1 =
{() => this}
; +>rewrites1 : JSX.Element +>
{() => this}
: JSX.Element +>div : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : JSX.Element +>
{[p, ...p, p]}
: JSX.Element +>div : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites3 =
{{p}}
; +>rewrites3 : JSX.Element +>
{{p}}
: JSX.Element +>div : any +>{p} : { p: any; } +>p : any +>div : any + + var rewrites4 =
this}>
; +>rewrites4 : JSX.Element +>
this}>
: JSX.Element +>div : any +>a : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites5 =
; +>rewrites5 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites6 =
; +>rewrites6 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>{p} : { p: any; } +>p : any +>div : any + } +} + +var whitespace1 =
; +>whitespace1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var whitespace2 =
{p}
; +>whitespace2 : JSX.Element +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +var whitespace3 =
+>whitespace3 : JSX.Element +>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js new file mode 100644 index 0000000000000..c19d9958ad441 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -0,0 +1,23 @@ +//// [tsxReactEmit2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; + + +//// [tsxReactEmit2.js] +var p1, p2, p3; +var spreads1 = React.createElement("div", React.__spread(p1), p2); +var spreads2 = React.createElement("div", React.__spread(p1), p2); +var spreads3 = React.createElement("div", React.__spread({x: p3}, p1), p2); +var spreads4 = React.createElement("div", React.__spread(p1, {x: p3}), p2); +var spreads5 = React.createElement("div", React.__spread({x: p2}, p1, {y: p3}), p2); diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols new file mode 100644 index 0000000000000..9607d9330da48 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxReactEmit2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmit2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmit2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmit2.tsx, 3, 3)) + } +} + +var p1, p2, p3; +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 7, 7)) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 7, 11)) + +var spreads1 =
{p2}
; +>spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + +var spreads2 =
{p2}
; +>spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + +var spreads3 =
{p2}
; +>spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads4 =
{p2}
; +>spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads5 =
{p2}
; +>spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types new file mode 100644 index 0000000000000..9f8d6e494d0dd --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsx/tsxReactEmit2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p1, p2, p3; +>p1 : any +>p2 : any +>p3 : any + +var spreads1 =
{p2}
; +>spreads1 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads2 =
{p2}
; +>spreads2 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads3 =
{p2}
; +>spreads3 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p3 : any +>p1 : any +>p2 : any +>div : any + +var spreads4 =
{p2}
; +>spreads4 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>x : any +>p3 : any +>p2 : any +>div : any + +var spreads5 =
{p2}
; +>spreads5 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p2 : any +>p1 : any +>y : any +>p3 : any +>p2 : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js new file mode 100644 index 0000000000000..9885effa48fba --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -0,0 +1,10 @@ +//// [tsxReactEmit3.tsx] + +declare module JSX { interface Element { } } + +declare var Foo, Bar, baz; + + q s ; + +//// [tsxReactEmit3.js] +React.createElement(Foo, null, " ", React.createElement(Bar, null, " q "), " ", React.createElement(Bar, null), " s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols new file mode 100644 index 0000000000000..8ef0ccab2419a --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsx/tsxReactEmit3.tsx === + +declare module JSX { interface Element { } } +>JSX : Symbol(JSX, Decl(tsxReactEmit3.tsx, 0, 0)) +>Element : Symbol(Element, Decl(tsxReactEmit3.tsx, 1, 20)) + +declare var Foo, Bar, baz; +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 3, 21)) + + q s ; +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) + diff --git a/tests/baselines/reference/tsxReactEmit3.types b/tests/baselines/reference/tsxReactEmit3.types new file mode 100644 index 0000000000000..9e5d9fece5642 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxReactEmit3.tsx === + +declare module JSX { interface Element { } } +>JSX : any +>Element : Element + +declare var Foo, Bar, baz; +>Foo : any +>Bar : any +>baz : any + + q s ; +> q s : JSX.Element +>Foo : any +> q : JSX.Element +>Bar : any +>Bar : any +> : JSX.Element +>Bar : any +> : JSX.Element +>Bar : any +> : JSX.Element +>Bar : any +>Foo : any + diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt new file mode 100644 index 0000000000000..82cacd39e2820 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find name 'blah'. + + +==== tests/cases/conformance/jsx/tsxReactEmit4.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } + } + + var p; + var openClosed1 =
+ + {blah} + ~~~~ +!!! error TS2304: Cannot find name 'blah'. + +
; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js new file mode 100644 index 0000000000000..b162b17ad7f1f --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -0,0 +1,19 @@ +//// [tsxReactEmit4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var openClosed1 =
+ + {blah} + +
; + + +//// [tsxReactEmit4.js] +var p; +var openClosed1 = React.createElement("div", null, blah); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js new file mode 100644 index 0000000000000..69bceb7a0e947 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -0,0 +1,75 @@ +//// [tsxReactEmitWhitespace.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +// Emit " " +
; +// Emit " ", p, " " +
{p}
; +// Emit only p +
+ {p} +
; + +// Emit only p +
+ {p} +
; + +// Emit " 3" +
3 +
; + +// Emit " 3 " +
3
; + +// Emit "3" +
+ 3 +
; + +// Emit no args +
+
; + +// Emit "foo" + ' ' + "bar" +
+ + foo + + bar + +
; + + + +//// [tsxReactEmitWhitespace.js] +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT +var p = 0; +// Emit " " +React.createElement("div", null, " "); +// Emit " ", p, " " +React.createElement("div", null, " ", p, " "); +// Emit only p +React.createElement("div", null, p); +// Emit only p +React.createElement("div", null, p); +// Emit " 3" +React.createElement("div", null, " 3"); +// Emit " 3 " +React.createElement("div", null, " 3 "); +// Emit "3" +React.createElement("div", null, "3"); +// Emit no args +React.createElement("div", null); +// Emit "foo" + ' ' + "bar" +React.createElement("div", null, "foo" + ' ' + "bar"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols new file mode 100644 index 0000000000000..afbb694498197 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -0,0 +1,77 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitWhitespace.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitWhitespace.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitWhitespace.tsx, 3, 3)) + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 10, 3)) + +// Emit " " +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit " ", p, " " +
{p}
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit only p +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + {p} +
; + +// Emit only p +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + {p} +
; + +// Emit " 3" +
3 +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +
; + +// Emit " 3 " +
3
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit "3" +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + 3 +
; + +// Emit no args +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +
; + +// Emit "foo" + ' ' + "bar" +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + foo + + bar + +
; + + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types new file mode 100644 index 0000000000000..e0e3639fa9b20 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -0,0 +1,101 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +>p : number +>0 : number + +// Emit " " +
; +>
: JSX.Element +>div : any +>div : any + +// Emit " ", p, " " +
{p}
; +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +// Emit only p +
+>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + +// Emit only p +
+>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + +// Emit " 3" +
3 +>
3
: JSX.Element +>div : any + +
; +>div : any + +// Emit " 3 " +
3
; +>
3
: JSX.Element +>div : any +>div : any + +// Emit "3" +
+>
3
: JSX.Element +>div : any + + 3 +
; +>div : any + +// Emit no args +
+>
: JSX.Element +>div : any + +
; +>div : any + +// Emit "foo" + ' ' + "bar" +
+>
foo bar
: JSX.Element +>div : any + + foo + + bar + +
; +>div : any + + diff --git a/tests/baselines/reference/tsxTypeErrors.errors.txt b/tests/baselines/reference/tsxTypeErrors.errors.txt new file mode 100644 index 0000000000000..42959efe6fe4b --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.errors.txt @@ -0,0 +1,55 @@ +tests/cases/conformance/jsx/tsxTypeErrors.tsx(3,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxTypeErrors.tsx(6,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxTypeErrors.tsx(10,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxTypeErrors.tsx(13,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxTypeErrors.tsx(26,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxTypeErrors.tsx(32,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. + + +==== tests/cases/conformance/jsx/tsxTypeErrors.tsx (6 errors) ==== + + // A built-in element (OK) + var a1 =
; + ~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + // A built-in element with a mistyped property (error) + var a2 = + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + // A built-in element with a badly-typed attribute value (error) + var thing = { oops: 100 }; + var a3 =
+ ~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + // Mistyped html name (error) + var e1 = + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + // A custom type + class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } + } + + // Let's use it + // TODO: Error on missing 'reqd' + var b1 = ; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + // Mistyped attribute member + // sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. + // Types of property 'y' are incompatible. + // Type 'string' is not assignable to type 'number'. + var b2 = ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + + \ No newline at end of file diff --git a/tests/baselines/reference/tsxTypeErrors.js b/tests/baselines/reference/tsxTypeErrors.js new file mode 100644 index 0000000000000..f195a459747bd --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.js @@ -0,0 +1,60 @@ +//// [tsxTypeErrors.tsx] + +// A built-in element (OK) +var a1 =
; + +// A built-in element with a mistyped property (error) +var a2 = + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
+ +// Mistyped html name (error) +var e1 = + +// A custom type +class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; + + + +//// [tsxTypeErrors.jsx] +// A built-in element (OK) +var a1 =
; +// A built-in element with a mistyped property (error) +var a2 = ; +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
; +// Mistyped html name (error) +var e1 = ; +// A custom type +var MyClass = (function () { + function MyClass() { + } + return MyClass; +})(); +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; From 6dc430d8926868f23f8ac11cf3fe4d658a02ff04 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 14:18:10 -0700 Subject: [PATCH 104/250] constructor cannot have modifier 'abstract' --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2f7a66ad78c1e..e9977c9cd428d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12853,6 +12853,9 @@ namespace ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & NodeFlags.Protected) { return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } From c4876d53fd461cd7842396e0e1faa5de34c11c04 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 18 Jun 2015 14:26:22 -0700 Subject: [PATCH 105/250] Add support for awaiting union types with mixed promise and non-promise constituents. --- src/compiler/checker.ts | 166 ++++++++++-------- tests/baselines/reference/awaitUnion_es6.js | 24 +++ .../reference/awaitUnion_es6.symbols | 39 ++++ .../baselines/reference/awaitUnion_es6.types | 44 +++++ .../conformance/async/es6/awaitUnion_es6.ts | 14 ++ 5 files changed, 214 insertions(+), 73 deletions(-) create mode 100644 tests/baselines/reference/awaitUnion_es6.js create mode 100644 tests/baselines/reference/awaitUnion_es6.symbols create mode 100644 tests/baselines/reference/awaitUnion_es6.types create mode 100644 tests/cases/conformance/async/es6/awaitUnion_es6.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70ca1172ccbfa..83e5d3de18ca4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7653,7 +7653,7 @@ namespace ts { // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which we will wrap in // the native Promise type later in this function. - type = getAwaitedType(type, func, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, func, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); } } else { @@ -7762,7 +7762,7 @@ namespace ts { // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. - type = getAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); } if (!contains(aggregatedTypes, type)) { @@ -7914,7 +7914,7 @@ namespace ts { let exprType = checkExpression(node.body); if (returnType) { if (isAsync) { - let awaitedType = getAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + let awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); checkTypeAssignableTo(awaitedType, promisedType, node.body); } else { @@ -8041,7 +8041,7 @@ namespace ts { } let operandType = checkExpression(node.expression); - return getAwaitedType(operandType, node); + return checkAwaitedType(operandType, node); } function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { @@ -9474,10 +9474,10 @@ namespace ts { error(location, message); } - return false; + return unknownType; } - return true; + return type; } /** @@ -9537,7 +9537,7 @@ namespace ts { return getTypeAtPosition(signature, 0); } - let alreadySeenTypesForAwait: boolean[] = []; + let awaitedTypeStack: number[] = []; /** * Gets the "awaited type" of a type. @@ -9546,76 +9546,96 @@ namespace ts { * Promise-like type; otherwise, it is the type of the expression. This is used to reflect * The runtime behavior of the `await` keyword. */ - function getAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage): Type { - // reset the set of visited types - alreadySeenTypesForAwait.length = 0; - while (true) { - let promisedType = getPromisedType(type); - if (promisedType === undefined) { - // The type was not a PromiseLike, so it could not be unwrapped any further. - // As long as the type does not have a callable "then" property, then it is - // safe to return the type; otherwise, an error will have been reported in - // the call to checkNonThenableType and we will return unknownType. - // - // An example of a non-promise "thenable" might be: - // - // await { then(): void {} } - // - // The "thenable" does not match the minimal definition for a PromiseLike. When - // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise - // will never settle. We treat this as an error to help flag an early indicator - // of a runtime problem. If the user wants to return this value from an async - // function, they would need to wrap it in some other value. If they want it to - // be treated as a promise, they can cast to . - if (!checkNonThenableType(type, location, message)) { - type = unknownType; + function getAwaitedType(type: Type) { + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + } + + function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { + return getAwaitedTypeWorker(type); + + function getAwaitedTypeWorker(type: Type): Type { + if (type.flags & TypeFlags.Union) { + let types: Type[] = []; + for (let constituentType of (type).types) { + types.push(getAwaitedTypeWorker(constituentType)); } - break; + return getUnionType(types); } - - // Keep track of the type we're about to unwrap to avoid bad recursive promise types. - // See the comments below for more information. - alreadySeenTypesForAwait[type.id] = true; - - if (alreadySeenTypesForAwait[promisedType.id]) { - // We have a bad actor in the form of a promise whose promised type is the same - // promise type, or a mutually recursive promise. Return the unknown type as we cannot guess - // the shape. If this were the actual case in the JavaScript, this Promise would never resolve. - // - // An example of a bad actor with a singly-recursive promise type might be: - // - // interface BadPromise { - // then(onfulfilled: (value: BadPromise) => any, onrejected: (error: any) => any): BadPromise; - // } - // - // The above interface will pass the PromiseLike check, and return a promised type of `BadPromise`. - // Since this is a self reference, we don't want to keep recursing ad infinitum. - // - // An example of a bad actor in the form of a mutually-recursive promise type might be: - // - // interface BadPromiseA { - // then(onfulfilled: (value: BadPromiseB) => any, onrejected: (error: any) => any): BadPromiseB; - // } - // - // interface BadPromiseB { - // then(onfulfilled: (value: BadPromiseA) => any, onrejected: (error: any) => any): BadPromiseA; - // } - // - if (location) { - error(location, Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + else { + let promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error( + location, + Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, + symbolToString(type.symbol)); + } + + return unknownType; + } + + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + let awaitedType = getAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; } - - type = unknownType; - break; } - - type = promisedType; } - - // Cleanup, reset the set of visited types - alreadySeenTypesForAwait.length = 0; - return type; } /** @@ -9691,7 +9711,7 @@ namespace ts { } // Get and return the awaited type of the return type. - return getAwaitedType(promiseType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(promiseType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } /** Check a decorator */ @@ -10664,7 +10684,7 @@ namespace ts { else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { if (isAsyncFunctionLike(func)) { let promisedType = getPromisedType(returnType); - let awaitedType = getAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + let awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); checkTypeAssignableTo(awaitedType, promisedType, node.expression); } else { diff --git a/tests/baselines/reference/awaitUnion_es6.js b/tests/baselines/reference/awaitUnion_es6.js new file mode 100644 index 0000000000000..7ac556b01bca4 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.js @@ -0,0 +1,24 @@ +//// [awaitUnion_es6.ts] +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} + +//// [awaitUnion_es6.js] +function f() { + return __awaiter([this], function* () { + let await_a = yield a; + let await_b = yield b; + let await_c = yield c; + let await_d = yield d; + let await_e = yield e; + }); +} diff --git a/tests/baselines/reference/awaitUnion_es6.symbols b/tests/baselines/reference/awaitUnion_es6.symbols new file mode 100644 index 0000000000000..ca0b9afaf929c --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/async/es6/awaitUnion_es6.ts === +declare let a: number | string; +>a : Symbol(a, Decl(awaitUnion_es6.ts, 0, 11)) + +declare let b: PromiseLike | PromiseLike; +>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let c: PromiseLike; +>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let d: number | PromiseLike; +>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let e: number | PromiseLike; +>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +async function f() { +>f : Symbol(f, Decl(awaitUnion_es6.ts, 4, 53)) + + let await_a = await a; +>await_a : Symbol(await_a, Decl(awaitUnion_es6.ts, 6, 4)) + + let await_b = await b; +>await_b : Symbol(await_b, Decl(awaitUnion_es6.ts, 7, 4)) + + let await_c = await c; +>await_c : Symbol(await_c, Decl(awaitUnion_es6.ts, 8, 4)) + + let await_d = await d; +>await_d : Symbol(await_d, Decl(awaitUnion_es6.ts, 9, 4)) + + let await_e = await e; +>await_e : Symbol(await_e, Decl(awaitUnion_es6.ts, 10, 4)) +} diff --git a/tests/baselines/reference/awaitUnion_es6.types b/tests/baselines/reference/awaitUnion_es6.types new file mode 100644 index 0000000000000..fc7bef8a28c25 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/async/es6/awaitUnion_es6.ts === +declare let a: number | string; +>a : string | number + +declare let b: PromiseLike | PromiseLike; +>b : PromiseLike | PromiseLike +>PromiseLike : PromiseLike +>PromiseLike : PromiseLike + +declare let c: PromiseLike; +>c : PromiseLike +>PromiseLike : PromiseLike + +declare let d: number | PromiseLike; +>d : number | PromiseLike +>PromiseLike : PromiseLike + +declare let e: number | PromiseLike; +>e : number | PromiseLike +>PromiseLike : PromiseLike + +async function f() { +>f : () => Promise + + let await_a = await a; +>await_a : string | number +>a : any + + let await_b = await b; +>await_b : string | number +>b : any + + let await_c = await c; +>await_c : string | number +>c : any + + let await_d = await d; +>await_d : string | number +>d : any + + let await_e = await e; +>await_e : string | number +>e : any +} diff --git a/tests/cases/conformance/async/es6/awaitUnion_es6.ts b/tests/cases/conformance/async/es6/awaitUnion_es6.ts new file mode 100644 index 0000000000000..a132ae01dfde2 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitUnion_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} \ No newline at end of file From 379d74a1bfa49acdc616846dc02e21a4f2d25891 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 18 Jun 2015 14:27:20 -0700 Subject: [PATCH 106/250] Minor function rename --- src/compiler/checker.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83e5d3de18ca4..13c0aa89a9fd1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9551,13 +9551,13 @@ namespace ts { } function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { - return getAwaitedTypeWorker(type); + return checkAwaitedTypeWorker(type); - function getAwaitedTypeWorker(type: Type): Type { + function checkAwaitedTypeWorker(type: Type): Type { if (type.flags & TypeFlags.Union) { let types: Type[] = []; for (let constituentType of (type).types) { - types.push(getAwaitedTypeWorker(constituentType)); + types.push(checkAwaitedTypeWorker(constituentType)); } return getUnionType(types); @@ -9630,7 +9630,7 @@ namespace ts { // Keep track of the type we're about to unwrap to avoid bad recursive promise types. // See the comments above for more information. awaitedTypeStack.push(type.id); - let awaitedType = getAwaitedTypeWorker(promisedType); + let awaitedType = checkAwaitedTypeWorker(promisedType); awaitedTypeStack.pop(); return awaitedType; } From 46eb5216ffc851c4ee214f773872829a3209ab8d Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 14:32:14 -0700 Subject: [PATCH 107/250] Missed a few files in baseline-accept --- tests/baselines/reference/tsxReactEmit1.js | 4 ++-- tests/baselines/reference/tsxReactEmit3.js | 2 +- tests/baselines/reference/tsxReactEmitWhitespace.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index c461987c77d0b..c8be861e8f178 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -68,6 +68,6 @@ var SomeClass = (function () { }; return SomeClass; })(); -var whitespace1 = React.createElement("div", null, " "); -var whitespace2 = React.createElement("div", null, " ", p, " "); +var whitespace1 = React.createElement("div", null); +var whitespace2 = React.createElement("div", null, p); var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index 9885effa48fba..d31fec1c55035 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -7,4 +7,4 @@ declare var Foo, Bar, baz; q s ; //// [tsxReactEmit3.js] -React.createElement(Foo, null, " ", React.createElement(Bar, null, " q "), " ", React.createElement(Bar, null), " s ", React.createElement(Bar, null), React.createElement(Bar, null)); +React.createElement(Foo, null, React.createElement(Bar, null, "q "), React.createElement(Bar, null), "s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index 69bceb7a0e947..2f32295c279fa 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -56,17 +56,17 @@ var p = 0; // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; // Emit " " -React.createElement("div", null, " "); +React.createElement("div", null); // Emit " ", p, " " -React.createElement("div", null, " ", p, " "); +React.createElement("div", null, p); // Emit only p React.createElement("div", null, p); // Emit only p React.createElement("div", null, p); // Emit " 3" -React.createElement("div", null, " 3"); +React.createElement("div", null, "3"); // Emit " 3 " -React.createElement("div", null, " 3 "); +React.createElement("div", null, "3 "); // Emit "3" React.createElement("div", null, "3"); // Emit no args From 4c1002e96beec84b24797da614bae697dc43356c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 14:39:16 -0700 Subject: [PATCH 108/250] removed premature parser check --- src/compiler/parser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 79ba59b94b8d1..28bc103e4c123 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1082,11 +1082,11 @@ namespace ts { } return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.OpenBraceToken && canFollowModifier(); } - if (token === SyntaxKind.AbstractKeyword) { - nextToken(); - // 'abstract' can precede class declarations and member function declarations. - return token === SyntaxKind.ClassKeyword || token === SyntaxKind.Identifier; - } + // if (token === SyntaxKind.AbstractKeyword) { + // nextToken(); + // // 'abstract' can precede class declarations and member function declarations. + // return token === SyntaxKind.ClassKeyword || token === SyntaxKind.Identifier; + // } if (token === SyntaxKind.DefaultKeyword) { return nextTokenIsClassOrFunction(); } From 10c8b6a089cca98c2680beba09c91b45e409f886 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 14:44:01 -0700 Subject: [PATCH 109/250] removed comment --- src/compiler/parser.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 28bc103e4c123..886b73f3044dd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1082,11 +1082,6 @@ namespace ts { } return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.OpenBraceToken && canFollowModifier(); } - // if (token === SyntaxKind.AbstractKeyword) { - // nextToken(); - // // 'abstract' can precede class declarations and member function declarations. - // return token === SyntaxKind.ClassKeyword || token === SyntaxKind.Identifier; - // } if (token === SyntaxKind.DefaultKeyword) { return nextTokenIsClassOrFunction(); } From 326036dbe5b7493338856b8e3f62bb4ac7df7fd2 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 15:04:05 -0700 Subject: [PATCH 110/250] write to declaration file --- src/compiler/declarationEmitter.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 8e9f3e5c35254..649e9b69a762a 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -589,6 +589,9 @@ namespace ts { if (node.flags & NodeFlags.Static) { write("static "); } + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } } function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) { From 053be425c708e8fe59169d0c554160fbcb6d3b6c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Jun 2015 15:25:08 -0700 Subject: [PATCH 111/250] Add tests. --- src/harness/runner.ts | 1 - .../semanticClassificationsCancellation1.ts | 15 +++++++++++++ .../syntacticClassificationsCancellation1.ts | 21 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/semanticClassificationsCancellation1.ts create mode 100644 tests/cases/fourslash/syntacticClassificationsCancellation1.ts diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 42c2d5667c4be..1e9c64704210a 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -49,7 +49,6 @@ if (testConfigFile !== '') { if (!option) { continue; } - ts.sys.write("Option: " + option + "\r\n"); switch (option) { case 'compiler': runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); diff --git a/tests/cases/fourslash/semanticClassificationsCancellation1.ts b/tests/cases/fourslash/semanticClassificationsCancellation1.ts new file mode 100644 index 0000000000000..9381bef5e86ce --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationsCancellation1.ts @@ -0,0 +1,15 @@ +/// + +////module M { +////} +////module N { +////} + +var c = classification; +cancellation.setCancelled(1); +verifyOperationIsCancelled(() => verify.semanticClassificationsAre()); +cancellation.resetCancelled(); + +verify.semanticClassificationsAre( + c.moduleName("M"), + c.moduleName("N")); diff --git a/tests/cases/fourslash/syntacticClassificationsCancellation1.ts b/tests/cases/fourslash/syntacticClassificationsCancellation1.ts new file mode 100644 index 0000000000000..f15ce5f9984c8 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsCancellation1.ts @@ -0,0 +1,21 @@ +/// + +////module M { +////} +////module N { +////} + +var c = classification; +cancellation.setCancelled(1); +verifyOperationIsCancelled(() => verify.syntacticClassificationsAre()); +cancellation.resetCancelled(); + +verify.syntacticClassificationsAre( + c.keyword("module"), + c.moduleName("M"), + c.punctuation("{"), + c.punctuation("}"), + c.keyword("module"), + c.moduleName("N"), + c.punctuation("{"), + c.punctuation("}")); From eb03ae8e7c66f32326eb2e32c5defae17455bb74 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 18 Jun 2015 15:41:19 -0700 Subject: [PATCH 112/250] Added shortcut in checkAwaitedType for isolatedModules --- src/compiler/checker.ts | 6 + .../asyncAwaitIsolatedModules_es6.errors.txt | 45 +++++++ .../asyncAwaitIsolatedModules_es6.js | 119 ++++++++++++++++++ .../es6/asyncAwaitIsolatedModules_es6.ts | 41 ++++++ 4 files changed, 211 insertions(+) create mode 100644 tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt create mode 100644 tests/baselines/reference/asyncAwaitIsolatedModules_es6.js create mode 100644 tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 13c0aa89a9fd1..5445c7f919e2b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9687,6 +9687,12 @@ namespace ts { // side of the `Promise` class, which would be `{ new (...): Promise }`. let promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + let promiseConstructor = getMergedSymbol(promiseType.symbol); if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt new file mode 100644 index 0000000000000..068fbb604e1e9 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts(1,27): error TS2307: Cannot find module 'missing'. + + +==== tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts (1 errors) ==== + import { MyPromise } from "missing"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'missing'. + + declare var p: Promise; + declare var mp: MyPromise; + + async function f0() { } + async function f1(): Promise { } + async function f3(): MyPromise { } + + let f4 = async function() { } + let f5 = async function(): Promise { } + let f6 = async function(): MyPromise { } + + let f7 = async () => { }; + let f8 = async (): Promise => { }; + let f9 = async (): MyPromise => { }; + let f10 = async () => p; + let f11 = async () => mp; + let f12 = async (): Promise => mp; + let f13 = async (): MyPromise => p; + + let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } + }; + + class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } + } + + module M { + export async function f1() { } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js new file mode 100644 index 0000000000000..7fb55df0eae63 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js @@ -0,0 +1,119 @@ +//// [asyncAwaitIsolatedModules_es6.ts] +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwaitIsolatedModules_es6.js] +var __awaiter = (this && this.__awaiter) || function (args, generator) { + var PromiseConstructor = args[1] || Promise; + return new PromiseConstructor(function (resolve, reject) { + generator = generator.call(args[0], args[2]); + function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f0() { + return __awaiter([this], function* () { }); +} +function f1() { + return __awaiter([this, Promise], function* () { }); +} +function f3() { + return __awaiter([this, MyPromise], function* () { }); +} +let f4 = function () { + return __awaiter([this], function* () { }); +}; +let f5 = function () { + return __awaiter([this, Promise], function* () { }); +}; +let f6 = function () { + return __awaiter([this, MyPromise], function* () { }); +}; +let f7 = () => __awaiter([this], function* () { }); +let f8 = () => __awaiter([this, Promise], function* () { }); +let f9 = () => __awaiter([this, MyPromise], function* () { }); +let f10 = () => __awaiter([this], function* () { return p; }); +let f11 = () => __awaiter([this], function* () { return mp; }); +let f12 = () => __awaiter([this, Promise], function* () { return mp; }); +let f13 = () => __awaiter([this, MyPromise], function* () { return p; }); +let o = { + m1() { + return __awaiter([this], function* () { }); + }, + m2() { + return __awaiter([this, Promise], function* () { }); + }, + m3() { + return __awaiter([this, MyPromise], function* () { }); + } +}; +class C { + m1() { + return __awaiter([this], function* () { }); + } + m2() { + return __awaiter([this, Promise], function* () { }); + } + m3() { + return __awaiter([this, MyPromise], function* () { }); + } + static m4() { + return __awaiter([this], function* () { }); + } + static m5() { + return __awaiter([this, Promise], function* () { }); + } + static m6() { + return __awaiter([this, MyPromise], function* () { }); + } +} +var M; +(function (M) { + function f1() { + return __awaiter([this], function* () { }); + } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts new file mode 100644 index 0000000000000..8e2cfd8c6c578 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts @@ -0,0 +1,41 @@ +// @target: ES6 +// @isolatedModules: true +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file From d596bb750f10e75eb8f24c6694b9ba7073fa9c98 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 16:06:50 -0700 Subject: [PATCH 113/250] declarations of abstract methods must be consecutive --- src/compiler/checker.ts | 14 +++++++++----- src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e9977c9cd428d..cb0016c949656 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9191,9 +9191,6 @@ namespace ts { return; } - // Abstract methods can't have an implementation -- in particular, they don't need one. - if (node.flags & NodeFlags.Abstract) { return; } - let seen = false; let subsequentNode = forEachChild(node.parent, c => { if (seen) { @@ -9226,7 +9223,13 @@ namespace ts { error(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & NodeFlags.Abstract) { + error(errorNode, Diagnostics.All_declarations_of_an_abstract_member_function_must_be_consecutive); + } else { + error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } @@ -9303,7 +9306,8 @@ namespace ts { }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a29aed6615f02..e89a4e03c0377 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -398,6 +398,7 @@ namespace ts { Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract member function '{0}' on type '{1}' cannot be called via super expression." }, Classes_containing_abstract_functions_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract functions must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." }, + All_declarations_of_an_abstract_member_function_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract member function must be consecutive." }, 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 859565c181a3d..10ff7cbae3597 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1579,6 +1579,10 @@ "category": "Error", "code": 2515 }, + "All declarations of an abstract member function must be consecutive.": { + "category": "Error", + "code": 2516 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From 868138834bdef7434a4b3fd52cfb075115b747ec Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 16:07:10 -0700 Subject: [PATCH 114/250] added tests --- .../classAbstractConstructor.ts | 3 +++ .../classAbstractDeclarations.d.ts | 25 +++++++++++++++++ .../classAbstractInheritance.ts | 21 +++++++++++++++ .../classAbstractMethodWithImplementation.ts | 3 +++ .../classAbstractMixedWithModifiers.ts | 15 +++++++++++ .../classAbstractOverloads.ts | 24 +++++++++++++++++ .../classAbstractProperties.ts | 11 ++++++++ .../classAbstractSuperCalls.ts | 26 ++++++++++++++++++ .../classInstantiatingAbstractClass.ts | 18 +++++++++++++ .../classWithAbstractMethods.ts | 27 +++++++++++++++++++ 10 files changed, 173 insertions(+) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractConstructor.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractDeclarations.d.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractInheritance.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractMethodWithImplementation.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractMixedWithModifiers.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractOverloads.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractProperties.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractSuperCalls.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractConstructor.ts new file mode 100644 index 0000000000000..f53b1a3a93760 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractConstructor.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract constructor() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractDeclarations.d.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractDeclarations.d.ts new file mode 100644 index 0000000000000..14dfd1d86d840 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractDeclarations.d.ts @@ -0,0 +1,25 @@ +declare abstract class A { + abstract constructor() {} +} + +declare abstract class AA { + abstract foo(); +} + +declare abstract class BB extends AA {} + +declare class CC extends AA {} + +declare class DD extends BB {} + +declare abstract class EE extends BB {} + +declare class FF extends CC {} + +declare abstract class GG extends CC {} + +declare abstract class AAA {} + +declare abstract class BBB extends AAA {} + +declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractInheritance.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractInheritance.ts new file mode 100644 index 0000000000000..ced15607f84f9 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractInheritance.ts @@ -0,0 +1,21 @@ +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractMethodWithImplementation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractMethodWithImplementation.ts new file mode 100644 index 0000000000000..432613ca04bab --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractMethodWithImplementation.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractMixedWithModifiers.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractMixedWithModifiers.ts new file mode 100644 index 0000000000000..d3c2546ac9054 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractMixedWithModifiers.ts @@ -0,0 +1,15 @@ +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractOverloads.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractOverloads.ts new file mode 100644 index 0000000000000..c30a03f8217a8 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractOverloads.ts @@ -0,0 +1,24 @@ +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractProperties.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractProperties.ts new file mode 100644 index 0000000000000..3349e878e03d3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractProperties.ts @@ -0,0 +1,11 @@ +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractSuperCalls.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractSuperCalls.ts new file mode 100644 index 0000000000000..90fdc5cc3898e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractSuperCalls.ts @@ -0,0 +1,26 @@ + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo(); } // error, super is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} diff --git a/tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts b/tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts new file mode 100644 index 0000000000000..beb44cc789400 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts @@ -0,0 +1,18 @@ + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts b/tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts new file mode 100644 index 0000000000000..e333811c67f1e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts @@ -0,0 +1,27 @@ +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} \ No newline at end of file From b0750c25b2ff5750c48db44e7e11e7a62d50d365 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 18 Jun 2015 18:37:32 -0700 Subject: [PATCH 115/250] Fix emit for boolean attributes --- src/compiler/emitter.ts | 7 ++++++- tests/baselines/reference/tsxReactEmit1.js | 8 ++++---- tests/baselines/reference/tsxReactEmit1.symbols | 12 +++++++----- tests/baselines/reference/tsxReactEmit1.types | 10 ++++++---- tests/cases/conformance/jsx/tsxReactEmit1.tsx | 4 ++-- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 265690cd68023..588375febc55f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1148,7 +1148,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function emitJsxAttribute(node: JsxAttribute) { emitAttributeName(node.name); write(': '); - emit(node.initializer); + if (node.initializer) { + emit(node.initializer); + } + else { + write('true'); + } } function emitJsxElement(openingNode: JsxOpeningElement|JsxSelfClosingElement, children?: JsxChild[]) { diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index c8be861e8f178..b6c5fd96183fc 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -13,13 +13,13 @@ var selfClosed3 =
; var selfClosed4 =
; var selfClosed5 =
; var selfClosed6 =
; -var selfClosed7 =
; +var selfClosed7 =
; var openClosed1 =
; var openClosed2 =
foo
; var openClosed3 =
{p}
; var openClosed4 =
{p < p}
; -var openClosed5 =
{p > p}
; +var openClosed5 =
{p > p}
; class SomeClass { f() { @@ -48,12 +48,12 @@ var selfClosed3 = React.createElement("div", {x: '1'}); var selfClosed4 = React.createElement("div", {x: "1", y: '0'}); var selfClosed5 = React.createElement("div", {x: 0, y: '0'}); var selfClosed6 = React.createElement("div", {x: "1", y: '0'}); -var selfClosed7 = React.createElement("div", {x: p, y: 'p'}); +var selfClosed7 = React.createElement("div", {x: p, y: 'p', b: true}); var openClosed1 = React.createElement("div", null); var openClosed2 = React.createElement("div", {n: 'm'}, "foo"); var openClosed3 = React.createElement("div", {n: 'm'}, p); var openClosed4 = React.createElement("div", {n: 'm'}, p < p); -var openClosed5 = React.createElement("div", {n: 'm'}, p > p); +var openClosed5 = React.createElement("div", {n: 'm', b: true}, p > p); var SomeClass = (function () { function SomeClass() { } diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index f35a78729151c..60fa5e70b0a73 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -48,11 +48,12 @@ var selfClosed6 =
; >x : Symbol(unknown) >y : Symbol(unknown) -var selfClosed7 =
; +var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) +>b : Symbol(unknown) var openClosed1 =
; >openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 16, 3)) @@ -75,15 +76,16 @@ var openClosed4 =
{p < p}
; >p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) -var openClosed5 =
{p > p}
; +var openClosed5 =
{p > p}
; >openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 20, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>b : Symbol(unknown) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) class SomeClass { ->SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 43)) +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) f() { >f : Symbol(f, Decl(tsxReactEmit1.tsx, 22, 17)) @@ -91,7 +93,7 @@ class SomeClass { var rewrites1 =
{() => this}
; >rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 24, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 43)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) var rewrites2 =
{[p, ...p, p]}
; >rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 25, 5)) @@ -109,7 +111,7 @@ class SomeClass { >rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 28, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 43)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) var rewrites5 =
; >rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 29, 5)) diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index d58316b14cfd2..d23cad4560a27 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -54,13 +54,14 @@ var selfClosed6 =
; >x : any >y : any -var selfClosed7 =
; +var selfClosed7 =
; >selfClosed7 : JSX.Element ->
: JSX.Element +>
: JSX.Element >div : any >x : any >p : any >y : any +>b : any var openClosed1 =
; >openClosed1 : JSX.Element @@ -93,11 +94,12 @@ var openClosed4 =
{p < p}
; >p : any >div : any -var openClosed5 =
{p > p}
; +var openClosed5 =
{p > p}
; >openClosed5 : JSX.Element ->
{p > p}
: JSX.Element +>
{p > p}
: JSX.Element >div : any >n : any +>b : any >p > p : boolean >p : any >p : any diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx index 8ca8ef1ff4053..b8f14b0ba229c 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit1.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -14,13 +14,13 @@ var selfClosed3 =
; var selfClosed4 =
; var selfClosed5 =
; var selfClosed6 =
; -var selfClosed7 =
; +var selfClosed7 =
; var openClosed1 =
; var openClosed2 =
foo
; var openClosed3 =
{p}
; var openClosed4 =
{p < p}
; -var openClosed5 =
{p > p}
; +var openClosed5 =
{p > p}
; class SomeClass { f() { From 388e73f49f9857f2ae2783af0d0812ed83952ad1 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 19 Jun 2015 11:30:34 -0700 Subject: [PATCH 116/250] Fix React emit for spread attributes when they are the first attribute --- src/compiler/emitter.ts | 5 +++++ tests/baselines/reference/tsxReactEmit2.js | 6 +++--- tests/baselines/reference/tsxReactEmit4.errors.txt | 4 +++- tests/baselines/reference/tsxReactEmit4.js | 6 +++++- tests/cases/conformance/jsx/tsxReactEmit4.tsx | 3 +++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 588375febc55f..2b8faa8d79e52 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1178,6 +1178,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { + // If this is the first argument, we need to emit a {} as the first argument + if(i === 0) { + write('{}, '); + } + if (haveOpenedObjectLiteral) { write('}'); haveOpenedObjectLiteral = false; diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js index c19d9958ad441..f4a12946ed98f 100644 --- a/tests/baselines/reference/tsxReactEmit2.js +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -16,8 +16,8 @@ var spreads5 =
{p2}
; //// [tsxReactEmit2.js] var p1, p2, p3; -var spreads1 = React.createElement("div", React.__spread(p1), p2); -var spreads2 = React.createElement("div", React.__spread(p1), p2); +var spreads1 = React.createElement("div", React.__spread({}, p1), p2); +var spreads2 = React.createElement("div", React.__spread({}, p1), p2); var spreads3 = React.createElement("div", React.__spread({x: p3}, p1), p2); -var spreads4 = React.createElement("div", React.__spread(p1, {x: p3}), p2); +var spreads4 = React.createElement("div", React.__spread({}, p1, {x: p3}), p2); var spreads5 = React.createElement("div", React.__spread({x: p2}, p1, {y: p3}), p2); diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt index 82cacd39e2820..00b7cb8d019ec 100644 --- a/tests/baselines/reference/tsxReactEmit4.errors.txt +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -17,4 +17,6 @@ tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find n !!! error TS2304: Cannot find name 'blah'.
; - \ No newline at end of file + + // Should emit React.__spread({}, p, {x: 0}) + var spread1 =
; \ No newline at end of file diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js index b162b17ad7f1f..2254c4dd651c4 100644 --- a/tests/baselines/reference/tsxReactEmit4.js +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -12,8 +12,12 @@ var openClosed1 =
{blah}
; - + +// Should emit React.__spread({}, p, {x: 0}) +var spread1 =
; //// [tsxReactEmit4.js] var p; var openClosed1 = React.createElement("div", null, blah); +// Should emit React.__spread({}, p, {x: 0}) +var spread1 = React.createElement("div", React.__spread({}, p, {x: 0})); diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx index 0987b89c97876..f007c35c24a9c 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit4.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -13,3 +13,6 @@ var openClosed1 =
{blah}
; + +// Should emit React.__spread({}, p, {x: 0}) +var spread1 =
; \ No newline at end of file From 8f1790de4ad05a86f94dffb6586a42b090e8e7e3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 19 Jun 2015 15:34:19 -0700 Subject: [PATCH 117/250] Simplified checkClassPropertyAccess -- fixed bug in super access --- src/compiler/checker.ts | 105 +++++++++++------- .../diagnosticInformationMap.generated.ts | 6 +- src/compiler/diagnosticMessages.json | 6 +- 3 files changed, 70 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cb0016c949656..741863f03346f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6658,42 +6658,91 @@ namespace ts { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } - function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) { + /** + * Check whether the requested property access is valid. + * Returns true if node passed the check, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (eg: the super is `super.*`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ + function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) : boolean { let flags = getDeclarationFlagsFromSymbol(prop); - // Public properties are always accessible + let declaringClass : InterfaceType; + + if (left.kind === SyntaxKind.SuperKeyword) { + let errorNode = (node).name ? + (node).name : + (node).right; + + // TS 1.0 spec (April 2014): 4.8.2 + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { // prop is a property access + + error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + + // In a super call, the member function can be accessed if the method is not abstract. + // Note that a member cannot be private and abstract -- this is checked elsewhere. + if (flags & NodeFlags.Abstract) { + // Get the declaring the class instance type for the error message. + declaringClass = getDeclaredTypeOfSymbol(prop.parent); + + error(errorNode, Diagnostics.Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + + // Public properties are otherwise accessible. if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { - return; + return true; } - // Property is known to be private or protected at this point - // Get the declaring and enclosing class instance types + + // Property is known to be private or protected at this point. + + // Get the declaring and enclosing class instance types. let enclosingClassDeclaration = getAncestor(node, SyntaxKind.ClassDeclaration); + // Debug.assert(!!enclosingClassDeclaration, "Should be defined"); let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - let declaringClass = getDeclaredTypeOfSymbol(prop.parent); + declaringClass = getDeclaredTypeOfSymbol(prop.parent); + // Private property is accessible if declaring and enclosing class are the same if (flags & NodeFlags.Private) { if (declaringClass !== enclosingClass) { error(node, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } + // Property is known to be protected at this point + // All protected properties of a supertype are accessible in a super access if (left.kind === SyntaxKind.SuperKeyword) { - return; + return true; } // A protected property is accessible in the declaring class and classes derived from it if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } // No further restrictions for static properties if (flags & NodeFlags.Static) { - return; + return true; } // An instance property must be accessed through an instance of the enclosing class + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(type, enclosingClass))) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; } + return true; } function checkPropertyAccessExpression(node: PropertyAccessExpression) { @@ -6722,31 +6771,12 @@ namespace ts { } return unknownType; } + + // TODO: Why is this line here? getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & SymbolFlags.Class) { - // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === SyntaxKind.SuperKeyword) { - if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - - // Abstract methods cannot be accessed through super property accesses. Eg: - // class A { abstract foo(); } - // class B extends A { bar() { super.foo();} } - // is illegal. - if (getDeclarationFlagsFromSymbol(prop) & NodeFlags.Abstract) { - error(right, Diagnostics.Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression, declarationNameToString(right), typeToString(type)); - } - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } @@ -6760,14 +6790,7 @@ namespace ts { if (type !== unknownType && !isTypeAny(type)) { let prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - return false; - } - else { - let modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index e89a4e03c0377..071570482dfd9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -231,10 +231,10 @@ namespace ts { this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 10ff7cbae3597..85c8e46c2461c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -911,11 +911,11 @@ "category": "Error", "code": 2336 }, - "Super calls are not permitted outside constructors or in nested functions inside constructors": { + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { "category": "Error", "code": 2337 }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class": { + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { "category": "Error", "code": 2338 }, @@ -923,7 +923,7 @@ "category": "Error", "code": 2339 }, - "Only public and protected methods of the base class are accessible via the 'super' keyword": { + "Only public and protected methods of the base class are accessible via the 'super' keyword.": { "category": "Error", "code": 2340 }, From df3560f6a7f9dc3a8856c305a5d7bfb58c0f3917 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 19 Jun 2015 15:41:33 -0700 Subject: [PATCH 118/250] moved tests, added a test --- .../classAbstractConstructor.ts | 0 .../classAbstractDeclarations.d.ts | 0 .../classAbstractInheritance.ts | 0 .../classAbstractMethodWithImplementation.ts | 0 .../classAbstractMixedWithModifiers.ts | 0 .../classAbstractOverloads.ts | 0 .../classAbstractProperties.ts | 0 .../classAbstractSuperCalls.ts | 0 .../classAbstractUsingAbstractMethod.ts | 17 +++++++++++++++++ .../classInstantiatingAbstractClass.ts | 10 +++++++++- 10 files changed, 26 insertions(+), 1 deletion(-) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractConstructor.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractDeclarations.d.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractInheritance.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractMethodWithImplementation.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractMixedWithModifiers.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractOverloads.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractProperties.ts (100%) rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classAbstractSuperCalls.ts (100%) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts rename tests/cases/conformance/classes/classDeclarations/{ => classAbstractKeyword}/classInstantiatingAbstractClass.ts (56%) diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractConstructor.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractDeclarations.d.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractDeclarations.d.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractInheritance.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractInheritance.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractMethodWithImplementation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractMethodWithImplementation.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractMixedWithModifiers.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractMixedWithModifiers.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractOverloads.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractOverloads.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractProperties.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractProperties.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractSuperCalls.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractSuperCalls.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts new file mode 100644 index 0000000000000..8561fa2ce15e7 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts @@ -0,0 +1,17 @@ +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts similarity index 56% rename from tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts index beb44cc789400..d60a39a3f2cc0 100644 --- a/tests/cases/conformance/classes/classDeclarations/classInstantiatingAbstractClass.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts @@ -15,4 +15,12 @@ var c : C; a = new B; b = new B; -c = new B; \ No newline at end of file +c = new B; + +module M { + export abstract class A {} +} + +import myA = M.A; + +var aa = new myA; From b448310058e283071bf8009f31fd61e3711488d0 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 19 Jun 2015 15:45:18 -0700 Subject: [PATCH 119/250] accepted baselines --- tests/baselines/reference/APISample_linter.js | 146 +++++++++--------- .../reference/abstractClass1.errors.txt | 112 +++++++------- tests/baselines/reference/abstractClass1.js | 144 ++++++++--------- .../reference/abstractClassIdentifierName.js | 20 +-- .../abstractClassIdentifierName.symbols | 16 +- .../abstractClassIdentifierName.types | 16 +- .../reference/abstractIdentifierNameStrict.js | 18 +-- .../abstractIdentifierNameStrict.symbols | 22 +-- .../abstractIdentifierNameStrict.types | 30 ++-- .../abstractInterfaceIdentifierName.js | 8 +- .../abstractInterfaceIdentifierName.symbols | 18 +-- .../abstractInterfaceIdentifierName.types | 18 +-- .../classAbstractConstructor.errors.txt | 12 ++ .../reference/classAbstractConstructor.js | 11 ++ .../classAbstractDeclarations.d.errors.txt | 52 +++++++ .../classAbstractInheritance.errors.txt | 39 +++++ .../reference/classAbstractInheritance.js | 96 ++++++++++++ ...bstractMethodWithImplementation.errors.txt | 9 ++ .../classAbstractMethodWithImplementation.js | 12 ++ ...classAbstractMixedWithModifiers.errors.txt | 36 +++++ .../classAbstractMixedWithModifiers.js | 23 +++ .../classAbstractOverloads.errors.txt | 42 +++++ .../reference/classAbstractOverloads.js | 38 +++++ .../classAbstractProperties.errors.txt | 29 ++++ .../reference/classAbstractProperties.js | 19 +++ .../classAbstractSuperCalls.errors.txt | 33 ++++ .../reference/classAbstractSuperCalls.js | 75 +++++++++ ...lassAbstractUsingAbstractMethod.errors.txt | 23 +++ .../classAbstractUsingAbstractMethod.js | 50 ++++++ ...classInstantiatingAbstractClass.errors.txt | 39 +++++ .../classInstantiatingAbstractClass.js | 75 +++++++++ .../classWithAbstractMethods.errors.txt | 46 ++++++ .../reference/classWithAbstractMethods.js | 98 ++++++++++++ .../computedPropertyNames30_ES5.errors.txt | 4 +- .../computedPropertyNames30_ES6.errors.txt | 4 +- .../decoratorOnClassMethod12.errors.txt | 4 +- ...lassConstructorWithoutSuperCall.errors.txt | 8 +- ...perCallsInNonConstructorMembers.errors.txt | 32 ++-- .../emitThisInSuperMethodCall.errors.txt | 12 +- .../reference/errorSuperCalls.errors.txt | 16 +- .../errorSuperPropertyAccess.errors.txt | 64 ++++---- .../illegalSuperCallsInConstructor.errors.txt | 20 +-- .../reference/parserAstSpans1.errors.txt | 8 +- ...vateInstanceMemberAccessibility.errors.txt | 12 +- ...opertyAccessibleWithinSubclass3.errors.txt | 4 +- ...ctedInstanceMemberAccessibility.errors.txt | 4 +- ...opertyAccessibleWithinSubclass2.errors.txt | 8 +- .../reference/superAccess.errors.txt | 8 +- .../reference/superAccess2.errors.txt | 4 +- .../superCallOutsideConstructor.errors.txt | 12 +- .../reference/superErrors.errors.txt | 20 +-- .../reference/superInLambdas.errors.txt | 8 +- .../reference/superPropertyAccess.errors.txt | 20 +-- .../reference/superPropertyAccess1.errors.txt | 12 +- .../reference/superPropertyAccess2.errors.txt | 4 +- ...ect-literal-getters-and-setters.errors.txt | 4 +- 56 files changed, 1287 insertions(+), 430 deletions(-) create mode 100644 tests/baselines/reference/classAbstractConstructor.errors.txt create mode 100644 tests/baselines/reference/classAbstractConstructor.js create mode 100644 tests/baselines/reference/classAbstractDeclarations.d.errors.txt create mode 100644 tests/baselines/reference/classAbstractInheritance.errors.txt create mode 100644 tests/baselines/reference/classAbstractInheritance.js create mode 100644 tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt create mode 100644 tests/baselines/reference/classAbstractMethodWithImplementation.js create mode 100644 tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt create mode 100644 tests/baselines/reference/classAbstractMixedWithModifiers.js create mode 100644 tests/baselines/reference/classAbstractOverloads.errors.txt create mode 100644 tests/baselines/reference/classAbstractOverloads.js create mode 100644 tests/baselines/reference/classAbstractProperties.errors.txt create mode 100644 tests/baselines/reference/classAbstractProperties.js create mode 100644 tests/baselines/reference/classAbstractSuperCalls.errors.txt create mode 100644 tests/baselines/reference/classAbstractSuperCalls.js create mode 100644 tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt create mode 100644 tests/baselines/reference/classAbstractUsingAbstractMethod.js create mode 100644 tests/baselines/reference/classInstantiatingAbstractClass.errors.txt create mode 100644 tests/baselines/reference/classInstantiatingAbstractClass.js create mode 100644 tests/baselines/reference/classWithAbstractMethods.errors.txt create mode 100644 tests/baselines/reference/classWithAbstractMethods.js diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index bdf8a7ed1ca8a..5c2a8953a6123 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1,67 +1,67 @@ //// [APISample_linter.ts] - -/* - * Note: This test is a public API sample. The sample sources can be found - at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter - * Please log a "breaking change" issue for any API breaking change affecting this issue - */ - -declare var process: any; -declare var console: any; -declare var readFileSync: any; - -import * as ts from "typescript"; - -export function delint(sourceFile: ts.SourceFile) { - delintNode(sourceFile); - - function delintNode(node: ts.Node) { - switch (node.kind) { - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: - if ((node).statement.kind !== ts.SyntaxKind.Block) { - report(node, "A looping statement's contents should be wrapped in a block body."); - } - break; - - case ts.SyntaxKind.IfStatement: - let ifStatement = (node); - if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { - report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); - } - if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && - ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { - report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); - } - break; - - case ts.SyntaxKind.BinaryExpression: - let op = (node).operatorToken.kind; - if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { - report(node, "Use '===' and '!=='.") - } - break; - } - - ts.forEachChild(node, delintNode); - } - - function report(node: ts.Node, message: string) { - let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); - console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`); - } -} - -const fileNames = process.argv.slice(2); -fileNames.forEach(fileName => { - // Parse a file - let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); - - // delint it - delint(sourceFile); + +/* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var process: any; +declare var console: any; +declare var readFileSync: any; + +import * as ts from "typescript"; + +export function delint(sourceFile: ts.SourceFile) { + delintNode(sourceFile); + + function delintNode(node: ts.Node) { + switch (node.kind) { + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + if ((node).statement.kind !== ts.SyntaxKind.Block) { + report(node, "A looping statement's contents should be wrapped in a block body."); + } + break; + + case ts.SyntaxKind.IfStatement: + let ifStatement = (node); + if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { + report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); + } + if (ifStatement.elseStatement && + ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && + ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { + report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); + } + break; + + case ts.SyntaxKind.BinaryExpression: + let op = (node).operatorToken.kind; + if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { + report(node, "Use '===' and '!=='.") + } + break; + } + + ts.forEachChild(node, delintNode); + } + + function report(node: ts.Node, message: string) { + let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); + console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`); + } +} + +const fileNames = process.argv.slice(2); +fileNames.forEach(fileName => { + // Parse a file + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + + // delint it + delint(sourceFile); }); //// [APISample_linter.js] @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: - if (node.statement.kind !== 182 /* Block */) { + case 190 /* ForStatement */: + case 191 /* ForInStatement */: + case 189 /* WhileStatement */: + case 188 /* DoStatement */: + if (node.statement.kind !== 183 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 186 /* IfStatement */: + case 187 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 182 /* Block */) { + if (ifStatement.thenStatement.kind !== 183 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 182 /* Block */ && - ifStatement.elseStatement.kind !== 186 /* IfStatement */) { + ifStatement.elseStatement.kind !== 183 /* Block */ && + ifStatement.elseStatement.kind !== 187 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 172 /* BinaryExpression */: + case 173 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/abstractClass1.errors.txt b/tests/baselines/reference/abstractClass1.errors.txt index 5892f54266317..5e658fec6412b 100644 --- a/tests/baselines/reference/abstractClass1.errors.txt +++ b/tests/baselines/reference/abstractClass1.errors.txt @@ -1,57 +1,57 @@ -tests/cases/compiler/abstractClass1.ts(15,9): error TS2502: Cannot create an instance of the abstract class 'Foo' -tests/cases/compiler/abstractClass1.ts(16,9): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/abstractClass1.ts(16,9): error TS2502: Cannot create an instance of the abstract class 'Foo' -tests/cases/compiler/abstractClass1.ts(25,1): error TS2502: Cannot create an instance of the abstract class 'Qux' -tests/cases/compiler/abstractClass1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/abstractClass1.ts(35,1): error TS2502: Cannot create an instance of the abstract class 'Foo' - - -==== tests/cases/compiler/abstractClass1.ts (6 errors) ==== - - abstract class Foo { - constructor(f: any) { } - public static bar(): void { } - - public empty() { } - } - - class Bar extends Foo { - constructor(f: any) { - super(f); - } - } - - var a = new Foo(1); // Error - ~~~~~~~~~~ -!!! error TS2502: Cannot create an instance of the abstract class 'Foo' - var b = new Foo(); // Error because of invalid constructor arguments - ~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~~~~~~ -!!! error TS2502: Cannot create an instance of the abstract class 'Foo' - - module baz { - export abstract class Qux { - } - export class Quz extends Qux { - } - } - - new baz.Qux(); - ~~~~~~~~~~~~~ -!!! error TS2502: Cannot create an instance of the abstract class 'Qux' - - // Valid - var c = new Bar(1); - c.empty(); - - // Calling a static method on a abstract class is valid - Foo.bar(); - - var Copy = Foo; - new Copy(); - ~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~~~~~~~ -!!! error TS2502: Cannot create an instance of the abstract class 'Foo' +tests/cases/compiler/abstractClass1.ts(15,9): error TS2511: Cannot create an instance of the abstract class 'Foo'. +tests/cases/compiler/abstractClass1.ts(16,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/abstractClass1.ts(16,9): error TS2511: Cannot create an instance of the abstract class 'Foo'. +tests/cases/compiler/abstractClass1.ts(25,1): error TS2511: Cannot create an instance of the abstract class 'Qux'. +tests/cases/compiler/abstractClass1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/abstractClass1.ts(35,1): error TS2511: Cannot create an instance of the abstract class 'Foo'. + + +==== tests/cases/compiler/abstractClass1.ts (6 errors) ==== + + abstract class Foo { + constructor(f: any) { } + public static bar(): void { } + + public empty() { } + } + + class Bar extends Foo { + constructor(f: any) { + super(f); + } + } + + var a = new Foo(1); // Error + ~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'Foo'. + var b = new Foo(); // Error because of invalid constructor arguments + ~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'Foo'. + + module baz { + export abstract class Qux { + } + export class Quz extends Qux { + } + } + + new baz.Qux(); + ~~~~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'Qux'. + + // Valid + var c = new Bar(1); + c.empty(); + + // Calling a static method on a abstract class is valid + Foo.bar(); + + var Copy = Foo; + new Copy(); + ~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/abstractClass1.js b/tests/baselines/reference/abstractClass1.js index 4cb36d91ae1dd..494673d6ce042 100644 --- a/tests/baselines/reference/abstractClass1.js +++ b/tests/baselines/reference/abstractClass1.js @@ -1,4 +1,4 @@ -//// [abstractClass1.ts] +//// [abstractClass1.ts] abstract class Foo { constructor(f: any) { } @@ -34,74 +34,74 @@ Foo.bar(); var Copy = Foo; new Copy(); - - -//// [abstractClass1.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo(f) { - } - Foo.bar = function () { }; - Foo.prototype.empty = function () { }; - return Foo; -})(); -var Bar = (function (_super) { - __extends(Bar, _super); - function Bar(f) { - _super.call(this, f); - } - return Bar; -})(Foo); -var a = new Foo(1); // Error -var b = new Foo(); // Error because of invalid constructor arguments -var baz; -(function (baz) { - var Qux = (function () { - function Qux() { - } - return Qux; - })(); - baz.Qux = Qux; - var Quz = (function (_super) { - __extends(Quz, _super); - function Quz() { - _super.apply(this, arguments); - } - return Quz; - })(Qux); - baz.Quz = Quz; -})(baz || (baz = {})); -new baz.Qux(); -// Valid -var c = new Bar(1); -c.empty(); -// Calling a static method on a abstract class is valid -Foo.bar(); -var Copy = Foo; -new Copy(); - - -//// [abstractClass1.d.ts] -declare abstract class Foo { - constructor(f: any); - static bar(): void; - empty(): void; -} -declare class Bar extends Foo { - constructor(f: any); -} -declare var a: Foo; -declare var b: any; -declare module baz { - abstract class Qux { - } - class Quz extends Qux { - } -} -declare var c: Bar; -declare var Copy: typeof Foo; + + +//// [abstractClass1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Foo = (function () { + function Foo(f) { + } + Foo.bar = function () { }; + Foo.prototype.empty = function () { }; + return Foo; +})(); +var Bar = (function (_super) { + __extends(Bar, _super); + function Bar(f) { + _super.call(this, f); + } + return Bar; +})(Foo); +var a = new Foo(1); // Error +var b = new Foo(); // Error because of invalid constructor arguments +var baz; +(function (baz) { + var Qux = (function () { + function Qux() { + } + return Qux; + })(); + baz.Qux = Qux; + var Quz = (function (_super) { + __extends(Quz, _super); + function Quz() { + _super.apply(this, arguments); + } + return Quz; + })(Qux); + baz.Quz = Quz; +})(baz || (baz = {})); +new baz.Qux(); +// Valid +var c = new Bar(1); +c.empty(); +// Calling a static method on a abstract class is valid +Foo.bar(); +var Copy = Foo; +new Copy(); + + +//// [abstractClass1.d.ts] +declare abstract class Foo { + constructor(f: any); + static bar(): void; + empty(): void; +} +declare class Bar extends Foo { + constructor(f: any); +} +declare var a: Foo; +declare var b: any; +declare module baz { + abstract class Qux { + } + class Quz extends Qux { + } +} +declare var c: Bar; +declare var Copy: typeof Foo; diff --git a/tests/baselines/reference/abstractClassIdentifierName.js b/tests/baselines/reference/abstractClassIdentifierName.js index 71827d2cb5bd8..0e53e44671ab4 100644 --- a/tests/baselines/reference/abstractClassIdentifierName.js +++ b/tests/baselines/reference/abstractClassIdentifierName.js @@ -1,14 +1,14 @@ -//// [abstractClassIdentifierName.ts] +//// [abstractClassIdentifierName.ts] class abstract { abstract(): void { } } - - -//// [abstractClassIdentifierName.js] -var abstract = (function () { - function abstract() { - } - abstract.prototype.abstract = function () { }; - return abstract; -})(); + + +//// [abstractClassIdentifierName.js] +var abstract = (function () { + function abstract() { + } + abstract.prototype.abstract = function () { }; + return abstract; +})(); diff --git a/tests/baselines/reference/abstractClassIdentifierName.symbols b/tests/baselines/reference/abstractClassIdentifierName.symbols index 41c46649c435e..12d878620d893 100644 --- a/tests/baselines/reference/abstractClassIdentifierName.symbols +++ b/tests/baselines/reference/abstractClassIdentifierName.symbols @@ -1,8 +1,8 @@ -=== tests/cases/compiler/abstractClassIdentifierName.ts === -class abstract { ->abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 0)) - - abstract(): void { } ->abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 16)) -} - +=== tests/cases/compiler/abstractClassIdentifierName.ts === +class abstract { +>abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 0)) + + abstract(): void { } +>abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 16)) +} + diff --git a/tests/baselines/reference/abstractClassIdentifierName.types b/tests/baselines/reference/abstractClassIdentifierName.types index ef152979f13a0..e31abf49a6f4c 100644 --- a/tests/baselines/reference/abstractClassIdentifierName.types +++ b/tests/baselines/reference/abstractClassIdentifierName.types @@ -1,8 +1,8 @@ -=== tests/cases/compiler/abstractClassIdentifierName.ts === -class abstract { ->abstract : abstract - - abstract(): void { } ->abstract : () => void -} - +=== tests/cases/compiler/abstractClassIdentifierName.ts === +class abstract { +>abstract : abstract + + abstract(): void { } +>abstract : () => void +} + diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.js b/tests/baselines/reference/abstractIdentifierNameStrict.js index 8544019c4d1f7..92d159766d7e8 100644 --- a/tests/baselines/reference/abstractIdentifierNameStrict.js +++ b/tests/baselines/reference/abstractIdentifierNameStrict.js @@ -1,14 +1,14 @@ -//// [abstractIdentifierNameStrict.ts] +//// [abstractIdentifierNameStrict.ts] var abstract = true; function foo() { "use strict"; var abstract = true; -} - -//// [abstractIdentifierNameStrict.js] -var abstract = true; -function foo() { - "use strict"; - var abstract = true; -} +} + +//// [abstractIdentifierNameStrict.js] +var abstract = true; +function foo() { + "use strict"; + var abstract = true; +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.symbols b/tests/baselines/reference/abstractIdentifierNameStrict.symbols index f983ddccdc92b..c6a374e9bcdf0 100644 --- a/tests/baselines/reference/abstractIdentifierNameStrict.symbols +++ b/tests/baselines/reference/abstractIdentifierNameStrict.symbols @@ -1,11 +1,11 @@ -=== tests/cases/compiler/abstractIdentifierNameStrict.ts === -var abstract = true; ->abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 0, 3)) - -function foo() { ->foo : Symbol(foo, Decl(abstractIdentifierNameStrict.ts, 0, 20)) - - "use strict"; - var abstract = true; ->abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 4, 7)) -} +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 0, 3)) + +function foo() { +>foo : Symbol(foo, Decl(abstractIdentifierNameStrict.ts, 0, 20)) + + "use strict"; + var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 4, 7)) +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.types b/tests/baselines/reference/abstractIdentifierNameStrict.types index e43207007e03a..7c79ce58a372e 100644 --- a/tests/baselines/reference/abstractIdentifierNameStrict.types +++ b/tests/baselines/reference/abstractIdentifierNameStrict.types @@ -1,15 +1,15 @@ -=== tests/cases/compiler/abstractIdentifierNameStrict.ts === -var abstract = true; ->abstract : boolean ->true : boolean - -function foo() { ->foo : () => void - - "use strict"; ->"use strict" : string - - var abstract = true; ->abstract : boolean ->true : boolean -} +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : boolean +>true : boolean + +function foo() { +>foo : () => void + + "use strict"; +>"use strict" : string + + var abstract = true; +>abstract : boolean +>true : boolean +} diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.js b/tests/baselines/reference/abstractInterfaceIdentifierName.js index c3913ae5cdfaa..67058bfc6194a 100644 --- a/tests/baselines/reference/abstractInterfaceIdentifierName.js +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.js @@ -1,8 +1,8 @@ -//// [abstractInterfaceIdentifierName.ts] +//// [abstractInterfaceIdentifierName.ts] interface abstract { abstract(): void; } - - -//// [abstractInterfaceIdentifierName.js] + + +//// [abstractInterfaceIdentifierName.js] diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.symbols b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols index db2ad0aceba69..c70cdec8ac957 100644 --- a/tests/baselines/reference/abstractInterfaceIdentifierName.symbols +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols @@ -1,9 +1,9 @@ -=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === - -interface abstract { ->abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 0, 0)) - - abstract(): void; ->abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 1, 20)) -} - +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 0, 0)) + + abstract(): void; +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 1, 20)) +} + diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.types b/tests/baselines/reference/abstractInterfaceIdentifierName.types index 3a5c6024f4ca7..c6d30ca38a0c3 100644 --- a/tests/baselines/reference/abstractInterfaceIdentifierName.types +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.types @@ -1,9 +1,9 @@ -=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === - -interface abstract { ->abstract : abstract - - abstract(): void; ->abstract : () => void -} - +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : abstract + + abstract(): void; +>abstract : () => void +} + diff --git a/tests/baselines/reference/classAbstractConstructor.errors.txt b/tests/baselines/reference/classAbstractConstructor.errors.txt new file mode 100644 index 0000000000000..b8d91cefb0fbf --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1240: Abstract member functions cannot have an implementation. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (2 errors) ==== + abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1240: Abstract member functions cannot have an implementation. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractConstructor.js b/tests/baselines/reference/classAbstractConstructor.js new file mode 100644 index 0000000000000..fa88b0c7d3796 --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.js @@ -0,0 +1,11 @@ +//// [classAbstractConstructor.ts] +abstract class A { + abstract constructor() {} +} + +//// [classAbstractConstructor.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt new file mode 100644 index 0000000000000..aef63b296e79e --- /dev/null +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -0,0 +1,52 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1240: Abstract member functions cannot have an implementation. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2415: Class 'CC' incorrectly extends base class 'AA'. + Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2415: Class 'DD' incorrectly extends base class 'BB'. + Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2415: Class 'FF' incorrectly extends base class 'CC'. + Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (6 errors) ==== + declare abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1240: Abstract member functions cannot have an implementation. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. + } + + declare abstract class AA { + abstract foo(); + } + + declare abstract class BB extends AA {} + + declare class CC extends AA {} + ~~ +!!! error TS2415: Class 'CC' incorrectly extends base class 'AA'. +!!! error TS2415: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. + + declare class DD extends BB {} + ~~ +!!! error TS2415: Class 'DD' incorrectly extends base class 'BB'. +!!! error TS2415: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. + + declare abstract class EE extends BB {} + + declare class FF extends CC {} + ~~ +!!! error TS2415: Class 'FF' incorrectly extends base class 'CC'. +!!! error TS2415: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. + + declare abstract class GG extends CC {} + + declare abstract class AAA {} + + declare abstract class BBB extends AAA {} + + declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInheritance.errors.txt b/tests/baselines/reference/classAbstractInheritance.errors.txt new file mode 100644 index 0000000000000..39e209b2e0561 --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(13,7): error TS2415: Class 'CC' incorrectly extends base class 'AA'. + Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(15,7): error TS2415: Class 'DD' incorrectly extends base class 'BB'. + Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(19,7): error TS2415: Class 'FF' incorrectly extends base class 'CC'. + Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts (3 errors) ==== + abstract class A {} + + abstract class B extends A {} + + class C extends A {} + + abstract class AA { + abstract foo(); + } + + abstract class BB extends AA {} + + class CC extends AA {} + ~~ +!!! error TS2415: Class 'CC' incorrectly extends base class 'AA'. +!!! error TS2415: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. + + class DD extends BB {} + ~~ +!!! error TS2415: Class 'DD' incorrectly extends base class 'BB'. +!!! error TS2415: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. + + abstract class EE extends BB {} + + class FF extends CC {} + ~~ +!!! error TS2415: Class 'FF' incorrectly extends base class 'CC'. +!!! error TS2415: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. + + abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js new file mode 100644 index 0000000000000..2aa156500e0ac --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -0,0 +1,96 @@ +//// [classAbstractInheritance.ts] +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} + +//// [classAbstractInheritance.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + return DD; +})(BB); +var EE = (function (_super) { + __extends(EE, _super); + function EE() { + _super.apply(this, arguments); + } + return EE; +})(BB); +var FF = (function (_super) { + __extends(FF, _super); + function FF() { + _super.apply(this, arguments); + } + return FF; +})(CC); +var GG = (function (_super) { + __extends(GG, _super); + function GG() { + _super.apply(this, arguments); + } + return GG; +})(CC); diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt new file mode 100644 index 0000000000000..5e1196f0e7cc1 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1240: Abstract member functions cannot have an implementation. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== + abstract class A { + abstract foo() {} + ~~~~~~~~~~~~~~~~~ +!!! error TS1240: Abstract member functions cannot have an implementation. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.js b/tests/baselines/reference/classAbstractMethodWithImplementation.js new file mode 100644 index 0000000000000..d931901271230 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.js @@ -0,0 +1,12 @@ +//// [classAbstractMethodWithImplementation.ts] +abstract class A { + abstract foo() {} +} + +//// [classAbstractMethodWithImplementation.js] +var A = (function () { + function A() { + } + A.prototype.foo = function () { }; + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt new file mode 100644 index 0000000000000..488fbdeb36e9e --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1029: 'private' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1237: 'static' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1237: 'static' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts (6 errors) ==== + abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + ~~~~~~~~ +!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier. + + abstract public foo_bb(); + ~~~~~~ +!!! error TS1029: 'public' modifier must precede 'abstract' modifier. + abstract protected foo_cc(); + ~~~~~~~~~ +!!! error TS1029: 'protected' modifier must precede 'abstract' modifier. + abstract private foo_dd(); + ~~~~~~~ +!!! error TS1029: 'private' modifier must precede 'abstract' modifier. + + abstract static foo_d(); + ~~~~~~ +!!! error TS1237: 'static' modifier cannot be used with 'abstract' modifier. + + static abstract foo_e(); + ~~~~~~~~ +!!! error TS1237: 'static' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.js b/tests/baselines/reference/classAbstractMixedWithModifiers.js new file mode 100644 index 0000000000000..71eb4c61c048e --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.js @@ -0,0 +1,23 @@ +//// [classAbstractMixedWithModifiers.ts] +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} + +//// [classAbstractMixedWithModifiers.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractOverloads.errors.txt b/tests/baselines/reference/classAbstractOverloads.errors.txt new file mode 100644 index 0000000000000..88dd33c2bedfd --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: All overload signatures must match with respect to modifier 'abstract'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: All overload signatures must match with respect to modifier 'abstract'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: All overload signatures must match with respect to modifier 'abstract'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract member function must be consecutive. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts (5 errors) ==== + abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + ~~~ +!!! error TS2512: All overload signatures must match with respect to modifier 'abstract'. + abstract bar(); + + abstract baz(); + ~~~ +!!! error TS2512: All overload signatures must match with respect to modifier 'abstract'. + baz(); + abstract baz(); + ~~~ +!!! error TS2512: All overload signatures must match with respect to modifier 'abstract'. + baz() {} + + qux(); + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } + + abstract class B { + abstract foo() : number; + abstract foo(); + ~~~ +!!! error TS2516: All declarations of an abstract member function must be consecutive. + x : number; + abstract foo(); + abstract foo(); + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverloads.js b/tests/baselines/reference/classAbstractOverloads.js new file mode 100644 index 0000000000000..1bdff73d5b781 --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.js @@ -0,0 +1,38 @@ +//// [classAbstractOverloads.ts] +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} + +//// [classAbstractOverloads.js] +var A = (function () { + function A() { + } + A.prototype.baz = function () { }; + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt new file mode 100644 index 0000000000000..0f40d091fd8be --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(10,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (5 errors) ==== + abstract class A { + abstract x : number; + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. + public abstract y : number; + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. + protected abstract z : number; + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. + private abstract w : number; + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; + ~~~~~~~~ +!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractProperties.js b/tests/baselines/reference/classAbstractProperties.js new file mode 100644 index 0000000000000..a410715e4f784 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.js @@ -0,0 +1,19 @@ +//// [classAbstractProperties.ts] +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} + +//// [classAbstractProperties.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractSuperCalls.errors.txt b/tests/baselines/reference/classAbstractSuperCalls.errors.txt new file mode 100644 index 0000000000000..b63b768cbfeaa --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract member function 'foo' on type 'B' cannot be called via super expression. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (1 errors) ==== + + class A { + foo() { return 1; } + } + + abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } + } + + class C extends B { + foo() { return 2; } + qux() { return super.foo(); } // error, super is abstract + ~~~ +!!! error TS2513: Abstract member function 'foo' on type 'B' cannot be called via super expression. + norf() { return super.bar(); } + } + + class AA { + foo() { return 1; } + bar() { return this.foo(); } + } + + abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js new file mode 100644 index 0000000000000..7841785ac055a --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -0,0 +1,75 @@ +//// [classAbstractSuperCalls.ts] + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo(); } // error, super is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} + + +//// [classAbstractSuperCalls.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var A = (function () { + function A() { + } + A.prototype.foo = function () { return 1; }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.bar = function () { _super.prototype.foo.call(this); }; + B.prototype.baz = function () { return this.foo; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.prototype.foo = function () { return 2; }; + C.prototype.qux = function () { return _super.prototype.foo.call(this); }; // error, super is abstract + C.prototype.norf = function () { return _super.prototype.bar.call(this); }; + return C; +})(B); +var AA = (function () { + function AA() { + } + AA.prototype.foo = function () { return 1; }; + AA.prototype.bar = function () { return this.foo(); }; + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt new file mode 100644 index 0000000000000..3ae5084e2db69 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts(16,5): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts (1 errors) ==== + abstract class A { + abstract foo() : number; + } + + class B extends A { + foo() { return 1; } + } + + abstract class C extends A { + abstract foo() : number; + } + + var a = new B; + a.foo(); + + a = new C; // error, cannot instantiate abstract class. + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + a.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod.js b/tests/baselines/reference/classAbstractUsingAbstractMethod.js new file mode 100644 index 0000000000000..26a406aa008a5 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod.js @@ -0,0 +1,50 @@ +//// [classAbstractUsingAbstractMethod.ts] +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); + +//// [classAbstractUsingAbstractMethod.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.foo = function () { return 1; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var a = new B; +a.foo(); +a = new C; // error, cannot instantiate abstract class. +a.foo(); diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt b/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt new file mode 100644 index 0000000000000..a9da2f38c376c --- /dev/null +++ b/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(26,10): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts (3 errors) ==== + + abstract class A {} + + class B extends A {} + + abstract class C extends B {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + + var a : A; + var b : B; + var c : C; + + a = new B; + b = new B; + c = new B; + + module M { + export abstract class A {} + } + + import myA = M.A; + + var aa = new myA; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.js b/tests/baselines/reference/classInstantiatingAbstractClass.js new file mode 100644 index 0000000000000..5a23d3d9b4098 --- /dev/null +++ b/tests/baselines/reference/classInstantiatingAbstractClass.js @@ -0,0 +1,75 @@ +//// [classInstantiatingAbstractClass.ts] + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; + +module M { + export abstract class A {} +} + +import myA = M.A; + +var aa = new myA; + + +//// [classInstantiatingAbstractClass.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); +new A; +new B; +new C; +var a; +var b; +var c; +a = new B; +b = new B; +c = new B; +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; +})(M || (M = {})); +var myA = M.A; +var aa = new myA; diff --git a/tests/baselines/reference/classWithAbstractMethods.errors.txt b/tests/baselines/reference/classWithAbstractMethods.errors.txt new file mode 100644 index 0000000000000..37eba4a6a861a --- /dev/null +++ b/tests/baselines/reference/classWithAbstractMethods.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(1,7): error TS2514: Classes containing abstract functions must be marked abstract. +tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(2,5): error TS1238: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(5,7): error TS2415: Class 'B' incorrectly extends base class 'A'. + Non-abstract class 'B' does not implement inherited abstract member 'A.foo'. +tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(21,7): error TS2415: Class 'BB' incorrectly extends base class 'AA'. + Non-abstract class 'BB' does not implement inherited abstract member 'AA.foo'. + + +==== tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts (4 errors) ==== + class A { + ~ +!!! error TS2514: Classes containing abstract functions must be marked abstract. + abstract foo(); + ~~~~~~~~ +!!! error TS1238: Abstract methods can only appear within an abstract class. + } + + class B extends A {} + ~ +!!! error TS2415: Class 'B' incorrectly extends base class 'A'. +!!! error TS2415: Non-abstract class 'B' does not implement inherited abstract member 'A.foo'. + + abstract class C extends A {} + + class D extends A { + foo() {} + } + + abstract class E extends A { + foo() {} + } + + abstract class AA { + abstract foo(); + } + + class BB extends AA {} + ~~ +!!! error TS2415: Class 'BB' incorrectly extends base class 'AA'. +!!! error TS2415: Non-abstract class 'BB' does not implement inherited abstract member 'AA.foo'. + + abstract class CC extends AA {} + + class DD extends AA { + foo() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classWithAbstractMethods.js b/tests/baselines/reference/classWithAbstractMethods.js new file mode 100644 index 0000000000000..2035ba20ea9f6 --- /dev/null +++ b/tests/baselines/reference/classWithAbstractMethods.js @@ -0,0 +1,98 @@ +//// [classWithAbstractMethods.ts] +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} + +//// [classWithAbstractMethods.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + D.prototype.foo = function () { }; + return D; +})(A); +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { }; + return E; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + DD.prototype.foo = function () { }; + return DD; +})(AA); diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt index 1dfb605db33db..deb80dbcca896 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt index dc8892fd32628..b10d184f7990e 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt index 14845839089c2..3ad3cabebe20d 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10 class C extends S { @super.decorator ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. method() { } } } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt index 40610b5b83819..c67bc2479ecd0 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(17,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(23,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts (5 errors) ==== @@ -30,7 +30,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r2 = () => super(); // error for misplaced super call (nested function) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. @@ -42,7 +42,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r = function () { super() } // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index f465afbccadc5..ab79f8d3e2354 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (10 errors) ==== @@ -22,43 +22,43 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. static b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt index 7fe090395e375..06211ef771ff0 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt +++ b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/emitThisInSuperMethodCall.ts (3 errors) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } @@ -24,7 +24,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' () => { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -32,7 +32,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } diff --git a/tests/baselines/reference/errorSuperCalls.errors.txt b/tests/baselines/reference/errorSuperCalls.errors.txt index cd1aa23f14df9..9ecc7a1565eb5 100644 --- a/tests/baselines/reference/errorSuperCalls.errors.txt +++ b/tests/baselines/reference/errorSuperCalls.errors.txt @@ -8,10 +8,10 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ==== @@ -94,26 +94,26 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T //super call in class member initializer of derived type t = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. fn() { //super call in class member function of derived type super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } //super call in class accessor (get and set) of derived type get foo() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return null; } set foo(n) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt index b273b1b6f45c8..c34ed9120463e 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt @@ -9,30 +9,30 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(25,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(29,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(30,9): error TS2335: 'super' can only be referenced in a derived class. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(98,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(111,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(113,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(116,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2335: 'super' can only be referenced in a derived class. @@ -119,13 +119,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.publicMember = 1; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -133,7 +133,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -141,18 +141,18 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn2() { function inner() { super.publicFunc(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } var x = { test: function () { return super.publicFunc(); } ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -165,13 +165,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.privateMember = 1; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -179,7 +179,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -187,7 +187,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -199,10 +199,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess static fn() { super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -212,10 +212,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -226,10 +226,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt index a07fbea75d851..1d3d2e7c2754c 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(15,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/illegalSuperCallsInConstructor.ts (8 errors) ==== @@ -19,15 +19,15 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup var r2 = () => super(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r3 = () => { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r4 = function () { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r5 = { ~~~~~~~~~~~~~~~~~~ get foo() { @@ -37,7 +37,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; ~~~~~~~~~~~~~~~~~~~~~~~~~ }, @@ -49,7 +49,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~~~~~~~~~ } diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index 9697dcbc1282b..648929e974e3e 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(79,16): error TS10 tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (8 errors) ==== @@ -129,7 +129,7 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(10); this.p1 = super.c2_p1; ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } /** c3 p1*/ public p1: number; @@ -241,6 +241,6 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(); this.d = super.b; ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index f29ee917ea7f4..7893100b5a589 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS1003: Identifier expected. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS1110: Type expected. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS2341: Property 'foo' is private and only accessible within class 'Base'. @@ -14,17 +14,17 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces class Derived extends Base { x = super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. y() { return super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } z: typeof super.foo; // error ~~~~~ !!! error TS1003: Identifier expected. ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. a: this.foo; // error ~~~~ diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt index f2b19d043c27a..897636b6d90c1 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts (1 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce this.x; // OK, accessed within a subclass of the declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt index 03671925febc1..4b950c70019b0 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(14,23): error TS2339: Property 'z' does not exist on type 'B'. -tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(18,24): error TS2339: Property 'y' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(19,24): error TS2339: Property 'z' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(22,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAcc var s1 = super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var s2 = super.f(); var s3 = super.y; // error ~ diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt index 1f1bd72617c12..b6fa239f2910f 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts (2 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -25,6 +25,6 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superAccess.errors.txt b/tests/baselines/reference/superAccess.errors.txt index 64c921e0e7f99..f506bb9f13648 100644 --- a/tests/baselines/reference/superAccess.errors.txt +++ b/tests/baselines/reference/superAccess.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/superAccess.ts(9,24): error TS2339: Property 'S1' does not exist on type 'MyBase'. -tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superAccess.ts (3 errors) ==== @@ -17,9 +17,9 @@ tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protec !!! error TS2339: Property 'S1' does not exist on type 'MyBase'. var l4 = super.S2; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l5 = super.f(); // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superAccess2.errors.txt b/tests/baselines/reference/superAccess2.errors.txt index eda3e29bb0a88..d8b39284f6567 100644 --- a/tests/baselines/reference/superAccess2.errors.txt +++ b/tests/baselines/reference/superAccess2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments. tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access. @@ -25,7 +25,7 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not !!! error TS1034: 'super' must be followed by an argument list or member access. static yy = super; // error for static initializer accessing super ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. diff --git a/tests/baselines/reference/superCallOutsideConstructor.errors.txt b/tests/baselines/reference/superCallOutsideConstructor.errors.txt index 2cdcaad189163..c22c4d33b5db9 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.errors.txt +++ b/tests/baselines/reference/superCallOutsideConstructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/superCallOutsideConstructor.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super class D extends C { x = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. constructor() { super(); @@ -19,13 +19,13 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super var y = () => { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } var y2 = function() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } } diff --git a/tests/baselines/reference/superErrors.errors.txt b/tests/baselines/reference/superErrors.errors.txt index fad592b490cc7..26e0ba3a6c410 100644 --- a/tests/baselines/reference/superErrors.errors.txt +++ b/tests/baselines/reference/superErrors.errors.txt @@ -4,12 +4,12 @@ tests/cases/compiler/superErrors.ts(4,19): error TS2335: 'super' can only be ref tests/cases/compiler/superErrors.ts(4,24): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(5,31): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/superErrors.ts(5,36): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(31,41): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(43,41): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(47,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(48,28): error TS1034: 'super' must be followed by an argument list or member access. @@ -52,20 +52,20 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in an inner function in a constructor function inner2() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } @@ -77,13 +77,13 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superInLambdas.errors.txt b/tests/baselines/reference/superInLambdas.errors.txt index 7587ed82ef11e..a3863d00c02b9 100644 --- a/tests/baselines/reference/superInLambdas.errors.txt +++ b/tests/baselines/reference/superInLambdas.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superInLambdas.ts(61,34): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be followed by an argument list or member access. @@ -53,13 +53,13 @@ tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be fol // super property in a nested lambda in a constructor var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } sayHello(): void { // super property in a nested lambda in a method var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } diff --git a/tests/baselines/reference/superPropertyAccess.errors.txt b/tests/baselines/reference/superPropertyAccess.errors.txt index 4880bf66f17c4..41e0a0adac53a 100644 --- a/tests/baselines/reference/superPropertyAccess.errors.txt +++ b/tests/baselines/reference/superPropertyAccess.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/superPropertyAccess.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess.ts(24,9): error TS2341: Property 'p1' is private and only accessible within class 'MyBase'. -tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess.ts (8 errors) ==== @@ -36,7 +36,7 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an super.m2.bind(this); // Should error, instance property, not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.p1(); // Should error, private not public instance member function ~~~~~~~~ @@ -44,20 +44,20 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an var l1 = super.d1; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l1 = super.d2; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.m1 = function (a: string) { return ""; }; // Should be allowed, we will not restrict assignment super.value = 0; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var z = super.value; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess1.errors.txt b/tests/baselines/reference/superPropertyAccess1.errors.txt index b256860ec72e3..aed25fd6a92c8 100644 --- a/tests/baselines/reference/superPropertyAccess1.errors.txt +++ b/tests/baselines/reference/superPropertyAccess1.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/superPropertyAccess1.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess1.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess1.ts (5 errors) ==== @@ -22,7 +22,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } constructor() { @@ -30,7 +30,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public get y() { @@ -39,7 +39,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess2.errors.txt b/tests/baselines/reference/superPropertyAccess2.errors.txt index 475705f150610..2512ad91faec1 100644 --- a/tests/baselines/reference/superPropertyAccess2.errors.txt +++ b/tests/baselines/reference/superPropertyAccess2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/superPropertyAccess2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(13,15): error TS2339: Property 'x' does not exist on type 'typeof C'. tests/cases/compiler/superPropertyAccess2.ts(18,15): error TS2339: Property 'bar' does not exist on type 'C'. -tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess2.ts(22,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' does not exist on type 'typeof C'. @@ -33,7 +33,7 @@ tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' !!! error TS2339: Property 'bar' does not exist on type 'C'. super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public static get y() { diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt index 44332e6e56725..4f1faf78a7823 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): e tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ==== @@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return super.test(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } From 933a2fa6df4345cfd91df7868f69f7cc7f84e5ee Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 19 Jun 2015 16:00:03 -0700 Subject: [PATCH 120/250] updated baseline for new __extends impl --- tests/baselines/reference/abstractClass1.js | 3 +-- tests/baselines/reference/classAbstractInheritance.js | 3 +-- tests/baselines/reference/classAbstractSuperCalls.js | 3 +-- tests/baselines/reference/classAbstractUsingAbstractMethod.js | 3 +-- tests/baselines/reference/classInstantiatingAbstractClass.js | 3 +-- tests/baselines/reference/classWithAbstractMethods.js | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/abstractClass1.js b/tests/baselines/reference/abstractClass1.js index 494673d6ce042..06868a485f5eb 100644 --- a/tests/baselines/reference/abstractClass1.js +++ b/tests/baselines/reference/abstractClass1.js @@ -40,8 +40,7 @@ new Copy(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo(f) { diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js index 2aa156500e0ac..6656e4687d239 100644 --- a/tests/baselines/reference/classAbstractInheritance.js +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -25,8 +25,7 @@ abstract class GG extends CC {} var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js index 7841785ac055a..152fd03f463ef 100644 --- a/tests/baselines/reference/classAbstractSuperCalls.js +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -31,8 +31,7 @@ abstract class BB extends AA { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod.js b/tests/baselines/reference/classAbstractUsingAbstractMethod.js index 26a406aa008a5..74bc80b263005 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethod.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod.js @@ -21,8 +21,7 @@ a.foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.js b/tests/baselines/reference/classInstantiatingAbstractClass.js index 5a23d3d9b4098..6a2c3f31e37b6 100644 --- a/tests/baselines/reference/classInstantiatingAbstractClass.js +++ b/tests/baselines/reference/classInstantiatingAbstractClass.js @@ -31,8 +31,7 @@ var aa = new myA; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classWithAbstractMethods.js b/tests/baselines/reference/classWithAbstractMethods.js index 2035ba20ea9f6..91ccc5f9306ad 100644 --- a/tests/baselines/reference/classWithAbstractMethods.js +++ b/tests/baselines/reference/classWithAbstractMethods.js @@ -31,8 +31,7 @@ class DD extends AA { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { From 5b32903ab40549efc9cefd4f5f73688dff101a0a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 19 Jun 2015 16:01:12 -0700 Subject: [PATCH 121/250] Fix async function emit for lexical arguments --- src/compiler/checker.ts | 1 + src/compiler/emitter.ts | 57 +++++++++++-------- src/compiler/types.ts | 9 +-- .../reference/asyncArrowFunction1_es6.js | 2 +- .../reference/asyncArrowFunction6_es6.js | 2 +- .../reference/asyncArrowFunction7_es6.js | 4 +- .../reference/asyncArrowFunction8_es6.js | 2 +- ...asyncArrowFunctionCapturesArguments_es6.js | 2 +- .../asyncArrowFunctionCapturesThis_es6.js | 2 +- .../asyncAwaitIsolatedModules_es6.js | 55 +++++++++--------- tests/baselines/reference/asyncAwait_es6.js | 55 +++++++++--------- .../asyncFunctionDeclaration11_es6.js | 2 +- .../asyncFunctionDeclaration13_es6.js | 2 +- .../asyncFunctionDeclaration14_es6.js | 2 +- .../asyncFunctionDeclaration1_es6.js | 2 +- .../asyncFunctionDeclaration6_es6.js | 2 +- .../asyncFunctionDeclaration7_es6.js | 4 +- .../asyncFunctionDeclaration9_es6.js | 2 +- .../reference/awaitBinaryExpression1_es6.js | 2 +- .../reference/awaitBinaryExpression2_es6.js | 2 +- .../reference/awaitBinaryExpression3_es6.js | 2 +- .../reference/awaitBinaryExpression4_es6.js | 2 +- .../reference/awaitBinaryExpression5_es6.js | 2 +- .../reference/awaitCallExpression1_es6.js | 2 +- .../reference/awaitCallExpression2_es6.js | 2 +- .../reference/awaitCallExpression3_es6.js | 2 +- .../reference/awaitCallExpression4_es6.js | 2 +- .../reference/awaitCallExpression5_es6.js | 2 +- .../reference/awaitCallExpression6_es6.js | 2 +- .../reference/awaitCallExpression7_es6.js | 2 +- .../reference/awaitCallExpression8_es6.js | 2 +- tests/baselines/reference/awaitUnion_es6.js | 2 +- 32 files changed, 122 insertions(+), 113 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5445c7f919e2b..53c5e3d883337 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5765,6 +5765,7 @@ namespace ts { if (node.parserContextFlags & ParserContextFlags.Await) { getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; + getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d537380dc5d8f..a5271b27c2cab 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -49,11 +49,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { };`; const awaiterHelper = ` -var __awaiter = (this && this.__awaiter) || function (args, generator) { - var PromiseConstructor = args[1] || Promise; - return new PromiseConstructor(function (resolve, reject) { - generator = generator.call(args[0], args[2]); - function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } function step(verb, value) { @@ -1239,6 +1238,11 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { } function emitExpressionIdentifier(node: Identifier) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalArguments) { + write("_arguments"); + return; + } + let container = resolver.getReferencedExportContainer(node); if (container) { if (container.kind === SyntaxKind.SourceFile) { @@ -3374,9 +3378,9 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { // let a = async (b) => { await b; } // // // output - // let a = (b) => __awaiter([this], function* (b) { + // let a = (b) => __awaiter(this, void 0, void 0, function* () { // yield b; - // }, this); + // }); // // The emit for an async arrow with a lexical `arguments` binding might be: // @@ -3384,7 +3388,7 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { // let a = async (b) => { await arguments[0]; } // // // output - // let a = (b) => __awaiter([this, arguments], function* (arguments) { + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { // yield arguments[0]; // }); // @@ -3398,9 +3402,9 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { // // // output // let a = function (b) { - // return __awaiter([this], function* () { + // return __awaiter(this, void 0, void 0, function* () { // yield b; - // }, this); + // }); // } // // The emit for an async function expression with a lexical `arguments` binding @@ -3413,8 +3417,8 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { // // // output // let a = function (b) { - // return __awaiter([this, arguments], function* (arguments) { - // yield arguments[0]; + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; // }); // } // @@ -3428,8 +3432,8 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { // // // output // let a = function (b) { - // return __awaiter([this, arguments, MyPromise], function* (arguments) { - // yield arguments[0]; + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; // }); // } // @@ -3443,23 +3447,28 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { write("return"); } - write(" __awaiter([this"); - if (promiseConstructor || hasLexicalArguments) { + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + + if (promiseConstructor) { write(", "); - if (promiseConstructor) { - emitNodeWithoutSourceMap(promiseConstructor); - } - if (hasLexicalArguments) { - write(", arguments"); - } + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); } // Emit the call to __awaiter. if (hasLexicalArguments) { - write("], function* (arguments)"); + write(", function* (_arguments)"); } else { - write("], function* ()"); + write(", function* ()"); } // Emit the signature and body for the inner generator function. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index db2eafe4e5377..e55cccc0cccef 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1595,12 +1595,13 @@ namespace ts { SuperInstance = 0x00000100, // Instance 'super' reference SuperStatic = 0x00000200, // Static 'super' reference ContextChecked = 0x00000400, // Contextual types have been assigned - CaptureArguments = 0x00000800, // Lexical 'arguments' used in body (for async functions) + LexicalArguments = 0x00000800, + CaptureArguments = 0x00001000, // Lexical 'arguments' used in body (for async functions) // Values for enum members have been computed, and any errors have been reported for them. - EnumValuesComputed = 0x00001000, - BlockScopedBindingInLoop = 0x00002000, - LexicalModuleMergesWithClass= 0x00004000, // Instantiated lexical module declaration is merged with a previous class declaration. + EnumValuesComputed = 0x00002000, + BlockScopedBindingInLoop = 0x00004000, + LexicalModuleMergesWithClass= 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. } /* @internal */ diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js index 2c2f1091b1537..4f03acc5ced43 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.js +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -4,5 +4,5 @@ var foo = async (): Promise => { }; //// [asyncArrowFunction1_es6.js] -var foo = () => __awaiter([this, Promise], function* () { +var foo = () => __awaiter(this, void 0, Promise, function* () { }); diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js index 0a39441edf795..54b8aa1f6b154 100644 --- a/tests/baselines/reference/asyncArrowFunction6_es6.js +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -4,5 +4,5 @@ var foo = async (a = await): Promise => { } //// [asyncArrowFunction6_es6.js] -var foo = (a = yield ) => __awaiter([this, Promise], function* () { +var foo = (a = yield ) => __awaiter(this, void 0, Promise, function* () { }); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js index bb17963bfd371..ac68a8fd2f865 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es6.js +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -7,8 +7,8 @@ var bar = async (): Promise => { } //// [asyncArrowFunction7_es6.js] -var bar = () => __awaiter([this, Promise], function* () { +var bar = () => __awaiter(this, void 0, Promise, function* () { // 'await' here is an identifier, and not an await expression. - var foo = (a = yield ) => __awaiter([this, Promise], function* () { + var foo = (a = yield ) => __awaiter(this, void 0, Promise, function* () { }); }); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js index 2ec2325951055..9cee5ee1525d7 100644 --- a/tests/baselines/reference/asyncArrowFunction8_es6.js +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -5,6 +5,6 @@ var foo = async (): Promise => { } //// [asyncArrowFunction8_es6.js] -var foo = () => __awaiter([this, Promise], function* () { +var foo = () => __awaiter(this, void 0, Promise, function* () { var v = { [yield ]: foo }; }); diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js index 8cac736ea1b6d..c24259cf0b528 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -11,6 +11,6 @@ class C { class C { method() { function other() { } - var fn = () => __awaiter([this, , arguments], function* (arguments) { return yield other.apply(this, arguments); }); + var fn = () => __awaiter(this, arguments, Promise, function* (_arguments) { return yield other.apply(this, _arguments); }); } } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js index b13815ffcbf41..0f09e366ef3dc 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -9,6 +9,6 @@ class C { //// [asyncArrowFunctionCapturesThis_es6.js] class C { method() { - var fn = () => __awaiter([this], function* () { return yield this; }); + var fn = () => __awaiter(this, void 0, Promise, function* () { return yield this; }); } } diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js index 7fb55df0eae63..7007c66ae2810 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js @@ -40,11 +40,10 @@ module M { } //// [asyncAwaitIsolatedModules_es6.js] -var __awaiter = (this && this.__awaiter) || function (args, generator) { - var PromiseConstructor = args[1] || Promise; - return new PromiseConstructor(function (resolve, reject) { - generator = generator.call(args[0], args[2]); - function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } function step(verb, value) { @@ -55,65 +54,65 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { }); }; function f0() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } function f1() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } function f3() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } let f4 = function () { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }; let f5 = function () { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }; let f6 = function () { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); }; -let f7 = () => __awaiter([this], function* () { }); -let f8 = () => __awaiter([this, Promise], function* () { }); -let f9 = () => __awaiter([this, MyPromise], function* () { }); -let f10 = () => __awaiter([this], function* () { return p; }); -let f11 = () => __awaiter([this], function* () { return mp; }); -let f12 = () => __awaiter([this, Promise], function* () { return mp; }); -let f13 = () => __awaiter([this, MyPromise], function* () { return p; }); +let f7 = () => __awaiter(this, void 0, Promise, function* () { }); +let f8 = () => __awaiter(this, void 0, Promise, function* () { }); +let f9 = () => __awaiter(this, void 0, MyPromise, function* () { }); +let f10 = () => __awaiter(this, void 0, Promise, function* () { return p; }); +let f11 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f12 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f13 = () => __awaiter(this, void 0, MyPromise, function* () { return p; }); let o = { m1() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }, m2() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }, m3() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } }; class C { m1() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } m2() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } m3() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } static m4() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } static m5() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } static m6() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } } var M; (function (M) { function f1() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } M.f1 = f1; })(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js index 2c0ffaf478a1c..155a44d339dbb 100644 --- a/tests/baselines/reference/asyncAwait_es6.js +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -40,11 +40,10 @@ module M { } //// [asyncAwait_es6.js] -var __awaiter = (this && this.__awaiter) || function (args, generator) { - var PromiseConstructor = args[1] || Promise; - return new PromiseConstructor(function (resolve, reject) { - generator = generator.call(args[0], args[2]); - function cast(value) { return value instanceof PromiseConstructor ? value : new PromiseConstructor(function (resolve) { resolve(value); }); } +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } function step(verb, value) { @@ -55,65 +54,65 @@ var __awaiter = (this && this.__awaiter) || function (args, generator) { }); }; function f0() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } function f1() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } function f3() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } let f4 = function () { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }; let f5 = function () { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }; let f6 = function () { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); }; -let f7 = () => __awaiter([this], function* () { }); -let f8 = () => __awaiter([this, Promise], function* () { }); -let f9 = () => __awaiter([this, MyPromise], function* () { }); -let f10 = () => __awaiter([this], function* () { return p; }); -let f11 = () => __awaiter([this], function* () { return mp; }); -let f12 = () => __awaiter([this, Promise], function* () { return mp; }); -let f13 = () => __awaiter([this, MyPromise], function* () { return p; }); +let f7 = () => __awaiter(this, void 0, Promise, function* () { }); +let f8 = () => __awaiter(this, void 0, Promise, function* () { }); +let f9 = () => __awaiter(this, void 0, MyPromise, function* () { }); +let f10 = () => __awaiter(this, void 0, Promise, function* () { return p; }); +let f11 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f12 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f13 = () => __awaiter(this, void 0, MyPromise, function* () { return p; }); let o = { m1() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }, m2() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); }, m3() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } }; class C { m1() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } m2() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } m3() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } static m4() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } static m5() { - return __awaiter([this, Promise], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } static m6() { - return __awaiter([this, MyPromise], function* () { }); + return __awaiter(this, void 0, MyPromise, function* () { }); } } var M; (function (M) { function f1() { - return __awaiter([this], function* () { }); + return __awaiter(this, void 0, Promise, function* () { }); } M.f1 = f1; })(M || (M = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js index 7cc10548371c7..a44343cef7822 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -4,6 +4,6 @@ async function await(): Promise { //// [asyncFunctionDeclaration11_es6.js] function await() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js index f17b5c894f8cf..4257c8691c25b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -7,7 +7,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration13_es6.js] function foo() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { // Legal to use 'await' in a type context. var v; }); diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js index 7fee3f4802abb..f32d106f92e37 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -5,7 +5,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration14_es6.js] function foo() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { return; }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js index 3e58785802185..263e27fa35efa 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -4,6 +4,6 @@ async function foo(): Promise { //// [asyncFunctionDeclaration1_es6.js] function foo() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js index 33645996cd880..8c37968ab4c22 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -4,6 +4,6 @@ async function foo(a = await): Promise { //// [asyncFunctionDeclaration6_es6.js] function foo(a = yield ) { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { }); } diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js index 667250e45db61..ef66df4e4133a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -7,10 +7,10 @@ async function bar(): Promise { //// [asyncFunctionDeclaration7_es6.js] function bar() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { // 'await' here is an identifier, and not a yield expression. function foo(a = yield ) { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { }); } }); diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js index dab1b75076e68..9723a69f2a23b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -5,7 +5,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration9_es6.js] function foo() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { var v = { [yield ]: foo }; }); } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js index 11b630355d40d..8deb771f5abf2 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -9,7 +9,7 @@ async function func(): Promise { //// [awaitBinaryExpression1_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = (yield p) || a; "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js index e8f610ae10ac2..506af50a0efba 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -9,7 +9,7 @@ async function func(): Promise { //// [awaitBinaryExpression2_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = (yield p) && a; "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js index 770bf75d5a1e1..4b298d7b94751 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -9,7 +9,7 @@ async function func(): Promise { //// [awaitBinaryExpression3_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = (yield p) + a; "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js index f756d6604bb0f..4d31358898442 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -9,7 +9,7 @@ async function func(): Promise { //// [awaitBinaryExpression4_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = yield p, a; "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js index c66cfbbd57a2b..01d6c50f6f03e 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.js +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -10,7 +10,7 @@ async function func(): Promise { //// [awaitBinaryExpression5_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var o; o.a = yield p; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js index db4e0c96abf9f..f9dad87a8b6b3 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.js +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression1_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = fn(a, a, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js index 47b1e062ae5b8..87d99cd079399 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.js +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression2_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = fn(yield p, a, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js index e7a09f9b9b883..f397d83c3a14e 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.js +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression3_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = fn(a, yield p, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js index 59449e4f6a14b..d8824d7e7a007 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.js +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression4_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = (yield pfn)(a, a, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js index c5e28deee89bc..f39a633765d88 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.js +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression5_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = o.fn(a, a, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js index 62fde8c799ca3..de8477fa9388a 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.js +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression6_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = o.fn(yield p, a, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js index f717d76c51dee..24edc3b9393e6 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.js +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression7_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = o.fn(a, yield p, a); "after"; diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js index e6e2cee172bc2..8bee6112a7a39 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.js +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -13,7 +13,7 @@ async function func(): Promise { //// [awaitCallExpression8_es6.js] function func() { - return __awaiter([this, Promise], function* () { + return __awaiter(this, void 0, Promise, function* () { "before"; var b = (yield po).fn(a, a, a); "after"; diff --git a/tests/baselines/reference/awaitUnion_es6.js b/tests/baselines/reference/awaitUnion_es6.js index 7ac556b01bca4..80c68f811ef95 100644 --- a/tests/baselines/reference/awaitUnion_es6.js +++ b/tests/baselines/reference/awaitUnion_es6.js @@ -14,7 +14,7 @@ async function f() { //// [awaitUnion_es6.js] function f() { - return __awaiter([this], function* () { + return __awaiter(this, void 0, Promise, function* () { let await_a = yield a; let await_b = yield b; let await_c = yield c; From 24da34c4ad7a2b1fd5fe6fbb66016809c382fd4b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 19 Jun 2015 16:20:00 -0700 Subject: [PATCH 122/250] fixed some indentation quirks, comments --- src/compiler/checker.ts | 53 +++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3b9b0301fb899..bf455b87e088e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2003,7 +2003,7 @@ namespace ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -4585,9 +4585,7 @@ namespace ts { let sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp === targetProp) { // source inherits targetProp and doesn't redeclare/override it. - if (source.flags & TypeFlags.Class && target.flags & TypeFlags.Class) { - let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); let sourceDecl = getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration); @@ -6035,20 +6033,20 @@ namespace 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; } } } @@ -7666,7 +7664,7 @@ namespace ts { /** * Performs typechecking on the given node, which is a call/new expression. * @param node The call expression to be checked. - * @returns On success, the expression's signature's return type. On failure, any. + * @returns On success, the expression's signature's return type. On failure, anyType. */ function checkCallExpression(node: CallExpression): Type { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true @@ -8166,8 +8164,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -8355,7 +8353,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // fall-through + // Otherwise fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -9578,7 +9576,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // Otherwise fall through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -10705,8 +10703,6 @@ namespace ts { checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type @@ -10798,7 +10794,6 @@ namespace ts { error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2, typeToString(type), typeToString(baseType), symbolToString(baseProperty)); } - } else { // derived !== undefined -- derived overrides base let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { @@ -12088,7 +12083,7 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // fall-through + // Otherwise fall through case SyntaxKind.NumericLiteral: // index access @@ -12261,7 +12256,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -12512,11 +12507,11 @@ namespace ts { // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case SyntaxKind.ClassDeclaration: return "Function"; - case SyntaxKind.PropertyDeclaration: return serializeTypeNode((node).type); - case SyntaxKind.Parameter: return serializeTypeNode((node).type); - case SyntaxKind.GetAccessor: return serializeTypeNode((node).type); - case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); + case SyntaxKind.ClassDeclaration: return "Function"; + case SyntaxKind.PropertyDeclaration: return serializeTypeNode((node).type); + case SyntaxKind.Parameter: return serializeTypeNode((node).type); + case SyntaxKind.GetAccessor: return serializeTypeNode((node).type); + case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (isFunctionLike(node)) { return "Function"; From 76c0d32f9da2a378f12e427b52edade900576915 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 19 Jun 2015 18:05:43 -0700 Subject: [PATCH 123/250] Moved async functions for ES6 behind experimental flag --- src/compiler/checker.ts | 4 ++++ src/compiler/commandLineParser.ts | 5 +++++ src/compiler/diagnosticInformationMap.generated.ts | 3 +++ src/compiler/diagnosticMessages.json | 12 ++++++++++++ src/compiler/program.ts | 7 ++++++- src/compiler/types.ts | 1 + src/harness/harness.ts | 4 ++++ .../asyncArrowFunction/asyncArrowFunction10_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction1_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction2_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction3_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction4_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction5_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction6_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction7_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction8_es6.ts | 1 + .../asyncArrowFunction/asyncArrowFunction9_es6.ts | 1 + .../asyncArrowFunctionCapturesArguments_es6.ts | 1 + .../asyncArrowFunctionCapturesThis_es6.ts | 1 + .../async/es6/asyncAwaitIsolatedModules_es6.ts | 1 + tests/cases/conformance/async/es6/asyncAwait_es6.ts | 1 + tests/cases/conformance/async/es6/asyncClass_es6.ts | 1 + .../conformance/async/es6/asyncConstructor_es6.ts | 1 + .../cases/conformance/async/es6/asyncDeclare_es6.ts | 1 + tests/cases/conformance/async/es6/asyncEnum_es6.ts | 1 + tests/cases/conformance/async/es6/asyncGetter_es6.ts | 1 + .../conformance/async/es6/asyncInterface_es6.ts | 1 + tests/cases/conformance/async/es6/asyncModule_es6.ts | 1 + tests/cases/conformance/async/es6/asyncSetter_es6.ts | 1 + .../awaitBinaryExpression1_es6.ts | 1 + .../awaitBinaryExpression2_es6.ts | 1 + .../awaitBinaryExpression3_es6.ts | 1 + .../awaitBinaryExpression4_es6.ts | 1 + .../awaitBinaryExpression5_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression1_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression2_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression3_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression4_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression5_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression6_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression7_es6.ts | 1 + .../awaitCallExpression/awaitCallExpression8_es6.ts | 1 + tests/cases/conformance/async/es6/awaitUnion_es6.ts | 1 + .../asyncFunctionDeclaration10_es6.ts | 1 + .../asyncFunctionDeclaration11_es6.ts | 1 + .../asyncFunctionDeclaration12_es6.ts | 1 + .../asyncFunctionDeclaration13_es6.ts | 1 + .../asyncFunctionDeclaration14_es6.ts | 1 + .../asyncFunctionDeclaration1_es6.ts | 1 + .../asyncFunctionDeclaration2_es6.ts | 1 + .../asyncFunctionDeclaration3_es6.ts | 1 + .../asyncFunctionDeclaration4_es6.ts | 1 + .../asyncFunctionDeclaration5_es6.ts | 1 + .../asyncFunctionDeclaration6_es6.ts | 1 + .../asyncFunctionDeclaration7_es6.ts | 1 + .../asyncFunctionDeclaration8_es6.ts | 1 + .../asyncFunctionDeclaration9_es6.ts | 1 + 57 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 53c5e3d883337..87b5ac44dce23 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9863,6 +9863,10 @@ namespace ts { checkSignatureDeclaration(node); let isAsync = isAsyncFunctionLike(node); if (isAsync) { + if (!compilerOptions.experimentalAsyncFunctions) { + error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); + } + emitAwaiter = true; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 07bccf4a5efa3..f2b7dcc91c134 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -192,6 +192,11 @@ namespace ts { type: "boolean", description: Diagnostics.Watch_input_files, }, + { + name: "experimentalAsyncFunctions", + type: "boolean", + description: Diagnostics.Enables_experimental_support_for_ES7_async_functions + }, { name: "experimentalDecorators", type: "boolean", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 6cd9a803aa4a7..beb35eec9bf1e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -201,6 +201,7 @@ namespace ts { An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, @@ -547,6 +548,8 @@ namespace ts { Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, + Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4ad7408d70d17..089ddb6a83ed8 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -791,6 +791,10 @@ "category": "Error", "code": 1235 }, + "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": { + "category": "Error", + "code": 1236 + }, "'with' statements are not allowed in an async function block.": { @@ -2180,6 +2184,14 @@ "category": "Message", "code": 6066 }, + "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": { + "category": "Message", + "code": 6067 + }, + "Enables experimental support for ES7 async functions.": { + "category": "Message", + "code": 6068 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 562654c2ed0c1..4484addd84eae 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -144,7 +144,7 @@ namespace ts { let program: Program; let files: SourceFile[] = []; let diagnostics = createDiagnosticCollection(); - + let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; let noDiagnosticsTypeChecker: TypeChecker; @@ -676,6 +676,11 @@ namespace ts { !options.experimentalDecorators) { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + + if (options.experimentalAsyncFunctions && + options.target !== ScriptTarget.ES6) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } } \ No newline at end of file diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e55cccc0cccef..3d9d4151079d3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1878,6 +1878,7 @@ namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; + experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6a55948815010..8e8fb8d9acb84 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1055,6 +1055,10 @@ module Harness { case 'emitdecoratormetadata': options.emitDecoratorMetadata = setting.value === 'true'; break; + + case 'experimentalasyncfunctions': + options.experimentalAsyncFunctions = setting.value === 'true'; + break; case 'noemithelpers': options.noEmitHelpers = setting.value === 'true'; diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts index 0959ed6c561e8..bb9f8a54e44a1 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var foo = async foo(): Promise => { // Legal to use 'await' in a type context. diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts index 83e7413c5279a..45e686fd280c3 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var foo = async (): Promise => { }; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts index bf39735d4603f..8d792fdff9c40 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var f = (await) => { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts index 4ae27c596f1ab..9ca200f8d76f8 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true function f(await = await) { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts index 51b34abeca1aa..4946592c45bb6 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var await = () => { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts index 174a619bdf9f9..53052368b31a7 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var foo = async (await): Promise => { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts index dace96c4933da..69768429ecf1a 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var foo = async (a = await): Promise => { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts index b1fd5cc030d97..a034381ba57d2 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var bar = async (): Promise => { // 'await' here is an identifier, and not an await expression. diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts index 5d53338b1bd78..397e06f703dad 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var foo = async (): Promise => { var v = { [await]: foo } diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts index da041fe472b30..3f961c9d59592 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var foo = async (a = await => await): Promise => { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts index 8dab2c0408630..f00d0d16545c5 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true class C { method() { function other() {} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts index f2c507cbdd667..a90f08cb9f779 100644 --- a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true class C { method() { var fn = async () => await this; diff --git a/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts index 8e2cfd8c6c578..52694f241185d 100644 --- a/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts +++ b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @isolatedModules: true +// @experimentalAsyncFunctions: true import { MyPromise } from "missing"; declare var p: Promise; diff --git a/tests/cases/conformance/async/es6/asyncAwait_es6.ts b/tests/cases/conformance/async/es6/asyncAwait_es6.ts index 8e72197a98d9a..eee2e73d023c9 100644 --- a/tests/cases/conformance/async/es6/asyncAwait_es6.ts +++ b/tests/cases/conformance/async/es6/asyncAwait_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @experimentalAsyncFunctions: true type MyPromise = Promise; declare var MyPromise: typeof Promise; declare var p: Promise; diff --git a/tests/cases/conformance/async/es6/asyncClass_es6.ts b/tests/cases/conformance/async/es6/asyncClass_es6.ts index 22ffe997b03cd..c4a444ca90958 100644 --- a/tests/cases/conformance/async/es6/asyncClass_es6.ts +++ b/tests/cases/conformance/async/es6/asyncClass_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async class C { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncConstructor_es6.ts b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts index d769fad039525..998156f19f41f 100644 --- a/tests/cases/conformance/async/es6/asyncConstructor_es6.ts +++ b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true class C { async constructor() { } diff --git a/tests/cases/conformance/async/es6/asyncDeclare_es6.ts b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts index 5e0fb536b395f..d83c25a421a11 100644 --- a/tests/cases/conformance/async/es6/asyncDeclare_es6.ts +++ b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts @@ -1,3 +1,4 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncEnum_es6.ts b/tests/cases/conformance/async/es6/asyncEnum_es6.ts index 4fad7923a8c93..d9569bef9d17e 100644 --- a/tests/cases/conformance/async/es6/asyncEnum_es6.ts +++ b/tests/cases/conformance/async/es6/asyncEnum_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async enum E { Value } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncGetter_es6.ts b/tests/cases/conformance/async/es6/asyncGetter_es6.ts index 79fde60fdc4bb..fe5751ece0be7 100644 --- a/tests/cases/conformance/async/es6/asyncGetter_es6.ts +++ b/tests/cases/conformance/async/es6/asyncGetter_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true class C { async get foo() { } diff --git a/tests/cases/conformance/async/es6/asyncInterface_es6.ts b/tests/cases/conformance/async/es6/asyncInterface_es6.ts index 5d5497d3cd4bf..c7bb460ea2b2c 100644 --- a/tests/cases/conformance/async/es6/asyncInterface_es6.ts +++ b/tests/cases/conformance/async/es6/asyncInterface_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async interface I { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncModule_es6.ts b/tests/cases/conformance/async/es6/asyncModule_es6.ts index aa4c295d0e357..cf660d25d1f85 100644 --- a/tests/cases/conformance/async/es6/asyncModule_es6.ts +++ b/tests/cases/conformance/async/es6/asyncModule_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async module M { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncSetter_es6.ts b/tests/cases/conformance/async/es6/asyncSetter_es6.ts index 8eedcbb5288a2..2ca1c805a453e 100644 --- a/tests/cases/conformance/async/es6/asyncSetter_es6.ts +++ b/tests/cases/conformance/async/es6/asyncSetter_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true class C { async set foo(value) { } diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts index 46060f309b241..df0d0e459d470 100644 --- a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; async function func(): Promise { diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts index 362f1ecc4463f..7678c4b17abc1 100644 --- a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; async function func(): Promise { diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts index d3b02033252e1..0b441f063dded 100644 --- a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: number; declare var p: Promise; async function func(): Promise { diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts index eba3be31acfbc..a0bdf58710fc0 100644 --- a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; async function func(): Promise { diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts index 71b173f9e73a7..3276d24ee4bfa 100644 --- a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; async function func(): Promise { diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts index d0442f0968dc4..02de646112c57 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts index 6de07ef12ffee..5d2e4046349ad 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts index 2cc0b7b12d071..702e1f4cbcc15 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts index 8e349fbc5c329..aeeb192b4ba9a 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts index bbe81ac94b110..82bb1f88ad27b 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts index 09e88f5acbcdd..d5778df71ba79 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts index fe0182da4aa1b..db01f34c82531 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts index e3280eb7c10ff..b0b10a02a6ff5 100644 --- a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare var a: boolean; declare var p: Promise; declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; diff --git a/tests/cases/conformance/async/es6/awaitUnion_es6.ts b/tests/cases/conformance/async/es6/awaitUnion_es6.ts index a132ae01dfde2..59c5285556c53 100644 --- a/tests/cases/conformance/async/es6/awaitUnion_es6.ts +++ b/tests/cases/conformance/async/es6/awaitUnion_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true declare let a: number | string; declare let b: PromiseLike | PromiseLike; declare let c: PromiseLike; diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts index aab1f0013ecf9..d543e424a38cc 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(a = await => await): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts index 747d20d7ea850..23e40a0e5ba8a 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts index bbd7725036512..a457d27073f68 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts @@ -1,3 +1,4 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var v = async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts index 8670fa0281165..83b6a99579cc5 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(): Promise { // Legal to use 'await' in a type context. var v: await; diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts index ba70c61b49241..b837e6618d1ec 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(): Promise { return; } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts index 289a65bb74fe1..3a79214001105 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts index 25a153b4a3412..e75ef1d36a3b0 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true function f(await) { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts index 4ae27c596f1ab..9ca200f8d76f8 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true function f(await = await) { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts index 5d1ec389da366..ac4447a0e4d82 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true function await() { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts index eb3cd1db55675..60a0a8f4b7476 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(await): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts index 89b0445fd2efd..a3ab64b9d294d 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(a = await): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts index 5a964695da5e5..cde12c7dbe3fb 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function bar(): Promise { // 'await' here is an identifier, and not a yield expression. async function foo(a = await): Promise { diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts index 764b0f3fb8a79..52b6dba279279 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts @@ -1,3 +1,4 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true var v = { [await]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts index 7671764ad2add..662fa01760655 100644 --- a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts @@ -1,5 +1,6 @@ // @target: ES6 // @noEmitHelpers: true +// @experimentalAsyncFunctions: true async function foo(): Promise { var v = { [await]: foo } } \ No newline at end of file From 25553446ef95cf8f664165e4517794c898797095 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 22 Jun 2015 10:31:00 -0700 Subject: [PATCH 124/250] Misc cleanup --- src/compiler/checker.ts | 191 +++++++------ src/compiler/commandLineParser.ts | 10 +- .../diagnosticInformationMap.generated.ts | 9 +- src/compiler/diagnosticMessages.json | 21 +- src/compiler/parser.ts | 102 ++++--- .../reference/jsxAndTypeAssertion.errors.txt | 13 +- .../reference/jsxAndTypeAssertion.js | 6 +- .../jsxInvalidEsprimaTestSuite.errors.txt | 260 +++++++++++------- .../reference/jsxInvalidEsprimaTestSuite.js | 45 +-- .../tsxAttributeInvalidNames.errors.txt | 43 ++- .../reference/tsxAttributeInvalidNames.js | 13 +- .../tsxElementResolution10.errors.txt | 4 +- .../tsxElementResolution18.errors.txt | 4 +- .../tsxElementResolution8.errors.txt | 8 +- .../reference/tsxOpeningClosingNames.js | 14 + .../reference/tsxOpeningClosingNames.symbols | 20 ++ .../reference/tsxOpeningClosingNames.types | 28 ++ .../jsx/tsxAttributeInvalidNames.tsx | 3 +- .../jsx/tsxOpeningClosingNames.tsx | 11 + 19 files changed, 509 insertions(+), 296 deletions(-) create mode 100644 tests/baselines/reference/tsxOpeningClosingNames.js create mode 100644 tests/baselines/reference/tsxOpeningClosingNames.symbols create mode 100644 tests/baselines/reference/tsxOpeningClosingNames.types create mode 100644 tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3ee4b57b44a87..bb3096bf70a96 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -117,6 +117,7 @@ namespace ts { let globalTemplateStringsArrayType: ObjectType; let globalESSymbolType: ObjectType; let jsxElementType: ObjectType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ let jsxIntrinsicElementsType: ObjectType; let globalIterableType: GenericType; let globalIteratorType: GenericType; @@ -165,11 +166,11 @@ namespace ts { }; let JsxNames = { - JSX: 'JSX', - IntrinsicElements: 'IntrinsicElements', - ElementClass: 'ElementClass', - ElementAttributesPropertyNameContainer: 'ElementAttributesProperty', - Element: 'Element' + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" }; let subtypeRelation: Map = {}; @@ -3775,7 +3776,11 @@ namespace ts { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } - function getExportedTypeOfNamespace(namespace: string, name: string): Type { + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace: string, name: string): Type { var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); return (typeSymbol && getDeclaredTypeOfSymbol(typeSymbol)) || unknownType; @@ -6334,12 +6339,12 @@ namespace ts { return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - else if (expr.kind === SyntaxKind.JsxSpreadAttribute) { + + if (expr.kind === SyntaxKind.JsxSpreadAttribute) { return getJsxElementAttributesType(expr.parent); } - else { - return undefined; - } + + return undefined; } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily @@ -6692,43 +6697,59 @@ namespace ts { return jsxElementType; } + function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean { + if(lhs.kind !== rhs.kind) { + return false; + } + if(lhs.kind === SyntaxKind.Identifier) { + return (lhs).text === (rhs).text; + } + return (lhs).right.text === (rhs).right.text && + tagNamesAreEquivalent((lhs).left, (rhs).left); + } + function checkJsxElement(node: JsxElement) { // Check that the closing tag matches - let expectedClosingTag = getTextOfNode(node.openingElement.tagName); - if (expectedClosingTag !== getTextOfNode(node.closingElement.tagName)) { - error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, expectedClosingTag); + if(!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNode(node.openingElement.tagName)); } // Check attributes checkJsxOpeningLikeElement(node.openingElement); // Check children - for (var i = 0, n = node.children.length; i < n; i++) { - if (node.children[i].kind === SyntaxKind.JsxExpression) { - checkJsxExpression(node.children[i]); - } - else if (node.children[i].kind === SyntaxKind.JsxElement) { - checkJsxElement(node.children[i]); - } - else if (node.children[i].kind === SyntaxKind.JsxSelfClosingElement) { - checkJsxSelfClosingElement(node.children[i]); - } - else { - // No checks for JSX Text - Debug.assert(node.children[i].kind === SyntaxKind.JsxText); + let children = node.children; + for (var i = 0, n = children.length; i < n; i++) { + switch (children[i].kind) { + case SyntaxKind.JsxExpression: + checkJsxExpression(children[i]); + break; + case SyntaxKind.JsxElement: + checkJsxElement(children[i]); + break; + case SyntaxKind.JsxSelfClosingElement: + checkJsxSelfClosingElement(children[i]); + break; + default: + // No checks for JSX Text + Debug.assert(children[i].kind === SyntaxKind.JsxText); } } return jsxElementType; } - /// Returns true iff the JSX element name would be a valid identifier, ignoring restrictions about keywords not being identifiers + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ function isIdentifierLike(name: string) { // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers return name.indexOf('-') < 0; } - /// Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ function isJsxIntrinsicIdentifier(tagName: Identifier|QualifiedName) { if (tagName.kind === SyntaxKind.QualifiedName) { return false; @@ -6740,7 +6761,7 @@ namespace ts { } function checkJsxAttribute(node: JsxAttribute, elementAttributesType: Type, nameTable: Map) { - var correspondingPropType: Type = undefined; + let correspondingPropType: Type = undefined; // Look up the corresponding property for this attribute if (elementAttributesType === emptyObjectType && isIdentifierLike(node.name.text)) { @@ -6748,14 +6769,12 @@ namespace ts { error(node.parent, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType) { // If there's no corresponding property with this name, error - if (isIdentifierLike(node.name.text)) { - error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + if (!correspondingPropType && isIdentifierLike(node.name.text)) { + error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; } } @@ -6779,17 +6798,17 @@ namespace ts { function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { let type = checkExpression(node.expression); let props = getPropertiesOfType(type); - for (var i = 0; i < props.length; i++) { + for(let prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type - if (!nameTable[props[i].name]) { - let targetPropSym = getPropertyOfType(elementAttributesType, props[i].name); + if (!nameTable[prop.name]) { + let targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { - let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, props[i].name); - checkTypeAssignableTo(getTypeOfSymbol(props[i]), getTypeOfSymbol(targetPropSym), node, undefined, msg); + let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); } - nameTable[props[i].name] = true; + nameTable[prop.name] = true; } } } @@ -6813,7 +6832,7 @@ namespace ts { /// Otherwise, returns unknownSymbol. function getJsxElementTagSymbol(node: JsxOpeningLikeElement): Symbol { let flags: JsxFlags = JsxFlags.UnknownElement; - var links = getNodeLinks(node); + let links = getNodeLinks(node); if (!links.resolvedSymbol) { if (isJsxIntrinsicIdentifier(node.tagName)) { links.resolvedSymbol = lookupIntrinsicTag(node); @@ -6827,7 +6846,7 @@ namespace ts { let intrinsicElementsType = getJsxIntrinsicElementsType(); if (intrinsicElementsType !== unknownType) { // Property case - let intrinsicProp = getPropertyOfType(intrinsicElementsType, getTextOfNode(node.tagName)); + let intrinsicProp = getPropertyOfType(intrinsicElementsType, (node.tagName).text); if (intrinsicProp) { links.jsxFlags |= JsxFlags.IntrinsicNamedElement; return intrinsicProp; @@ -6841,7 +6860,7 @@ namespace ts { } // Wasn't found - error(node, Diagnostics.Property_0_does_not_exist_on_type_1, getTextOfNode(node.tagName), 'JSX.' + JsxNames.IntrinsicElements); + error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (node.tagName).text, 'JSX.' + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -6852,74 +6871,74 @@ namespace ts { } function lookupClassTag(node: JsxOpeningLikeElement): Symbol { - let valueSym: Symbol; + let valueSymbol: Symbol; // Look up the value in the current scope if (node.tagName.kind === SyntaxKind.Identifier) { - valueSym = getResolvedSymbol(node.tagName); + valueSymbol = getResolvedSymbol(node.tagName); } else { - valueSym = checkQualifiedName(node.tagName).symbol; + valueSymbol = checkQualifiedName(node.tagName).symbol; } - if (valueSym !== unknownSymbol) { + if (valueSymbol !== unknownSymbol) { links.jsxFlags |= JsxFlags.ClassElement; } - return valueSym || unknownSymbol; + return valueSymbol || unknownSymbol; } } - /// Given a JSX element that is a class element, finds the Element Instance Type. If the - /// element is not a class element, or the class element type cannot be determined, returns 'undefined'. - /// For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ function getJsxElementInstanceType(node: JsxOpeningLikeElement) { if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) { // There is no such thing as an instance type for a non-class element return undefined; } - var classSymbol = getJsxElementTagSymbol(node); + let classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued return anyType; } - var valueType = getTypeOfSymbol(classSymbol); + let valueType = getTypeOfSymbol(classSymbol); if (isTypeAny(valueType)) { // Short-circuit if the class tag is using an element type 'any' return anyType; } // Resolve the signatures, preferring constructors - var signatures = getSignaturesOfType(valueType, SignatureKind.Construct); + let signatures = getSignaturesOfType(valueType, SignatureKind.Construct); if (signatures.length === 0) { // No construct signatures, try call signatures signatures = getSignaturesOfType(valueType, SignatureKind.Call); - } - if (signatures.length === 0) { - // We found no signatures at all, which is an error - error(node.tagName, Diagnostics.JSX_element_0_is_not_a_constructor_function, getTextOfNode(node.tagName)); - return undefined; - } - else { - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); - if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { - error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName)); return undefined; } + } - // Issue an error if this return type isn't assignable to JSX.ElementClass - // TODO: Move this to a 'check' function - var elemClassType = getJsxGlobalElementClassType(); - if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_0_is_not_a_constructor_function_for_JSX_elements); - } + // Check that the constructor/factory returns an object type + let returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); + if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } - return returnType; + // Issue an error if this return type isn't assignable to JSX.ElementClass + let elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } + + return returnType; } /// e.g. "props" for React.d.ts, @@ -6954,8 +6973,10 @@ namespace ts { } } - /// Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells - /// us which attributes are valid on a given element. + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -7011,9 +7032,11 @@ namespace ts { return links.resolvedType; } - /// Given a JSX attribute, returns the symbol for the corresponds property - /// of the element attributes type. Will return unknownSymbol for attributes - /// that have no matching element attributes type property. + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ function getJsxAttributePropertySymbol(attrib: JsxAttribute): Symbol { let attributesType = getJsxElementAttributesType(attrib.parent); let prop = getPropertyOfType(attributesType, attrib.name.text); @@ -7021,7 +7044,7 @@ namespace ts { } function getJsxGlobalElementClassType(): Type { - var jsxNS = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + let jsxNS = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); if (jsxNS) { let sym = getSymbol(jsxNS.exports, JsxNames.ElementClass, SymbolFlags.Type); let elemClassType = sym && getDeclaredTypeOfSymbol(sym); @@ -7053,13 +7076,13 @@ namespace ts { checkGrammarJsxElement(node); checkJsxPreconditions(node); - var targetAttributesType = getJsxElementAttributesType(node); + let targetAttributesType = getJsxElementAttributesType(node); - var nameTable: Map = {}; + let nameTable: Map = {}; // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and // thus should have their types ignored - for (var i = node.attributes.length - 1; i >= 0; i--) { + for (let i = node.attributes.length - 1; i >= 0; i--) { if (node.attributes[i].kind === SyntaxKind.JsxAttribute) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } @@ -7072,7 +7095,7 @@ namespace ts { // Check that all required properties have been provided if (targetAttributesType) { let targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { + for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && nameTable[targetProperties[i].name] === undefined) { @@ -13070,7 +13093,7 @@ namespace ts { globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeOfNamespace("JSX", JsxNames.Element); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 648724ad94ec8..021d194b9e8cd 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -410,17 +410,17 @@ namespace ts { } function getFileNames(): string[] { - var fileNames: string[] = []; + let fileNames: string[] = []; if (hasProperty(json, "files")) { if (json["files"] instanceof Array) { fileNames = map(json["files"], s => combinePaths(basePath, s)); } } else { - var exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); - for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; + let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; + let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + for (let i = 0; i < sysFiles.length; i++) { + let name = sysFiles[i]; if (fileExtensionIs(name, ".d.ts")) { let baseName = name.substr(0, name.length - ".d.ts".length); if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index bd3737ee4bf64..0d90897359479 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -393,12 +393,11 @@ namespace ts { The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, The_global_type_JSX_Element_must_exist_when_using_JSX: { code: 2602, category: DiagnosticCategory.Error, key: "The global type 'JSX.Element' must exist when using JSX." }, Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, - JSX_element_0_is_not_a_constructor_function: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element '{0}' is not a constructor function." }, - JSX_element_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element '{0}' is not a constructor function for JSX elements." }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 2609, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface JSX.{0} exists" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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}'." }, @@ -543,7 +542,7 @@ namespace ts { NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specifies_how_to_transform_JSX_syntax_during_compilation: { code: 6080, category: DiagnosticCategory.Message, key: "Specifies how to transform JSX syntax during compilation." }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for --jsx must be 'preserve' or 'react'." }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, @@ -563,6 +562,7 @@ namespace ts { _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -582,7 +582,6 @@ namespace ts { decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, - class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." }, JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 23ab3b89f70e5..21e352af339ec 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1562,11 +1562,11 @@ "category": "Error", "code": 2603 }, - "JSX element '{0}' is not a constructor function.": { + "JSX element type '{0}' does not have any construct or call signatures.": { "category": "Error", "code": 2604 }, - "JSX element '{0}' is not a constructor function for JSX elements.": { + "JSX element type '{0}' is not a constructor function for JSX elements.": { "category": "Error", "code": 2605 }, @@ -1582,11 +1582,6 @@ "category": "Error", "code": 2608 }, - "JSX element implicitly has type 'any' because no interface JSX.{0} exists": { - "category": "Error", - "code": 2609 - }, - "Cannot emit namespaced JSX elements in React": { "category": "Error", "code": 2650 @@ -2165,7 +2160,7 @@ "category": "Message", "code": 6080 }, - "Argument for --jsx must be 'preserve' or 'react'.": { + "Argument for '--jsx' must be 'preserve' or 'react'.": { "category": "Message", "code": 6081 }, @@ -2246,6 +2241,12 @@ "category": "Error", "code": 7025 }, + "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists": { + "category": "Error", + "code": 7026 + }, + + "You cannot rename this element.": { "category": "Error", "code": 8000 @@ -2323,10 +2324,6 @@ "category": "Error", "code": 9003 }, - "'class' declarations are only supported directly inside a module or as a top level declaration.": { - "category": "Error", - "code": 9004 - }, "JSX attributes must only be assigned a non-empty 'expression'.": { "category": "Error", "code": 17000 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d89ab3a771bdd..adb2ba0e206f1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1205,7 +1205,7 @@ namespace ts { case ParsingContext.JsxAttributes: return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken; case ParsingContext.JsxChildren: - return token === SyntaxKind.LessThanToken || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.JsxText; + return true; case ParsingContext.JSDocFunctionParameters: case ParsingContext.JSDocTypeArguments: case ParsingContext.JSDocTupleTypes: @@ -1297,10 +1297,10 @@ namespace ts { case ParsingContext.HeritageClauses: return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken; case ParsingContext.JsxAttributes: - // For error recovery, include } here (otherwise an over-braced {expr}} will close the surrounding statement block and mess up the entire file). - return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.SlashToken || token === SyntaxKind.CloseBraceToken; + // REMOVE -> // For error recovery, include } here (otherwise an over-braced {expr}} will close the surrounding statement block and mess up the entire file). + return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.SlashToken; case ParsingContext.JsxChildren: - return token === SyntaxKind.LessThanSlashToken; + return token === SyntaxKind.LessThanToken && lookAhead(nextTokenIsSlash); case ParsingContext.JSDocFunctionParameters: return token === SyntaxKind.CloseParenToken || token === SyntaxKind.ColonToken || token === SyntaxKind.CloseBraceToken; case ParsingContext.JSDocTypeArguments: @@ -3113,7 +3113,13 @@ namespace ts { case SyntaxKind.VoidKeyword: return parseVoidExpression(); case SyntaxKind.LessThanToken: - return sourceFile.isTSXFile ? parseJsxElementOrSelfClosingElement() : parseTypeAssertion(); + if (!sourceFile.isTSXFile) { + return parseTypeAssertion(); + } + if(lookAhead(nextTokenIsIdentifier)) { + return parseJsxElementOrSelfClosingElement(); + } + // Fall through default: return parsePostfixExpressionOrHigher(); } @@ -3241,36 +3247,14 @@ namespace ts { return finishNode(node); } - function parseJsxChild(): JsxChild { - let result: JsxChild = undefined; - switch (token) { - case SyntaxKind.JsxText: - result = createNode(SyntaxKind.JsxText); - token = scanner.scanJsxToken(); - result = finishNode(result); - break; - case SyntaxKind.OpenBraceToken: - result = parseJsxExpression(); - break; - default: - Debug.assert(token === SyntaxKind.LessThanToken); - result = parseJsxElementOrSelfClosingElement(); - break; - } - token = scanner.reScanJsxToken(); - Debug.assert(result !== undefined, "parsed some JSX child"); - return result; - } - function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement { let opening = parseJsxOpeningOrSelfClosingElement(); if (opening.kind === SyntaxKind.JsxOpeningElement) { let node = createNode(SyntaxKind.JsxElement, opening.pos); node.openingElement = opening; - // Rescan since parsing the > messed up the scanner state - token = scanner.reScanJsxToken(); - node.children = parseList(ParsingContext.JsxChildren, parseJsxChild); + debugger; + node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(); return finishNode(node); } @@ -3280,6 +3264,49 @@ namespace ts { return opening; } } + + function parseJsxText(): JsxText { + let node = createNode(SyntaxKind.JsxText, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + + function parseJsxChild(): JsxChild { + switch (token) { + case SyntaxKind.JsxText: + return parseJsxText(); + case SyntaxKind.OpenBraceToken: + return parseJsxExpression(); + case SyntaxKind.LessThanToken: + return parseJsxElementOrSelfClosingElement(); + } + Debug.fail('Unknown JSX child kind ' + token); + } + + function parseJsxChildren(openingTagName: EntityName): NodeArray { + let result = >[]; + result.pos = scanner.getStartPos(); + let saveParsingContext = parsingContext; + parsingContext |= 1 << ParsingContext.JsxChildren; + + while(true) { + token = scanner.reScanJsxToken(); + if (token === SyntaxKind.LessThanSlashToken) { + break; + } + else if (token === SyntaxKind.EndOfFileToken) { + parseErrorAtCurrentToken(Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + + result.end = scanner.getTokenPos(); + + parsingContext = saveParsingContext; + + return result; + } function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement { let fullStart = scanner.getStartPos(); @@ -3287,17 +3314,18 @@ namespace ts { parseExpected(SyntaxKind.LessThanToken); let tagName = parseJsxElementName(); + let attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); let node: JsxOpeningLikeElement; - if (token === SyntaxKind.SlashToken) { - node = createNode(SyntaxKind.JsxSelfClosingElement, fullStart); - nextToken(); + if (parseOptional(SyntaxKind.GreaterThanToken)) { + node = createNode(SyntaxKind.JsxOpeningElement, fullStart); } else { - node = createNode(SyntaxKind.JsxOpeningElement, fullStart); - } - parseExpected(SyntaxKind.GreaterThanToken); + parseExpected(SyntaxKind.SlashToken); + parseExpected(SyntaxKind.GreaterThanToken); + node = createNode(SyntaxKind.JsxSelfClosingElement, fullStart); + } node.tagName = tagName; node.attributes = attributes; @@ -4818,6 +4846,10 @@ namespace ts { return nextToken() === SyntaxKind.OpenParenToken; } + function nextTokenIsSlash() { + return nextToken() === SyntaxKind.SlashToken; + } + function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === SyntaxKind.CommaToken || diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt index 8e7132007d858..ead030952a517 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -60,15 +60,14 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expect !!! error TS1005: '}' expected. x = {}}>hello; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '}' expected. - x = {}}>hello{{}}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. @@ -78,9 +77,7 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expect !!! error TS1005: '}' expected. - x = x, x = ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. @@ -88,10 +85,8 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expect !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {{/foo/.test(x) ? : }} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~~ @@ -108,14 +103,10 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expect !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ~~~~ ~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. !!! error TS1005: ':' expected. diff --git a/tests/baselines/reference/jsxAndTypeAssertion.js b/tests/baselines/reference/jsxAndTypeAssertion.js index 26af23a2051bf..0b402b43de2e4 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.js +++ b/tests/baselines/reference/jsxAndTypeAssertion.js @@ -35,7 +35,9 @@ x = ; x = hello {} }; -x = }>hello} x=}>hello{}}; +x = }>hello}/>; + +x = }>hello{}}; x = x, x = ; @@ -44,4 +46,4 @@ x = x, x = ; } -}}>>; +}}/>; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index 7f3d60f836102..9cef517fa1be4 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -1,49 +1,66 @@ -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,2): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1005: ';' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,6): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,3): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,7): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS1005: '{' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS2304: Cannot find name 'd'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,9): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,10): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,4): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,4): error TS17002: Expected corresponding JSX closing tag for 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,13): error TS1002: Unterminated string literal. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS17002: Expected corresponding JSX closing tag for 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,3): error TS1005: ';' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,8): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1005: ';' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,4): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,4): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,8): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,10): error TS1161: Unterminated regular expression literal. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1005: ';' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2304: Cannot find name 'c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,8): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,10): error TS1161: Unterminated regular expression literal. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,10): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,5): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1161: Unterminated regular expression literal. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,12): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,14): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,5): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,7): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,11): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,4): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(19,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(20,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. @@ -76,29 +93,33 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1003: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(34,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: '; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS2304: Cannot find name 'a'. ~ -!!! error TS1003: Identifier expected. +!!! error TS1005: ';' expected. + +!!! error TS1161: Unterminated regular expression literal. <:a />; - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ -!!! error TS1003: Identifier expected. +!!! error TS1109: Expression expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. ; ~~~~~~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. @@ -113,8 +134,10 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ; ~ !!! error TS1003: Identifier expected. - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. ; ~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. @@ -128,70 +151,111 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ; ~ !!! error TS1003: Identifier expected. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS2304: Cannot find name 'a'. ~ -!!! error TS1003: Identifier expected. - ~~~~ -!!! error TS17002: Expected corresponding JSX closing tag for 'a'. +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'b'. + ~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS2304: Cannot find name 'a'. ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '>' expected. +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'b'. + ~~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS2304: Cannot find name 'a'. ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '>' expected. +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'c'. + ~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~~~~~~~~~~~ + ~~~~~~~~~~~ + ~~~~~~~~~~~ + ~~~~~~~~~~~ + ~~~~~~~~~~~ + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~~~~~~~~~~~~ + ~~~~~~~~~~~~ + ~~~~~~~~~~~~ + ~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'a'. - ~~~~ -!!! error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. <.a>; - ~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~~~~~~~~~~ + ~~~~~~~~~~ + ~~~~~~~~~~ ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1003: Identifier expected. +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~~~~~~~~~~ + ~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '>' expected. + ~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'a'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '>' expected. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. + +!!! error TS1161: Unterminated regular expression literal. ; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS2304: Cannot find name 'a'. ~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ; @@ -213,7 +277,7 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ~ !!! error TS1005: '}' expected. ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1003: Identifier expected. @@ -259,25 +323,19 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ~ !!! error TS1005: '{' expected. ; - ~~~~~~~~~ + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1003: Identifier expected. }; - ~~~~~~~~~ ~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~~~~~~~~~~~~~~~ + ~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~ !!! error TS1003: Identifier expected. -!!! error TS1005: 'one
/* intervening comment */
two
;;
; //// [jsxInvalidEsprimaTestSuite.jsx] -< />; -; -< a=/>; - }> -; -; - + < a; +b > < /b>; + < a; +b.c > < /a:b.c>; + < a.b; +c > < /a.b:c>; + < a.b.c > < /a>; + < .a > < /.a>; + < a. > < /a.>; + < a[foo] > < /a[foo]>; + < a['foo'] > < /a['foo']>; + < a > ; ; var x =
one
two
;; var x =
one
/* intervening comment */ /* intervening comment */
two
;;
{"str"};}; -; -
"app">; +, id="b" />; +
"app">;
;
stuff
{}...props}>; @@ -66,6 +71,6 @@ var x =
one
/* intervening comment */ /* intervening comment */
>; >; ; -}>; +/>}>; }; -;>; + .../*hai*/asdf/>;; diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt index 055062237d837..90d0d003c28d6 100644 --- a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt +++ b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt @@ -1,14 +1,23 @@ -tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(9,8): error TS1003: Identifier expected. tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,8): error TS1003: Identifier expected. -tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,22): error TS1005: '; ~~ !!! error TS1003: Identifier expected. - ; + ~~~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'data'. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~ !!! error TS1003: Identifier expected. - -!!! error TS1005: '; -; +; //// [tsxAttributeInvalidNames.jsx] // Invalid names - 32data={32} />; - -data={32} />;; +; +32; +data = { 32: } / > ; + - data; +{ + 32; +} +/>;; diff --git a/tests/baselines/reference/tsxElementResolution10.errors.txt b/tests/baselines/reference/tsxElementResolution10.errors.txt index 987851191c53d..6dcee7d18fa8d 100644 --- a/tests/baselines/reference/tsxElementResolution10.errors.txt +++ b/tests/baselines/reference/tsxElementResolution10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/tsxElementResolution10.tsx(13,1): error TS2605: JSX element '{ x: number; }' is not a constructor function for JSX elements. +tests/cases/conformance/jsx/tsxElementResolution10.tsx(13,1): error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements. Property 'render' is missing in type '{ x: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/jsx/tsxElementResolution10.tsx(13,1): error TS2605: JSX var Obj1: Obj1type; ; // Error, no render member ~~~~~~~~~~~~~~~ -!!! error TS2605: JSX element '{ x: number; }' is not a constructor function for JSX elements. +!!! error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements. !!! error TS2605: Property 'render' is missing in type '{ x: number; }'. interface Obj2type { diff --git a/tests/baselines/reference/tsxElementResolution18.errors.txt b/tests/baselines/reference/tsxElementResolution18.errors.txt index 75d28616bf0d7..a4728b2f749e5 100644 --- a/tests/baselines/reference/tsxElementResolution18.errors.txt +++ b/tests/baselines/reference/tsxElementResolution18.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/tsxElementResolution18.tsx(6,1): error TS2609: JSX element implicitly has type 'any' because no interface JSX.IntrinsicElements exists +tests/cases/conformance/jsx/tsxElementResolution18.tsx(6,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists ==== tests/cases/conformance/jsx/tsxElementResolution18.tsx (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/conformance/jsx/tsxElementResolution18.tsx(6,1): error TS2609: JSX e // Error under implicit any
; ~~~~~~~~~~~~~ -!!! error TS2609: JSX element implicitly has type 'any' because no interface JSX.IntrinsicElements exists +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution8.errors.txt b/tests/baselines/reference/tsxElementResolution8.errors.txt index 644b43b471b50..5710c4e177d35 100644 --- a/tests/baselines/reference/tsxElementResolution8.errors.txt +++ b/tests/baselines/reference/tsxElementResolution8.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element 'Div' is not a constructor function. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element type 'Div' does not have any construct or call signatures. tests/cases/conformance/jsx/tsxElementResolution8.tsx(16,2): error TS2601: The return type of a JSX element constructor must return an object type. tests/cases/conformance/jsx/tsxElementResolution8.tsx(29,2): error TS2601: The return type of a JSX element constructor must return an object type. -tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element 'Obj3' is not a constructor function. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. ==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (4 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX e var Div = 3;
; ~~~ -!!! error TS2604: JSX element 'Div' is not a constructor function. +!!! error TS2604: JSX element type 'Div' does not have any construct or call signatures. // OK function Fact(): any { return null; } @@ -46,5 +46,5 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX e var Obj3: Obj3; ; // Error ~~~~ -!!! error TS2604: JSX element 'Obj3' is not a constructor function. +!!! error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. \ No newline at end of file diff --git a/tests/baselines/reference/tsxOpeningClosingNames.js b/tests/baselines/reference/tsxOpeningClosingNames.js new file mode 100644 index 0000000000000..80adad0f406dc --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.js @@ -0,0 +1,14 @@ +//// [tsxOpeningClosingNames.tsx] +declare module JSX { + interface Element { } +} + +declare module A.B.C { + var D: any; +} + +foo + + +//// [tsxOpeningClosingNames.jsx] +foo; diff --git a/tests/baselines/reference/tsxOpeningClosingNames.symbols b/tests/baselines/reference/tsxOpeningClosingNames.symbols new file mode 100644 index 0000000000000..3ff2a3ff68d1b --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxOpeningClosingNames.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxOpeningClosingNames.tsx, 0, 20)) +} + +declare module A.B.C { +>A : Symbol(A, Decl(tsxOpeningClosingNames.tsx, 2, 1)) +>B : Symbol(B, Decl(tsxOpeningClosingNames.tsx, 4, 17)) +>C : Symbol(C, Decl(tsxOpeningClosingNames.tsx, 4, 19)) + + var D: any; +>D : Symbol(D, Decl(tsxOpeningClosingNames.tsx, 5, 5)) +} + +foo +>D : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxOpeningClosingNames.types b/tests/baselines/reference/tsxOpeningClosingNames.types new file mode 100644 index 0000000000000..b02564ae104a7 --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +declare module A.B.C { +>A : typeof A +>B : typeof B +>C : typeof C + + var D: any; +>D : any +} + +foo +>foo : JSX.Element +>A : any +>B : any +>C : any +>D : any +>A : any +>B : any +>C : any +>D : any + diff --git a/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx index a3a8d2935355b..4471c5a9c9278 100644 --- a/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx +++ b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx @@ -4,9 +4,10 @@ declare module JSX { interface Element { } interface IntrinsicElements { test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; } } // Invalid names ; -; \ No newline at end of file +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx b/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx new file mode 100644 index 0000000000000..8f21517474fb8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } +} + +declare module A.B.C { + var D: any; +} + +foo From e448d8b9320b61fa9e9a5b846d8139ac9bbf6082 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 22 Jun 2015 11:53:38 -0700 Subject: [PATCH 125/250] Treat (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring); if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, (!sourceFile.isTSXFile || jsxDesugaring) ? ".js" : ".jsx"); + let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -70,7 +71,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, (host.getSourceFiles().every(f => !f.isTSXFile) || jsxDesugaring) ? ".js" : ".jsx"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, host.getSourceFiles().some(shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index adb2ba0e206f1..6da63a4f18ee5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -544,6 +544,7 @@ namespace ts { scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(isTsx(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard); } function clearState() { @@ -656,7 +657,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0; - sourceFile.isTSXFile = fileExtensionIs(sourceFile.fileName, ".tsx"); + sourceFile.languageVariant = fileExtensionIs(sourceFile.fileName, ".tsx") ? LanguageVariant.JSX : LanguageVariant.Standard; return sourceFile; } @@ -2839,7 +2840,7 @@ namespace ts { } // JSX overrides - if (sourceFile.isTSXFile) { + if (sourceFile.languageVariant === LanguageVariant.JSX) { let isArrowFunctionInJsx = lookAhead(() => { let third = nextToken(); let fourth = nextToken(); @@ -3113,7 +3114,7 @@ namespace ts { case SyntaxKind.VoidKeyword: return parseVoidExpression(); case SyntaxKind.LessThanToken: - if (!sourceFile.isTSXFile) { + if (sourceFile.languageVariant !== LanguageVariant.JSX) { return parseTypeAssertion(); } if(lookAhead(nextTokenIsIdentifier)) { @@ -5050,7 +5051,7 @@ namespace ts { } function processReferenceComments(sourceFile: SourceFile): void { - let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText); + let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText); let referencedFiles: FileReference[] = []; let amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 4ce0dadc1cdfb..1cae922f082ba 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -30,6 +30,7 @@ namespace ts { setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; // Invokes the provided callback then unconditionally restores the scanner to the state it // was in immediately prior to invoking the callback. The result of invoking the callback @@ -630,6 +631,7 @@ namespace ts { // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, + languageVariant = LanguageVariant.Standard, text?: string, onError?: ErrorCallback, start?: number, @@ -675,6 +677,7 @@ namespace ts { scan, setText, setScriptTarget, + setLanguageVariant, setOnError, setTextPos, tryScan, @@ -1309,6 +1312,9 @@ namespace ts { if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.LessThanEqualsToken; } + if (text.charCodeAt(pos + 1) === CharacterCodes.slash && languageVariant === LanguageVariant.JSX) { + return pos += 2, token = SyntaxKind.LessThanSlashToken; + } return pos++, token = SyntaxKind.LessThanToken; case CharacterCodes.equals: if (isConflictMarkerTrivia(text, pos)) { @@ -1588,6 +1594,10 @@ namespace ts { languageVersion = scriptTarget; } + function setLanguageVariant(variant: LanguageVariant) { + languageVariant = variant; + } + function setTextPos(textPos: number) { Debug.assert(textPos >= 0); pos = textPos; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d78d38d5ba710..3a34137a2b42a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1223,7 +1223,7 @@ namespace ts { amdDependencies: {path: string; name: string}[]; moduleName: string; referencedFiles: FileReference[]; - isTSXFile: boolean; + languageVariant: LanguageVariant; /** * lib.d.ts should have a reference comment like @@ -1988,6 +1988,11 @@ namespace ts { Latest = ES6, } + export const enum LanguageVariant { + Standard, + JSX + } + export interface ParsedCommandLine { options: CompilerOptions; fileNames: string[]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7ec599babbced..29f91e8c502fa 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -274,7 +274,7 @@ namespace ts { } export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan { - let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.text, /*onError:*/ undefined, pos); + let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); let start = scanner.getTokenPos(); return createTextSpanFromBounds(start, scanner.getTextPos()); @@ -1957,6 +1957,10 @@ namespace ts { return fileExtensionIs(fileName, ".js"); } + export function isTsx(fileName: string) { + return fileExtensionIs(fileName, ".tsx"); + } + /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. diff --git a/src/services/services.ts b/src/services/services.ts index 7e1aba31d540e..cc35eca49dd72 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -737,7 +737,6 @@ namespace ts { public amdDependencies: { name: string; path: string }[]; public moduleName: string; public referencedFiles: FileReference[]; - public isTSXFile: boolean; public syntacticDiagnostics: Diagnostic[]; public referenceDiagnostics: Diagnostic[]; @@ -752,6 +751,7 @@ namespace ts { public symbolCount: number; public version: string; public languageVersion: ScriptTarget; + public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: Map; @@ -2916,7 +2916,7 @@ namespace ts { else if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { node = (contextToken.parent).left; isRightOfDot = true; - } else if (contextToken && contextToken.kind === SyntaxKind.LessThanToken && sourceFile.isTSXFile) { + } else if (contextToken && contextToken.kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { isRightOfOpenTag = true; location = contextToken; } @@ -6167,8 +6167,8 @@ namespace ts { let spanLength = span.length; // Make a scanner we can get trivia from. - let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); - let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); + let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); let result: number[] = []; processElement(sourceFile); diff --git a/tests/baselines/reference/tsxErrorRecovery1.errors.txt b/tests/baselines/reference/tsxErrorRecovery1.errors.txt new file mode 100644 index 0000000000000..dc4f4d51afede --- /dev/null +++ b/tests/baselines/reference/tsxErrorRecovery1.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(5,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/jsx/tsxErrorRecovery1.tsx (1 errors) ==== + + declare namespace JSX { interface Element { } } + + function foo() { + var x =
{
+ ~~ +!!! error TS1109: Expression expected. + } + // Shouldn't see any errors down here + var y = { a: 1 }; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxErrorRecovery1.js b/tests/baselines/reference/tsxErrorRecovery1.js new file mode 100644 index 0000000000000..8d20951f6edd5 --- /dev/null +++ b/tests/baselines/reference/tsxErrorRecovery1.js @@ -0,0 +1,17 @@ +//// [tsxErrorRecovery1.tsx] + +declare namespace JSX { interface Element { } } + +function foo() { + var x =
{
+} +// Shouldn't see any errors down here +var y = { a: 1 }; + + +//// [tsxErrorRecovery1.jsx] +function foo() { + var x =
{}
; +} +// Shouldn't see any errors down here +var y = { a: 1 }; diff --git a/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx b/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx new file mode 100644 index 0000000000000..881b3c95376d9 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve + +declare namespace JSX { interface Element { } } + +function foo() { + var x =
{
+} +// Shouldn't see any errors down here +var y = { a: 1 }; From c9a925eb758ab023197c9e269e3d60fa1f808753 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 22 Jun 2015 11:53:55 -0700 Subject: [PATCH 126/250] Unrelated baseline noise --- .../jsxInvalidEsprimaTestSuite.errors.txt | 217 +++++++++--------- .../reference/jsxInvalidEsprimaTestSuite.js | 35 +-- .../reference/tsxAttributeResolution.js | 2 - .../reference/tsxAttributeResolution.symbols | 9 +- .../reference/tsxAttributeResolution.types | 1 - .../jsx/tsxAttributeResolution.tsx | 2 +- 6 files changed, 132 insertions(+), 134 deletions(-) diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index 9cef517fa1be4..f509044703a32 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -1,8 +1,9 @@ -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1161: Unterminated regular expression literal. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1005: ';' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,6): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,4): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,3): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,6): error TS1109: Expression expected. @@ -23,44 +24,47 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,3): error TS1005: ';' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2304: Cannot find name 'b'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,8): error TS1161: Unterminated regular expression literal. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1005: ';' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,4): error TS2304: Cannot find name 'b'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,4): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,8): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,10): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,8): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,12): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1005: ';' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2304: Cannot find name 'c'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,6): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,8): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,10): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,14): error TS2304: Cannot find name 'c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,10): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,5): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,5): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,7): error TS1161: Unterminated regular expression literal. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,9): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS1161: Unterminated regular expression literal. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,13): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,11): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS1161: Unterminated regular expression literal. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,22): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,4): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(19,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(20,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. @@ -96,22 +100,24 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002: Expected corresponding JSX closing tag for 'a'. -==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (96 errors) ==== +==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (100 errors) ==== declare var React: any; ; - ~ + ~~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; - ~ -!!! error TS2304: Cannot find name 'a'. + ~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ -!!! error TS1005: ';' expected. - -!!! error TS1161: Unterminated regular expression literal. +!!! error TS1003: Identifier expected. <:a />; + ~ +!!! error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. ~ @@ -157,105 +163,96 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 !!! error TS1005: ';' expected. ~ !!! error TS2304: Cannot find name 'b'. - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~ + ~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS2304: Cannot find name 'b'. + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; - ~ -!!! error TS2304: Cannot find name 'a'. + ~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ -!!! error TS1005: ';' expected. - ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '>' expected. + ~ !!! error TS2304: Cannot find name 'b'. - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~ + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; + ~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS2304: Cannot find name 'a'. ~ -!!! error TS1005: ';' expected. - ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '>' expected. + ~ !!! error TS2304: Cannot find name 'c'. - ~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~~~~~~~~~~~ - ~~~~~~~~~~~ - ~~~~~~~~~~~ - ~~~~~~~~~~~ - ~~~~~~~~~~~ - ~ + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS2304: Cannot find name 'a'. - ~ -!!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. + ~~~~ +!!! error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. <.a>; - ~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~~~~~~~~~~ - ~~~~~~~~~~ - ~~~~~~~~~~ + ~ +!!! error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. - ~ + ~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~~~~~~~~~~ - ~~~~~~~~~~ + ~~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. + ~ +!!! error TS1003: Identifier expected. ; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS2304: Cannot find name 'a'. + ~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. ~~~ !!! error TS2304: Cannot find name 'foo'. - ~ + ~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'RegExp'. - ~ + ~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. + ~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1109: Expression expected. + ~ !!! error TS2304: Cannot find name 'a'. - ~ + ~ !!! error TS1109: Expression expected. - -!!! error TS1161: Unterminated regular expression literal. ; - ~ -!!! error TS2304: Cannot find name 'a'. + ~~~ +!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~~ !!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index 537a2ff002b46..a53cf33410dbf 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -36,9 +36,8 @@ var x =
one
/* intervening comment */
two
;;
; //// [jsxInvalidEsprimaTestSuite.jsx] - < />; - < a; -/>; + > ; +; < ; a / > ; }/> @@ -46,17 +45,23 @@ a / > ; ; Date: Mon, 22 Jun 2015 12:56:10 -0700 Subject: [PATCH 128/250] moved comment --- src/compiler/checker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3e0a04b123e29..c01674d351392 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4584,7 +4584,9 @@ namespace ts { for (let targetProp of properties) { let sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { // sourceProp !== targetProp -- ie: source and target have distinct declarations with the same name + if (sourceProp !== targetProp) { + // sourceProp !== targetProp -- ie: source and target have distinct declarations with the same name + if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { if (reportErrors) { From 92ef6f5409e468597c118ca5e1c8b32d50f5636b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 22 Jun 2015 13:29:19 -0700 Subject: [PATCH 129/250] responded to some of Daniel's comments --- src/compiler/checker.ts | 33 ++++++++++++++-------------- src/compiler/diagnosticMessages.json | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c01674d351392..3492829657027 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6671,15 +6671,15 @@ namespace ts { /** * Check whether the requested property access is valid. - * Returns true if node passed the check, and false otherwise. + * Returns true if node is a valid property access, and false otherwise. * @param node The node to be checked. - * @param left The left hand side of the property access (eg: the super is `super.*`). + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). * @param type The type of left. * @param prop The symbol for the right hand side of the property access. */ - function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) : boolean { + function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { let flags = getDeclarationFlagsFromSymbol(prop); - let declaringClass : InterfaceType; + let declaringClass: InterfaceType; if (left.kind === SyntaxKind.SuperKeyword) { let errorNode = (node).name ? @@ -6693,8 +6693,7 @@ namespace ts { // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { // prop is a property access - + if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { // prop is a property access. error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -6715,11 +6714,8 @@ namespace ts { return true; } - // Property is known to be private or protected at this point. - // Get the declaring and enclosing class instance types. let enclosingClassDeclaration = getAncestor(node, SyntaxKind.ClassDeclaration); - // Debug.assert(!!enclosingClassDeclaration, "Should be defined"); let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; declaringClass = getDeclaredTypeOfSymbol(prop.parent); @@ -7558,7 +7554,7 @@ namespace ts { } // If the expression is of abstract type, then it cannot be instantiated. - var valueDecl = (expressionType.symbol ? expressionType.symbol.valueDeclaration : undefined); + let valueDecl = expressionType.symbol && expressionType.symbol.valueDeclaration; if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); } @@ -7650,8 +7646,8 @@ namespace ts { } /** - * Performs typechecking on the given node, which is a call/new expression. - * @param node The call expression to be checked. + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. * @returns On success, the expression's signature's return type. On failure, anyType. */ function checkCallExpression(node: CallExpression): Type { @@ -8341,7 +8337,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Otherwise fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -9265,7 +9261,8 @@ namespace ts { // the node in question is abstract. if (node.flags & NodeFlags.Abstract) { error(errorNode, Diagnostics.All_declarations_of_an_abstract_member_function_must_be_consecutive); - } else { + } + else { error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); } } @@ -10775,7 +10772,9 @@ namespace ts { Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived === base) { // derived class inherits base without override/redeclaration + if (derived === base) { + // derived class inherits base without override/redeclaration + let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); Debug.assert(derivedClassDecl !== undefined); @@ -10784,7 +10783,9 @@ namespace ts { error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2, typeToString(type), typeToString(baseType), symbolToString(baseProperty)); } - } else { // derived overrides base + } + else { + // derived overrides base. let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { // either base or derived property is private - not override, skip it diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b14d885dd9ac7..8df76ec896178 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1575,7 +1575,7 @@ "category": "Error", "code": 2514 }, - "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." : { + "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'.": { "category": "Error", "code": 2515 }, From 16c834420c7a95323dd33326f279866b8c72999b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 22 Jun 2015 13:55:09 -0700 Subject: [PATCH 130/250] More cleanup --- src/compiler/checker.ts | 27 ++++++++++---------- src/compiler/emitter.ts | 55 ++++++++++++++++++++++++++-------------- src/compiler/parser.ts | 5 ++-- src/harness/harness.ts | 9 ++++--- src/services/services.ts | 30 ++++++++++++---------- 5 files changed, 76 insertions(+), 50 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bb3096bf70a96..99544f466aa88 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6698,19 +6698,21 @@ namespace ts { } function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean { - if(lhs.kind !== rhs.kind) { + if (lhs.kind !== rhs.kind) { return false; } - if(lhs.kind === SyntaxKind.Identifier) { + + if (lhs.kind === SyntaxKind.Identifier) { return (lhs).text === (rhs).text; } + return (lhs).right.text === (rhs).right.text && tagNamesAreEquivalent((lhs).left, (rhs).left); } function checkJsxElement(node: JsxElement) { // Check that the closing tag matches - if(!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNode(node.openingElement.tagName)); } @@ -6718,21 +6720,20 @@ namespace ts { checkJsxOpeningLikeElement(node.openingElement); // Check children - let children = node.children; - for (var i = 0, n = children.length; i < n; i++) { - switch (children[i].kind) { + for(let child of node.children) { + switch (child.kind) { case SyntaxKind.JsxExpression: - checkJsxExpression(children[i]); + checkJsxExpression(child); break; case SyntaxKind.JsxElement: - checkJsxElement(children[i]); + checkJsxElement(child); break; case SyntaxKind.JsxSelfClosingElement: - checkJsxSelfClosingElement(children[i]); + checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - Debug.assert(children[i].kind === SyntaxKind.JsxText); + Debug.assert(child.kind === SyntaxKind.JsxText); } } @@ -6742,7 +6743,7 @@ namespace ts { /** * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers */ - function isIdentifierLike(name: string) { + function isUnhyphenatedJsxName(name: string) { // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers return name.indexOf('-') < 0; } @@ -6764,7 +6765,7 @@ namespace ts { let correspondingPropType: Type = undefined; // Look up the corresponding property for this attribute - if (elementAttributesType === emptyObjectType && isIdentifierLike(node.name.text)) { + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { // If there is no 'props' property, you may not have non-"data-" attributes error(node.parent, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } @@ -6772,7 +6773,7 @@ namespace ts { let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); // If there's no corresponding property with this name, error - if (!correspondingPropType && isIdentifierLike(node.name.text)) { + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); return unknownType; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 68bede620d4d1..8ae8e7c36ce54 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1157,7 +1157,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } - function emitJsxElement(openingNode: JsxOpeningElement|JsxSelfClosingElement, children?: JsxChild[]) { + function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { // Call React.createElement(tag, ... emitLeadingComments(openingNode); write('React.createElement('); @@ -1177,10 +1177,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write('React.__spread('); let haveOpenedObjectLiteral = false; - for (var i = 0; i < attrs.length; i++) { + for (let i = 0; i < attrs.length; i++) { if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { // If this is the first argument, we need to emit a {} as the first argument - if(i === 0) { + if (i === 0) { write('{}, '); } @@ -1188,7 +1188,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write('}'); haveOpenedObjectLiteral = false; } - if (i > 0) write(', '); + if (i > 0) { + write(', '); + } emit((attrs[i]).expression); } else { @@ -1198,7 +1200,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } else { haveOpenedObjectLiteral = true; - if (i > 0) write(', '); + if (i > 0) { + write(', '); + } write('{'); } emitJsxAttribute(attrs[i]); @@ -1212,7 +1216,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // One object literal with all the attributes in them write('{'); for (var i = 0; i < attrs.length; i++) { - if (i > 0) write(', '); + if (i > 0) { + write(', '); + } emitJsxAttribute(attrs[i]); } write('}'); @@ -1223,10 +1229,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === SyntaxKind.JsxExpression && !((children[i]).expression)) continue; + if (children[i].kind === SyntaxKind.JsxExpression && !((children[i]).expression)) { + continue; + } // Don't emit empty strings - if (children[i].kind === SyntaxKind.JsxText && !shouldEmitJsxText(children[i])) continue; + if (children[i].kind === SyntaxKind.JsxText && !shouldEmitJsxText(children[i])) { + continue; + } write(', '); emit(children[i]); @@ -1261,8 +1271,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitAttributes(attribs: NodeArray) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) write(' '); + for (let i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(' '); + } if (attribs[i].kind === SyntaxKind.JsxSpreadAttribute) { emitJsxSpreadAttribute(attribs[i]); @@ -5869,11 +5881,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } - function emitJsxElement(node: JsxElement|JsxSelfClosingElement) { + function emitJsxElement(node: JsxElement | JsxSelfClosingElement) { switch (compilerOptions.jsx) { case JsxEmit.React: jsxEmitReact(node); break; + case JsxEmit.Preserve: // Fall back to preserve if None was specified (we'll error earlier) default: jsxEmitPreserve(node); @@ -5892,8 +5905,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let firstNonWhitespace = 0; let lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (let i = 0; i < text.length; i++) { + let c = text.charCodeAt(i); if (c === CharacterCodes.lineFeed || c === CharacterCodes.carriageReturn) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { lines.push(text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); @@ -5915,11 +5931,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function shouldEmitJsxText(node: JsxText) { - if (compilerOptions.jsx === JsxEmit.React) { - return trimReactWhitespace(node).length > 0; - } - else { - return true; + switch (compilerOptions.jsx) { + case JsxEmit.React: + return trimReactWhitespace(node).length > 0; + case JsxEmit.Preserve: + default: + return true; } } @@ -5939,7 +5956,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitJsxExpression(node: JsxExpression) { - if (node.expression && node.expression.kind !== SyntaxKind.OmittedExpression) { + if (node.expression) { switch (compilerOptions.jsx) { case JsxEmit.Preserve: default: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6da63a4f18ee5..1317e180f76bd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2858,11 +2858,12 @@ namespace ts { } return false; }); + if (isArrowFunctionInJsx) { return Tristate.Unknown; - } else { - return Tristate.False; } + + return Tristate.False; } // This *could* be a parenthesized arrow function. diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 0ea7db33fe106..bd54d24cf732b 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1468,12 +1468,15 @@ module Harness { if (isDTS(emittedFile.fileName)) { // .d.ts file, add to declFiles emit this.declFilesCode.push(emittedFile); - } else if (isJS(emittedFile.fileName) || isJSX(emittedFile.fileName)) { + } + else if (isJS(emittedFile.fileName) || isJSX(emittedFile.fileName)) { // .js file, add to files this.files.push(emittedFile); - } else if (isJSMap(emittedFile.fileName)) { + } + else if (isJSMap(emittedFile.fileName)) { this.sourceMaps.push(emittedFile); - } else { + } + else { throw new Error('Unrecognized file extension for file ' + emittedFile.fileName); } }); diff --git a/src/services/services.ts b/src/services/services.ts index cc35eca49dd72..7b9de36e33c8d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2909,16 +2909,20 @@ namespace ts { let isRightOfDot = false; let isRightOfOpenTag = false; - if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (contextToken.parent).expression; - isRightOfDot = true; - } - else if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { - node = (contextToken.parent).left; - isRightOfDot = true; - } else if (contextToken && contextToken.kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { - isRightOfOpenTag = true; - location = contextToken; + if(contextToken) { + let kind = contextToken.kind; + if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; + isRightOfDot = true; + } + else if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; + isRightOfDot = true; + } + else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { + isRightOfOpenTag = true; + location = contextToken; + } } let semanticStart = new Date().getTime(); @@ -2930,11 +2934,11 @@ namespace ts { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { - // TODO include all in-scope value identifiers let tagSymbols = typeChecker.getJsxIntrinsicTagNames();; if (tryGetGlobalSymbols()) { symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & SymbolFlags.Value))); - } else { + } + else { symbols = tagSymbols; } isMemberCompletion = true; @@ -3006,7 +3010,7 @@ namespace ts { function tryGetGlobalSymbols(): boolean { let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); - let jsxElement: JsxElement, jsxSelfClosingElement: JsxSelfClosingElement; + if (containingObjectLiteral) { // Object literal expression, look up possible property names from contextual type isMemberCompletion = true; From 5bc10b9828e65c0dcf1e89c1fabce0bee5a28220 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 22 Jun 2015 15:22:47 -0700 Subject: [PATCH 131/250] It's no longer safe to store JSX elem. attr. type in nodelinks.resolvedType --- src/compiler/checker.ts | 25 ++++---- src/compiler/parser.ts | 1 - src/compiler/types.ts | 1 + .../baselines/reference/tsxInArrowFunction.js | 34 ++++++++++ .../reference/tsxInArrowFunction.symbols | 46 +++++++++++++ .../reference/tsxInArrowFunction.types | 64 +++++++++++++++++++ 6 files changed, 158 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/tsxInArrowFunction.js create mode 100644 tests/baselines/reference/tsxInArrowFunction.symbols create mode 100644 tests/baselines/reference/tsxInArrowFunction.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 99544f466aa88..0378835aa0a41 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6980,57 +6980,57 @@ namespace ts { */ function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { let links = getNodeLinks(node); - if (!links.resolvedType) { + if (!links.resolvedJsxType) { let sym = getJsxElementTagSymbol(node); if (links.jsxFlags & JsxFlags.ClassElement) { let elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedType = anyType; + return links.resolvedJsxType = anyType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { // There is no type ElementAttributesProperty, return 'any' - return links.resolvedType = anyType; + return links.resolvedJsxType = anyType; } else if (propsName === '') { // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead - return links.resolvedType = elemInstanceType; + return links.resolvedJsxType = elemInstanceType; } else { var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); if (!attributesType) { // There is no property named 'props' on this instance type - return links.resolvedType = emptyObjectType; + return links.resolvedJsxType = emptyObjectType; } else if (isTypeAny(attributesType) || (attributesType === unknownType)) { - return links.resolvedType = attributesType; + return links.resolvedJsxType = attributesType; } else if (!(attributesType.flags & TypeFlags.ObjectType)) { error(node.tagName, Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); - return links.resolvedType = anyType; + return links.resolvedJsxType = anyType; } else { - return links.resolvedType = attributesType; + return links.resolvedJsxType = attributesType; } } } else if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) { - return links.resolvedType = getTypeOfSymbol(sym); + return links.resolvedJsxType = getTypeOfSymbol(sym); } else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) { - return links.resolvedType = getIndexTypeOfSymbol(sym, IndexKind.String); + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, IndexKind.String); } else { // Resolution failed - return links.resolvedType = anyType; + return links.resolvedJsxType = anyType; } } - return links.resolvedType; + return links.resolvedJsxType; } /** @@ -7100,6 +7100,7 @@ namespace ts { if (!(targetProperties[i].flags & SymbolFlags.Optional) && nameTable[targetProperties[i].name] === undefined) { + console.log('oops?'); error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1317e180f76bd..ca3e868d3311c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3255,7 +3255,6 @@ namespace ts { let node = createNode(SyntaxKind.JsxElement, opening.pos); node.openingElement = opening; - debugger; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(); return finishNode(node); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3a34137a2b42a..7f45138bf7ddc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1687,6 +1687,7 @@ namespace ts { hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with + resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element } export const enum TypeFlags { diff --git a/tests/baselines/reference/tsxInArrowFunction.js b/tests/baselines/reference/tsxInArrowFunction.js new file mode 100644 index 0000000000000..ba4a0dd1d1470 --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.js @@ -0,0 +1,34 @@ +//// [tsxInArrowFunction.tsx] + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + } + } +} + + +// didn't work +
{() =>
}
; + +// didn't work +
{x =>
}
; + +// worked +
{() => (
)}
; + +// worked (!) +
{() =>
}
; + + +//// [tsxInArrowFunction.jsx] +// didn't work +
{function () { return
; }}
; +// didn't work +
{function (x) { return
; }}
; +// worked +
{function () { return (
); }}
; +// worked (!) +
{function () { return
; }}
; diff --git a/tests/baselines/reference/tsxInArrowFunction.symbols b/tests/baselines/reference/tsxInArrowFunction.symbols new file mode 100644 index 0000000000000..814f2577bf095 --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/jsx/tsxInArrowFunction.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxInArrowFunction.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxInArrowFunction.tsx, 1, 23)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxInArrowFunction.tsx, 2, 25)) + + div: { +>div : Symbol(div, Decl(tsxInArrowFunction.tsx, 3, 33)) + + text?: string; +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + } + } +} + + +// didn't work +
{() =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// didn't work +
{x =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>x : Symbol(x, Decl(tsxInArrowFunction.tsx, 15, 6)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// worked +
{() => (
)}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// worked (!) +
{() =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + diff --git a/tests/baselines/reference/tsxInArrowFunction.types b/tests/baselines/reference/tsxInArrowFunction.types new file mode 100644 index 0000000000000..e4b2aeb50fe2c --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsx/tsxInArrowFunction.tsx === + +declare namespace JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + div: { +>div : { text?: string; } + + text?: string; +>text : string + } + } +} + + +// didn't work +
{() =>
}
; +>
{() =>
}
: JSX.Element +>div : any +>() =>
: () => JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any + +// didn't work +
{x =>
}
; +>
{x =>
}
: JSX.Element +>div : any +>x =>
: (x: any) => JSX.Element +>x : any +>
: JSX.Element +>div : any +>text : any +>div : any + +// worked +
{() => (
)}
; +>
{() => (
)}
: JSX.Element +>div : any +>() => (
) : () => JSX.Element +>(
) : JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any + +// worked (!) +
{() =>
}
; +>
{() =>
}
: JSX.Element +>div : any +>() =>
: () => JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any +>div : any + From 5c0b913b271cf94d8a62f9bd56adf9c7df09b78c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 22 Jun 2015 15:47:12 -0700 Subject: [PATCH 132/250] changed error messages and fixed comments --- src/compiler/checker.ts | 37 +++++++++++-------- .../diagnosticInformationMap.generated.ts | 10 ++--- src/compiler/diagnosticMessages.json | 10 ++--- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3492829657027..5b1479bbf3133 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6693,18 +6693,21 @@ namespace ts { // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { // prop is a property access. + if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - - // In a super call, the member function can be accessed if the method is not abstract. + + // In a super call, the methods cannot be accessed if the method is abstract. // Note that a member cannot be private and abstract -- this is checked elsewhere. if (flags & NodeFlags.Abstract) { // Get the declaring the class instance type for the error message. declaringClass = getDeclaredTypeOfSymbol(prop.parent); - error(errorNode, Diagnostics.Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_called_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } } @@ -9142,7 +9145,7 @@ namespace ts { error(signatureDeclarationNode, Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); } - function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) { + function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) : NodeFlags { let flags = getCombinedNodeFlags(n); if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) { if (!(flags & NodeFlags.Ambient)) { @@ -9189,7 +9192,7 @@ namespace ts { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & NodeFlags.Abstract) { - error(o.name, Diagnostics.All_overload_signatures_must_match_with_respect_to_modifier_0, "abstract"); + error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract, "abstract"); } }); } @@ -9260,7 +9263,7 @@ namespace ts { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. if (node.flags & NodeFlags.Abstract) { - error(errorNode, Diagnostics.All_declarations_of_an_abstract_member_function_must_be_consecutive); + error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); @@ -9312,9 +9315,10 @@ namespace ts { bodyDeclaration = node; } - // abstract functions cannot have an implementation - if (currentNodeFlags & NodeFlags.Abstract) { - error(node, Diagnostics.Abstract_member_functions_cannot_have_an_implementation) + // abstract functions cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if (currentNodeFlags & NodeFlags.Abstract && node.kind === SyntaxKind.MethodDeclaration && !isConstructor) { + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)) } } else { @@ -9561,7 +9565,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // Otherwise fall through + // Fall through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -10725,11 +10729,12 @@ namespace ts { } forEach(node.members, checkSourceElement); - - // Classes containing abstract members must be marked abstract - if (!(node.flags & NodeFlags.Abstract) && forEach(node.members, (element: ClassElement) => element.flags & NodeFlags.Abstract)) { + + // Classes containing abstract methods must be marked abstract + if (!(node.flags & NodeFlags.Abstract) && forEach(node.members, element => element.flags & NodeFlags.Abstract)) { error(node, Diagnostics.Classes_containing_abstract_functions_must_be_marked_abstract); } + if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -12074,7 +12079,7 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // Otherwise fall through + // Fall through case SyntaxKind.NumericLiteral: // index access @@ -12880,7 +12885,7 @@ namespace ts { } if (node.kind !== SyntaxKind.ClassDeclaration) { if (node.kind !== SyntaxKind.MethodDeclaration) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_class_or_member_function_declaration, "abstract"); + return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) { return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 343b4e2273899..572c83849e576 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -191,10 +191,10 @@ namespace ts { An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - _0_modifier_can_only_appear_on_a_class_or_member_function_declaration: { code: 1236, category: DiagnosticCategory.Error, key: "'{0}' modifier can only appear on a class or member function declaration." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1236, category: DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, _0_modifier_cannot_be_used_with_1_modifier: { code: 1237, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1238, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, - Abstract_member_functions_cannot_have_an_implementation: { code: 1240, category: DiagnosticCategory.Error, key: "Abstract member functions cannot have an implementation." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1240, category: DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, 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." }, @@ -394,11 +394,11 @@ namespace ts { Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - All_overload_signatures_must_match_with_respect_to_modifier_0: { code: 2512, category: DiagnosticCategory.Error, key: "All overload signatures must match with respect to modifier '{0}'." }, - Abstract_member_function_0_on_type_1_cannot_be_called_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract member function '{0}' on type '{1}' cannot be called via super expression." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be `abstract` or not `abstract." }, + Abstract_method_0_1_cannot_be_called_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}.{1}' cannot be called via super expression." }, Classes_containing_abstract_functions_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract functions must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." }, - All_declarations_of_an_abstract_member_function_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract member function must be consecutive." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, 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 8df76ec896178..425aa5e87ac83 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -751,7 +751,7 @@ "category": "Error", "code": 1235 }, - "'{0}' modifier can only appear on a class or member function declaration.": { + "'abstract' modifier can only appear on a class or method declaration.": { "category": "Error", "code": 1236 }, @@ -763,7 +763,7 @@ "category": "Error", "code": 1238 }, - "Abstract member functions cannot have an implementation.": { + "Method '{0}' cannot have an implementation because it is marked abstract.": { "category": "Error", "code": 1240 }, @@ -1563,11 +1563,11 @@ "category": "Error", "code": 2511 }, - "All overload signatures must match with respect to modifier '{0}'.": { + "Overload signatures must all be `abstract` or not `abstract.": { "category": "Error", "code": 2512 }, - "Abstract member function '{0}' on type '{1}' cannot be called via super expression.": { + "Abstract method '{0}.{1}' cannot be called via super expression.": { "category": "Error", "code": 2513 }, @@ -1579,7 +1579,7 @@ "category": "Error", "code": 2515 }, - "All declarations of an abstract member function must be consecutive.": { + "All declarations of an abstract method must be consecutive.": { "category": "Error", "code": 2516 }, From 0daa9eb0d4fd9120ef43ae594abb162ab987ae09 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 22 Jun 2015 15:55:04 -0700 Subject: [PATCH 133/250] updated baselines for new error messages --- .../classAbstractConstructor.errors.txt | 9 +++------ .../classAbstractDeclarations.d.errors.txt | 9 +++------ ...ssAbstractMethodWithImplementation.errors.txt | 4 ++-- .../reference/classAbstractOverloads.errors.txt | 16 ++++++++-------- .../reference/classAbstractProperties.errors.txt | 16 ++++++++-------- .../reference/classAbstractSuperCalls.errors.txt | 4 ++-- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/tests/baselines/reference/classAbstractConstructor.errors.txt b/tests/baselines/reference/classAbstractConstructor.errors.txt index b8d91cefb0fbf..fbea6ef807f27 100644 --- a/tests/baselines/reference/classAbstractConstructor.errors.txt +++ b/tests/baselines/reference/classAbstractConstructor.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1240: Abstract member functions cannot have an implementation. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ==== abstract class A { abstract constructor() {} ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1240: Abstract member functions cannot have an implementation. +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt index 068a1273bb840..501a54e553918 100644 --- a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -1,18 +1,15 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1240: Abstract member functions cannot have an implementation. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (6 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (5 errors) ==== declare abstract class A { abstract constructor() {} ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1240: Abstract member functions cannot have an implementation. +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. ~ !!! error TS1184: An implementation cannot be declared in ambient contexts. } diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt index 5e1196f0e7cc1..2649c83f4e765 100644 --- a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1240: Abstract member functions cannot have an implementation. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1240: Method 'foo' cannot have an implementation because it is marked abstract. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== abstract class A { abstract foo() {} ~~~~~~~~~~~~~~~~~ -!!! error TS1240: Abstract member functions cannot have an implementation. +!!! error TS1240: Method 'foo' cannot have an implementation because it is marked abstract. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverloads.errors.txt b/tests/baselines/reference/classAbstractOverloads.errors.txt index 88dd33c2bedfd..74463ca7fc045 100644 --- a/tests/baselines/reference/classAbstractOverloads.errors.txt +++ b/tests/baselines/reference/classAbstractOverloads.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: All overload signatures must match with respect to modifier 'abstract'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: All overload signatures must match with respect to modifier 'abstract'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: All overload signatures must match with respect to modifier 'abstract'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be `abstract` or not `abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be `abstract` or not `abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be `abstract` or not `abstract. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract member function must be consecutive. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts (5 errors) ==== @@ -14,16 +14,16 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract bar(); bar(); ~~~ -!!! error TS2512: All overload signatures must match with respect to modifier 'abstract'. +!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. abstract bar(); abstract baz(); ~~~ -!!! error TS2512: All overload signatures must match with respect to modifier 'abstract'. +!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. baz(); abstract baz(); ~~~ -!!! error TS2512: All overload signatures must match with respect to modifier 'abstract'. +!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. baz() {} qux(); @@ -35,7 +35,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract foo() : number; abstract foo(); ~~~ -!!! error TS2516: All declarations of an abstract member function must be consecutive. +!!! error TS2516: All declarations of an abstract method must be consecutive. x : number; abstract foo(); abstract foo(); diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt index 0f40d091fd8be..30e7ca1153dc0 100644 --- a/tests/baselines/reference/classAbstractProperties.errors.txt +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1236: 'abstract' modifier can only appear on a class or method declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(10,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. @@ -9,16 +9,16 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract class A { abstract x : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. public abstract y : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. protected abstract z : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. private abstract w : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or member function declaration. +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. abstract foo_x() : number; public abstract foo_y() : number; diff --git a/tests/baselines/reference/classAbstractSuperCalls.errors.txt b/tests/baselines/reference/classAbstractSuperCalls.errors.txt index b63b768cbfeaa..ea81b2b60afc6 100644 --- a/tests/baselines/reference/classAbstractSuperCalls.errors.txt +++ b/tests/baselines/reference/classAbstractSuperCalls.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract member function 'foo' on type 'B' cannot be called via super expression. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract method 'foo.B' cannot be called via super expression. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (1 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst foo() { return 2; } qux() { return super.foo(); } // error, super is abstract ~~~ -!!! error TS2513: Abstract member function 'foo' on type 'B' cannot be called via super expression. +!!! error TS2513: Abstract method 'foo.B' cannot be called via super expression. norf() { return super.bar(); } } From a8d205a2fc6ce63fba37b36fa8482f050c1d500a Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 22 Jun 2015 16:06:17 -0700 Subject: [PATCH 134/250] new tests --- .../classAbstractCrashedOnce.ts | 10 ++++ .../classAbstractImportInstantiation.ts | 9 ++++ ...ass.ts => classAbstractInstantiations1.ts} | 8 --- .../classAbstractInstantiations2.ts | 51 +++++++++++++++++++ .../classAbstractManyKeywords.ts | 4 ++ .../classAbstractMultiLineDecl.ts | 12 +++++ 6 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts rename tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/{classInstantiatingAbstractClass.ts => classAbstractInstantiations1.ts} (60%) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts new file mode 100644 index 0000000000000..747b8dafe6ec3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts @@ -0,0 +1,10 @@ +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts new file mode 100644 index 0000000000000..165a3d7a2e6ce --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts @@ -0,0 +1,9 @@ +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts similarity index 60% rename from tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts index d60a39a3f2cc0..c9ca4afb18d88 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -16,11 +16,3 @@ var c : C; a = new B; b = new B; c = new B; - -module M { - export abstract class A {} -} - -import myA = M.A; - -var aa = new myA; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts new file mode 100644 index 0000000000000..6cca7ed947ff5 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -0,0 +1,51 @@ +class A { + // ... +} + +abstract class B { + foo(): number { return bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof C +} + +var BB = B; +new BB; // error -- BB is of type typeof C + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom() boolean; + nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts new file mode 100644 index 0000000000000..2a6fd46a08d01 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts @@ -0,0 +1,4 @@ +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts new file mode 100644 index 0000000000000..374a3c089ef79 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts @@ -0,0 +1,12 @@ +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; \ No newline at end of file From 676f4a17ee9100bcef215f27079d7a3fd544c043 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 22 Jun 2015 16:18:35 -0700 Subject: [PATCH 135/250] added baselines for new tests --- .../classAbstractCrashedOnce.errors.txt | 16 +++ .../reference/classAbstractCrashedOnce.js | 35 +++++ ...lassAbstractImportInstantiation.errors.txt | 19 +++ .../classAbstractImportInstantiation.js | 25 ++++ .../classAbstractInstantiations1.errors.txt | 28 ++++ ...ass.js => classAbstractInstantiations1.js} | 23 +--- .../classAbstractInstantiations2.errors.txt | 90 +++++++++++++ .../reference/classAbstractInstantiations2.js | 123 ++++++++++++++++++ .../classAbstractManyKeywords.errors.txt | 19 +++ .../reference/classAbstractManyKeywords.js | 28 ++++ .../classAbstractMultiLineDecl.errors.txt | 24 ++++ .../reference/classAbstractMultiLineDecl.js | 33 +++++ ...classInstantiatingAbstractClass.errors.txt | 39 ------ 13 files changed, 442 insertions(+), 60 deletions(-) create mode 100644 tests/baselines/reference/classAbstractCrashedOnce.errors.txt create mode 100644 tests/baselines/reference/classAbstractCrashedOnce.js create mode 100644 tests/baselines/reference/classAbstractImportInstantiation.errors.txt create mode 100644 tests/baselines/reference/classAbstractImportInstantiation.js create mode 100644 tests/baselines/reference/classAbstractInstantiations1.errors.txt rename tests/baselines/reference/{classInstantiatingAbstractClass.js => classAbstractInstantiations1.js} (68%) create mode 100644 tests/baselines/reference/classAbstractInstantiations2.errors.txt create mode 100644 tests/baselines/reference/classAbstractInstantiations2.js create mode 100644 tests/baselines/reference/classAbstractManyKeywords.errors.txt create mode 100644 tests/baselines/reference/classAbstractManyKeywords.js create mode 100644 tests/baselines/reference/classAbstractMultiLineDecl.errors.txt create mode 100644 tests/baselines/reference/classAbstractMultiLineDecl.js delete mode 100644 tests/baselines/reference/classInstantiatingAbstractClass.errors.txt diff --git a/tests/baselines/reference/classAbstractCrashedOnce.errors.txt b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt new file mode 100644 index 0000000000000..c2e38a6cf4472 --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts(8,5): error TS1003: Identifier expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts (1 errors) ==== + abstract class foo { + protected abstract test(); + } + + class bar extends foo { + test() { + this. + } + ~ +!!! error TS1003: Identifier expected. + } + var x = new bar(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js new file mode 100644 index 0000000000000..f4268a4a13c9f --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -0,0 +1,35 @@ +//// [classAbstractCrashedOnce.ts] +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); + +//// [classAbstractCrashedOnce.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var foo = (function () { + function foo() { + } + return foo; +})(); +var bar = (function (_super) { + __extends(bar, _super); + function bar() { + _super.apply(this, arguments); + } + bar.prototype.test = function () { + this. + ; + }; + return bar; +})(foo); +var x = new bar(); diff --git a/tests/baselines/reference/classAbstractImportInstantiation.errors.txt b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt new file mode 100644 index 0000000000000..76110afa4ff4f --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(4,5): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts (2 errors) ==== + module M { + export abstract class A {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + } + + import myA = M.A; + + new myA; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractImportInstantiation.js b/tests/baselines/reference/classAbstractImportInstantiation.js new file mode 100644 index 0000000000000..bb25181f20d8f --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.js @@ -0,0 +1,25 @@ +//// [classAbstractImportInstantiation.ts] +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; + + +//// [classAbstractImportInstantiation.js] +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + new A; +})(M || (M = {})); +var myA = M.A; +new myA; diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt new file mode 100644 index 0000000000000..0221ce07f959a --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (2 errors) ==== + + abstract class A {} + + class B extends A {} + + abstract class C extends B {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + + var a : A; + var b : B; + var c : C; + + a = new B; + b = new B; + c = new B; + \ No newline at end of file diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.js b/tests/baselines/reference/classAbstractInstantiations1.js similarity index 68% rename from tests/baselines/reference/classInstantiatingAbstractClass.js rename to tests/baselines/reference/classAbstractInstantiations1.js index 6a2c3f31e37b6..39e6754292641 100644 --- a/tests/baselines/reference/classInstantiatingAbstractClass.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -1,4 +1,4 @@ -//// [classInstantiatingAbstractClass.ts] +//// [classAbstractInstantiations1.ts] abstract class A {} @@ -17,17 +17,9 @@ var c : C; a = new B; b = new B; c = new B; - -module M { - export abstract class A {} -} - -import myA = M.A; - -var aa = new myA; -//// [classInstantiatingAbstractClass.js] +//// [classAbstractInstantiations1.js] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } @@ -61,14 +53,3 @@ var c; a = new B; b = new B; c = new B; -var M; -(function (M) { - var A = (function () { - function A() { - } - return A; - })(); - M.A = A; -})(M || (M = {})); -var myA = M.A; -var aa = new myA; diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt new file mode 100644 index 0000000000000..c3cb4a4cae424 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -0,0 +1,90 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(6,28): error TS2304: Cannot find name 'bar'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'B.bar'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,14): error TS2516: All declarations of an abstract method must be consecutive. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,20): error TS1144: '{' or ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,20): error TS2300: Duplicate identifier 'boolean'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be `abstract` or not `abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,21): error TS1144: '{' or ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,21): error TS2300: Duplicate identifier 'boolean'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(49,7): error TS2514: Classes containing abstract functions must be marked abstract. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (12 errors) ==== + class A { + // ... + } + + abstract class B { + foo(): number { return bar(); } + ~~~ +!!! error TS2304: Cannot find name 'bar'. + abstract bar() : number; + } + + new B; // error + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var BB: typeof B = B; + var AA: typeof A = BB; // error, AA is not of abstract type. + new AA; + + function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof C + ~~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + } + + var BB = B; + new BB; // error -- BB is of type typeof C + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var x : any = C; + new x; // okay -- undefined behavior at runtime + + class C extends B { } // error -- not declared abstract + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'B.bar'. + + abstract class D extends B { } // okay + + class E extends B { // okay -- implements abstract method + bar() { return 1; } + } + + abstract class F extends B { + abstract foo() : number; + bar() { return 2; } + } + + abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom() boolean; + ~~~ +!!! error TS2516: All declarations of an abstract method must be consecutive. + ~~~~~~~ +!!! error TS1144: '{' or ';' expected. + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'boolean'. + nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. + ~~~ +!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. + ~~~~~~~ +!!! error TS1144: '{' or ';' expected. + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'boolean'. + } + + class H { // error -- not declared abstract + ~ +!!! error TS2514: Classes containing abstract functions must be marked abstract. + abstract baz() : number; + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js new file mode 100644 index 0000000000000..055bdfedbc384 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -0,0 +1,123 @@ +//// [classAbstractInstantiations2.ts] +class A { + // ... +} + +abstract class B { + foo(): number { return bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof C +} + +var BB = B; +new BB; // error -- BB is of type typeof C + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom() boolean; + nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} + +//// [classAbstractInstantiations2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.foo = function () { return bar(); }; + return B; +})(); +new B; // error +var BB = B; +var AA = BB; // error, AA is not of abstract type. +new AA; +function constructB(Factory) { + new Factory; // error -- Factory is of type typeof C +} +var BB = B; +new BB; // error -- BB is of type typeof C +var x = C; +new x; // okay -- undefined behavior at runtime +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); // error -- not declared abstract +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(B); // okay +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.bar = function () { return 1; }; + return E; +})(B); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function () { return 2; }; + return F; +})(B); +var G = (function () { + function G() { + } + G.prototype.nom = ; + G.prototype.nom = ; + return G; +})(); +var H = (function () { + function H() { + } + return H; +})(); diff --git a/tests/baselines/reference/classAbstractManyKeywords.errors.txt b/tests/baselines/reference/classAbstractManyKeywords.errors.txt new file mode 100644 index 0000000000000..b200404eaf01a --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ==== + export default abstract class A {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. + ~~~~~ +!!! error TS1005: ';' expected. + export abstract class B {} + default abstract class C {} + ~~~~~~~ +!!! error TS1128: Declaration or statement expected. + import abstract class D {} + ~~~~~ +!!! error TS1005: '=' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractManyKeywords.js b/tests/baselines/reference/classAbstractManyKeywords.js new file mode 100644 index 0000000000000..79191c029e1b9 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.js @@ -0,0 +1,28 @@ +//// [classAbstractManyKeywords.ts] +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} + +//// [classAbstractManyKeywords.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +exports.B = B; +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt new file mode 100644 index 0000000000000..5af440ed4df9e --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts (3 errors) ==== + abstract class A {} + + abstract + class B {} + + abstract + + class C {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.js b/tests/baselines/reference/classAbstractMultiLineDecl.js new file mode 100644 index 0000000000000..3a92e2aa1e5dc --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.js @@ -0,0 +1,33 @@ +//// [classAbstractMultiLineDecl.ts] +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; + +//// [classAbstractMultiLineDecl.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +var C = (function () { + function C() { + } + return C; +})(); +new A; +new B; +new C; diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt b/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt deleted file mode 100644 index a9da2f38c376c..0000000000000 --- a/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(26,10): error TS2511: Cannot create an instance of the abstract class 'A'. - - -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts (3 errors) ==== - - abstract class A {} - - class B extends A {} - - abstract class C extends B {} - - new A; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'A'. - new B; - new C; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'C'. - - var a : A; - var b : B; - var c : C; - - a = new B; - b = new B; - c = new B; - - module M { - export abstract class A {} - } - - import myA = M.A; - - var aa = new myA; - ~~~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'A'. - \ No newline at end of file From 4490ff70b8d8a23b3f7bc71c48a971d9cb9e3fe8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 23 Jun 2015 09:05:49 -0700 Subject: [PATCH 136/250] Add Jake task to update the Sublime plugin --- Jakefile.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jakefile.js b/Jakefile.js index afe0ffd3ce5fe..c5f30cf9f6c57 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -690,3 +690,9 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function }); ex.run(); }, { async: true }); + +desc("Updates the sublime plugin's tsserver"); +task("update-sublime", [serverFile], function() { + jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/"); + jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); +}); From 9451aa66ee554f065b16a98adc71fa5ae84630e7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 10:12:32 -0700 Subject: [PATCH 137/250] Fixed order of arguments in error message --- 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 5b1479bbf3133..48903c2443f42 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6707,7 +6707,7 @@ namespace ts { // Get the declaring the class instance type for the error message. declaringClass = getDeclaredTypeOfSymbol(prop.parent); - error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_called_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_called_via_super_expression, typeToString(declaringClass), symbolToString(prop)); return false; } } From 1068890fcd54747594cac2fcfccef39fc55c63ba Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 10:33:41 -0700 Subject: [PATCH 138/250] Moved tests to classAbstractKeyword folder --- tests/cases/compiler/abstractClass1.ts | 36 ------------------- .../compiler/abstractClassIdentifierName.ts | 4 --- .../classAbstractAsIdentifier.ts | 5 +++ .../classAbstractInAModule.ts | 7 ++++ .../classAbstractSuperCalls.ts | 2 +- ...s => classAbstractUsingAbstractMethod1.ts} | 0 .../classAbstractUsingAbstractMethods2.ts} | 0 .../classAbstractWithInterface.ts | 1 + 8 files changed, 14 insertions(+), 41 deletions(-) delete mode 100644 tests/cases/compiler/abstractClass1.ts delete mode 100644 tests/cases/compiler/abstractClassIdentifierName.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts rename tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/{classAbstractUsingAbstractMethod.ts => classAbstractUsingAbstractMethod1.ts} (100%) rename tests/cases/conformance/classes/classDeclarations/{classWithAbstractMethods.ts => classAbstractKeyword/classAbstractUsingAbstractMethods2.ts} (100%) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts diff --git a/tests/cases/compiler/abstractClass1.ts b/tests/cases/compiler/abstractClass1.ts deleted file mode 100644 index 1590ee907f0d9..0000000000000 --- a/tests/cases/compiler/abstractClass1.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @declaration: true - -abstract class Foo { - constructor(f: any) { } - public static bar(): void { } - - public empty() { } -} - -class Bar extends Foo { - constructor(f: any) { - super(f); - } -} - -var a = new Foo(1); // Error -var b = new Foo(); // Error because of invalid constructor arguments - -module baz { - export abstract class Qux { - } - export class Quz extends Qux { - } -} - -new baz.Qux(); - -// Valid -var c = new Bar(1); -c.empty(); - -// Calling a static method on a abstract class is valid -Foo.bar(); - -var Copy = Foo; -new Copy(); diff --git a/tests/cases/compiler/abstractClassIdentifierName.ts b/tests/cases/compiler/abstractClassIdentifierName.ts deleted file mode 100644 index 09d07f16fb895..0000000000000 --- a/tests/cases/compiler/abstractClassIdentifierName.ts +++ /dev/null @@ -1,4 +0,0 @@ -class abstract { - - abstract(): void { } -} diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts new file mode 100644 index 0000000000000..4c251a03c366d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts @@ -0,0 +1,5 @@ +class abstract { + foo() { return 1; } +} + +new abstract; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts new file mode 100644 index 0000000000000..f31dd41436ebb --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts @@ -0,0 +1,7 @@ +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts index 90fdc5cc3898e..e93a670b55fac 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts @@ -11,7 +11,7 @@ abstract class B extends A { class C extends B { foo() { return 2; } - qux() { return super.foo(); } // error, super is abstract + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract norf() { return super.bar(); } } diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts new file mode 100644 index 0000000000000..17b8986894320 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts @@ -0,0 +1 @@ +abstract interface I {} \ No newline at end of file From 74d248e1222cda621c05d53b393b04e33ed9cb9b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 10:42:49 -0700 Subject: [PATCH 139/250] Changed error message --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 48903c2443f42..2bfa45db992dc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6707,7 +6707,7 @@ namespace ts { // Get the declaring the class instance type for the error message. declaringClass = getDeclaredTypeOfSymbol(prop.parent); - error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_called_via_super_expression, typeToString(declaringClass), symbolToString(prop)); + error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_accessed_via_super_expression, typeToString(declaringClass), symbolToString(prop)); return false; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 572c83849e576..e4977e56a784e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -395,7 +395,7 @@ namespace ts { Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be `abstract` or not `abstract." }, - Abstract_method_0_1_cannot_be_called_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}.{1}' cannot be called via super expression." }, + Abstract_method_0_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}.{1}' cannot be accessed via super expression." }, Classes_containing_abstract_functions_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract functions must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 425aa5e87ac83..731d4fed59afa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1567,7 +1567,7 @@ "category": "Error", "code": 2512 }, - "Abstract method '{0}.{1}' cannot be called via super expression.": { + "Abstract method '{0}.{1}' cannot be accessed via super expression.": { "category": "Error", "code": 2513 }, From 3eea71786b912b1ed20edfd6986d80cb4e733159 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 11:08:20 -0700 Subject: [PATCH 140/250] Fixed some error messages. --- src/compiler/checker.ts | 24 ++++++++++++------- .../diagnosticInformationMap.generated.ts | 4 ++-- src/compiler/diagnosticMessages.json | 4 ++-- .../classAbstractInstantiations2.ts | 6 ++--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2bfa45db992dc..e4d30141d381c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6701,10 +6701,12 @@ namespace ts { return false; } - // In a super call, the methods cannot be accessed if the method is abstract. - // Note that a member cannot be private and abstract -- this is checked elsewhere. if (flags & NodeFlags.Abstract) { - // Get the declaring the class instance type for the error message. + // A method cannot be accessed in a super call if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + declaringClass = getDeclaredTypeOfSymbol(prop.parent); error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_accessed_via_super_expression, typeToString(declaringClass), symbolToString(prop)); @@ -9145,7 +9147,7 @@ namespace ts { error(signatureDeclarationNode, Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); } - function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) : NodeFlags { + function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags { let flags = getCombinedNodeFlags(n); if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) { if (!(flags & NodeFlags.Ambient)) { @@ -9192,7 +9194,7 @@ namespace ts { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & NodeFlags.Abstract) { - error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract, "abstract"); + error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); } @@ -10732,7 +10734,7 @@ namespace ts { // Classes containing abstract methods must be marked abstract if (!(node.flags & NodeFlags.Abstract) && forEach(node.members, element => element.flags & NodeFlags.Abstract)) { - error(node, Diagnostics.Classes_containing_abstract_functions_must_be_marked_abstract); + error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); } if (produceDiagnostics) { @@ -10785,8 +10787,8 @@ namespace ts { // It is an error to inherit an abstract member without implementing it or being declared abstract. if ((baseDeclarationFlags & NodeFlags.Abstract) && !(derivedClassDecl.flags & NodeFlags.Abstract)) { - error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2, - typeToString(type), typeToString(baseType), symbolToString(baseProperty)); + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } } else { @@ -12821,7 +12823,11 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & NodeFlags.Abstract) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + if (modifier.kind === SyntaxKind.PrivateKeyword) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract")} + else { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } } flags |= modifierToFlag(modifier.kind); break; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index e4977e56a784e..364a703d415d3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -396,8 +396,8 @@ namespace ts { Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be `abstract` or not `abstract." }, Abstract_method_0_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}.{1}' cannot be accessed via super expression." }, - Classes_containing_abstract_functions_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract functions must be marked abstract." }, - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, 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 731d4fed59afa..ac191e635ee4b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1571,11 +1571,11 @@ "category": "Error", "code": 2513 }, - "Classes containing abstract functions must be marked abstract.": { + "Classes containing abstract methods must be marked abstract.": { "category": "Error", "code": 2514 }, - "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'.": { + "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": { "category": "Error", "code": 2515 }, diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts index 6cca7ed947ff5..ef965dfe94be4 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -3,7 +3,7 @@ class A { } abstract class B { - foo(): number { return bar(); } + foo(): number { return this.bar(); } abstract bar() : number; } @@ -42,8 +42,8 @@ abstract class G { y : number; abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent - abstract nom() boolean; - nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. } class H { // error -- not declared abstract From 1f6637b495812b6e83cc64b142bd53e22a9c7753 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 11:19:15 -0700 Subject: [PATCH 141/250] Added check to test --- .../classAbstractKeyword/classAbstractProperties.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts index 3349e878e03d3..e6dc355adb97e 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts @@ -4,6 +4,8 @@ abstract class A { protected abstract z : number; private abstract w : number; + abstract m: () => void; + abstract foo_x() : number; public abstract foo_y() : number; protected abstract foo_z() : number; From 771e4871266dee0363c65268fa1750feba54a33c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 11:23:45 -0700 Subject: [PATCH 142/250] Re-fixed error message. --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e4d30141d381c..8554f4a009109 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6709,7 +6709,7 @@ namespace ts { declaringClass = getDeclaredTypeOfSymbol(prop.parent); - error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_accessed_via_super_expression, typeToString(declaringClass), symbolToString(prop)); + error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 364a703d415d3..853ee81359c51 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -395,7 +395,7 @@ namespace ts { Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be `abstract` or not `abstract." }, - Abstract_method_0_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}.{1}' cannot be accessed via super expression." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ac191e635ee4b..3605bae69006a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1567,7 +1567,7 @@ "category": "Error", "code": 2512 }, - "Abstract method '{0}.{1}' cannot be accessed via super expression.": { + "Abstract method '{0}' in class '{1}' cannot be accessed via super expression.": { "category": "Error", "code": 2513 }, From 36b1dbaf95fda4b8f1dabacaeece4cf5f21ced47 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 11:30:30 -0700 Subject: [PATCH 143/250] accepted baselines --- .../reference/abstractClass1.errors.txt | 57 ---------- tests/baselines/reference/abstractClass1.js | 106 ------------------ .../reference/abstractClassIdentifierName.js | 14 --- .../abstractClassIdentifierName.symbols | 8 -- .../abstractClassIdentifierName.types | 8 -- .../reference/classAbstractAsIdentifier.js | 15 +++ .../classAbstractAsIdentifier.symbols | 11 ++ .../reference/classAbstractAsIdentifier.types | 13 +++ .../classAbstractDeclarations.d.errors.txt | 12 +- .../classAbstractInAModule.errors.txt | 13 +++ .../reference/classAbstractInAModule.js | 34 ++++++ .../classAbstractInheritance.errors.txt | 12 +- .../classAbstractInstantiations2.errors.txt | 40 +++---- .../reference/classAbstractInstantiations2.js | 10 +- ...classAbstractMixedWithModifiers.errors.txt | 4 +- .../classAbstractProperties.errors.txt | 9 +- .../reference/classAbstractProperties.js | 2 + .../classAbstractSuperCalls.errors.txt | 11 +- .../reference/classAbstractSuperCalls.js | 4 +- ...ssAbstractUsingAbstractMethod1.errors.txt} | 4 +- ...s => classAbstractUsingAbstractMethod1.js} | 4 +- ...ssAbstractUsingAbstractMethods2.errors.txt | 42 +++++++ ... => classAbstractUsingAbstractMethods2.js} | 4 +- .../classAbstractWithInterface.errors.txt | 7 ++ .../reference/classAbstractWithInterface.js | 4 + .../classWithAbstractMethods.errors.txt | 42 ------- 26 files changed, 195 insertions(+), 295 deletions(-) delete mode 100644 tests/baselines/reference/abstractClass1.errors.txt delete mode 100644 tests/baselines/reference/abstractClass1.js delete mode 100644 tests/baselines/reference/abstractClassIdentifierName.js delete mode 100644 tests/baselines/reference/abstractClassIdentifierName.symbols delete mode 100644 tests/baselines/reference/abstractClassIdentifierName.types create mode 100644 tests/baselines/reference/classAbstractAsIdentifier.js create mode 100644 tests/baselines/reference/classAbstractAsIdentifier.symbols create mode 100644 tests/baselines/reference/classAbstractAsIdentifier.types create mode 100644 tests/baselines/reference/classAbstractInAModule.errors.txt create mode 100644 tests/baselines/reference/classAbstractInAModule.js rename tests/baselines/reference/{classAbstractUsingAbstractMethod.errors.txt => classAbstractUsingAbstractMethod1.errors.txt} (72%) rename tests/baselines/reference/{classAbstractUsingAbstractMethod.js => classAbstractUsingAbstractMethod1.js} (89%) create mode 100644 tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt rename tests/baselines/reference/{classWithAbstractMethods.js => classAbstractUsingAbstractMethods2.js} (91%) create mode 100644 tests/baselines/reference/classAbstractWithInterface.errors.txt create mode 100644 tests/baselines/reference/classAbstractWithInterface.js delete mode 100644 tests/baselines/reference/classWithAbstractMethods.errors.txt diff --git a/tests/baselines/reference/abstractClass1.errors.txt b/tests/baselines/reference/abstractClass1.errors.txt deleted file mode 100644 index 5e658fec6412b..0000000000000 --- a/tests/baselines/reference/abstractClass1.errors.txt +++ /dev/null @@ -1,57 +0,0 @@ -tests/cases/compiler/abstractClass1.ts(15,9): error TS2511: Cannot create an instance of the abstract class 'Foo'. -tests/cases/compiler/abstractClass1.ts(16,9): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/abstractClass1.ts(16,9): error TS2511: Cannot create an instance of the abstract class 'Foo'. -tests/cases/compiler/abstractClass1.ts(25,1): error TS2511: Cannot create an instance of the abstract class 'Qux'. -tests/cases/compiler/abstractClass1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/abstractClass1.ts(35,1): error TS2511: Cannot create an instance of the abstract class 'Foo'. - - -==== tests/cases/compiler/abstractClass1.ts (6 errors) ==== - - abstract class Foo { - constructor(f: any) { } - public static bar(): void { } - - public empty() { } - } - - class Bar extends Foo { - constructor(f: any) { - super(f); - } - } - - var a = new Foo(1); // Error - ~~~~~~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'Foo'. - var b = new Foo(); // Error because of invalid constructor arguments - ~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'Foo'. - - module baz { - export abstract class Qux { - } - export class Quz extends Qux { - } - } - - new baz.Qux(); - ~~~~~~~~~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'Qux'. - - // Valid - var c = new Bar(1); - c.empty(); - - // Calling a static method on a abstract class is valid - Foo.bar(); - - var Copy = Foo; - new Copy(); - ~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~~~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'Foo'. - \ No newline at end of file diff --git a/tests/baselines/reference/abstractClass1.js b/tests/baselines/reference/abstractClass1.js deleted file mode 100644 index 06868a485f5eb..0000000000000 --- a/tests/baselines/reference/abstractClass1.js +++ /dev/null @@ -1,106 +0,0 @@ -//// [abstractClass1.ts] - -abstract class Foo { - constructor(f: any) { } - public static bar(): void { } - - public empty() { } -} - -class Bar extends Foo { - constructor(f: any) { - super(f); - } -} - -var a = new Foo(1); // Error -var b = new Foo(); // Error because of invalid constructor arguments - -module baz { - export abstract class Qux { - } - export class Quz extends Qux { - } -} - -new baz.Qux(); - -// Valid -var c = new Bar(1); -c.empty(); - -// Calling a static method on a abstract class is valid -Foo.bar(); - -var Copy = Foo; -new Copy(); - - -//// [abstractClass1.js] -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var Foo = (function () { - function Foo(f) { - } - Foo.bar = function () { }; - Foo.prototype.empty = function () { }; - return Foo; -})(); -var Bar = (function (_super) { - __extends(Bar, _super); - function Bar(f) { - _super.call(this, f); - } - return Bar; -})(Foo); -var a = new Foo(1); // Error -var b = new Foo(); // Error because of invalid constructor arguments -var baz; -(function (baz) { - var Qux = (function () { - function Qux() { - } - return Qux; - })(); - baz.Qux = Qux; - var Quz = (function (_super) { - __extends(Quz, _super); - function Quz() { - _super.apply(this, arguments); - } - return Quz; - })(Qux); - baz.Quz = Quz; -})(baz || (baz = {})); -new baz.Qux(); -// Valid -var c = new Bar(1); -c.empty(); -// Calling a static method on a abstract class is valid -Foo.bar(); -var Copy = Foo; -new Copy(); - - -//// [abstractClass1.d.ts] -declare abstract class Foo { - constructor(f: any); - static bar(): void; - empty(): void; -} -declare class Bar extends Foo { - constructor(f: any); -} -declare var a: Foo; -declare var b: any; -declare module baz { - abstract class Qux { - } - class Quz extends Qux { - } -} -declare var c: Bar; -declare var Copy: typeof Foo; diff --git a/tests/baselines/reference/abstractClassIdentifierName.js b/tests/baselines/reference/abstractClassIdentifierName.js deleted file mode 100644 index 0e53e44671ab4..0000000000000 --- a/tests/baselines/reference/abstractClassIdentifierName.js +++ /dev/null @@ -1,14 +0,0 @@ -//// [abstractClassIdentifierName.ts] -class abstract { - - abstract(): void { } -} - - -//// [abstractClassIdentifierName.js] -var abstract = (function () { - function abstract() { - } - abstract.prototype.abstract = function () { }; - return abstract; -})(); diff --git a/tests/baselines/reference/abstractClassIdentifierName.symbols b/tests/baselines/reference/abstractClassIdentifierName.symbols deleted file mode 100644 index 12d878620d893..0000000000000 --- a/tests/baselines/reference/abstractClassIdentifierName.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/abstractClassIdentifierName.ts === -class abstract { ->abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 0)) - - abstract(): void { } ->abstract : Symbol(abstract, Decl(abstractClassIdentifierName.ts, 0, 16)) -} - diff --git a/tests/baselines/reference/abstractClassIdentifierName.types b/tests/baselines/reference/abstractClassIdentifierName.types deleted file mode 100644 index e31abf49a6f4c..0000000000000 --- a/tests/baselines/reference/abstractClassIdentifierName.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/abstractClassIdentifierName.ts === -class abstract { ->abstract : abstract - - abstract(): void { } ->abstract : () => void -} - diff --git a/tests/baselines/reference/classAbstractAsIdentifier.js b/tests/baselines/reference/classAbstractAsIdentifier.js new file mode 100644 index 0000000000000..6adadd346b599 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.js @@ -0,0 +1,15 @@ +//// [classAbstractAsIdentifier.ts] +class abstract { + foo() { return 1; } +} + +new abstract; + +//// [classAbstractAsIdentifier.js] +var abstract = (function () { + function abstract() { + } + abstract.prototype.foo = function () { return 1; }; + return abstract; +})(); +new abstract; diff --git a/tests/baselines/reference/classAbstractAsIdentifier.symbols b/tests/baselines/reference/classAbstractAsIdentifier.symbols new file mode 100644 index 0000000000000..f2ce2ebcab517 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + + foo() { return 1; } +>foo : Symbol(foo, Decl(classAbstractAsIdentifier.ts, 0, 16)) +} + +new abstract; +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + diff --git a/tests/baselines/reference/classAbstractAsIdentifier.types b/tests/baselines/reference/classAbstractAsIdentifier.types new file mode 100644 index 0000000000000..e2894af804d23 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : abstract + + foo() { return 1; } +>foo : () => number +>1 : number +} + +new abstract; +>new abstract : abstract +>abstract : typeof abstract + diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt index 501a54e553918..33beb6d296b17 100644 --- a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (5 errors) ==== @@ -22,17 +22,17 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst declare class CC extends AA {} ~~ -!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. declare class DD extends BB {} ~~ -!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. declare abstract class EE extends BB {} declare class FF extends CC {} ~~ -!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. declare abstract class GG extends CC {} diff --git a/tests/baselines/reference/classAbstractInAModule.errors.txt b/tests/baselines/reference/classAbstractInAModule.errors.txt new file mode 100644 index 0000000000000..426da866087f5 --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts(6,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts (1 errors) ==== + module M { + export abstract class A {} + export class B extends A {} + } + + new M.A; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new M.B; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInAModule.js b/tests/baselines/reference/classAbstractInAModule.js new file mode 100644 index 0000000000000..e7ecd66b5bd04 --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.js @@ -0,0 +1,34 @@ +//// [classAbstractInAModule.ts] +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; + +//// [classAbstractInAModule.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(A); + M.B = B; +})(M || (M = {})); +new M.A; +new M.B; diff --git a/tests/baselines/reference/classAbstractInheritance.errors.txt b/tests/baselines/reference/classAbstractInheritance.errors.txt index a663a46675779..3e1062044150d 100644 --- a/tests/baselines/reference/classAbstractInheritance.errors.txt +++ b/tests/baselines/reference/classAbstractInheritance.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(13,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(15,7): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(19,7): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(13,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(15,7): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(19,7): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts (3 errors) ==== @@ -18,16 +18,16 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst class CC extends AA {} ~~ -!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'AA.foo'. +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. class DD extends BB {} ~~ -!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'BB.foo'. +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. abstract class EE extends BB {} class FF extends CC {} ~~ -!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'CC.foo'. +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index c3cb4a4cae424..8252887e98d0b 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -1,26 +1,20 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(6,28): error TS2304: Cannot find name 'bar'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'B.bar'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,14): error TS2516: All declarations of an abstract method must be consecutive. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,20): error TS1144: '{' or ';' expected. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,20): error TS2300: Duplicate identifier 'boolean'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be `abstract` or not `abstract. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,21): error TS1144: '{' or ';' expected. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,21): error TS2300: Duplicate identifier 'boolean'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(49,7): error TS2514: Classes containing abstract functions must be marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(49,7): error TS2514: Classes containing abstract methods must be marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1238: Abstract methods can only appear within an abstract class. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (12 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ==== class A { // ... } abstract class B { - foo(): number { return bar(); } - ~~~ -!!! error TS2304: Cannot find name 'bar'. + foo(): number { return this.bar(); } abstract bar() : number; } @@ -48,7 +42,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst class C extends B { } // error -- not declared abstract ~ -!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'B.bar'. +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. abstract class D extends B { } // okay @@ -67,24 +61,18 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst y : number; abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent - abstract nom() boolean; - ~~~ -!!! error TS2516: All declarations of an abstract method must be consecutive. - ~~~~~~~ -!!! error TS1144: '{' or ';' expected. - ~~~~~~~ -!!! error TS2300: Duplicate identifier 'boolean'. - nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. ~~~ !!! error TS2512: Overload signatures must all be `abstract` or not `abstract. - ~~~~~~~ -!!! error TS1144: '{' or ';' expected. - ~~~~~~~ -!!! error TS2300: Duplicate identifier 'boolean'. } class H { // error -- not declared abstract ~ -!!! error TS2514: Classes containing abstract functions must be marked abstract. +!!! error TS2514: Classes containing abstract methods must be marked abstract. abstract baz() : number; + ~~~~~~~~ +!!! error TS1238: Abstract methods can only appear within an abstract class. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js index 055bdfedbc384..5b868b3f7956f 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.js +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -4,7 +4,7 @@ class A { } abstract class B { - foo(): number { return bar(); } + foo(): number { return this.bar(); } abstract bar() : number; } @@ -43,8 +43,8 @@ abstract class G { y : number; abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent - abstract nom() boolean; - nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. } class H { // error -- not declared abstract @@ -65,7 +65,7 @@ var A = (function () { var B = (function () { function B() { } - B.prototype.foo = function () { return bar(); }; + B.prototype.foo = function () { return this.bar(); }; return B; })(); new B; // error @@ -112,8 +112,6 @@ var F = (function (_super) { var G = (function () { function G() { } - G.prototype.nom = ; - G.prototype.nom = ; return G; })(); var H = (function () { diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt index 488fbdeb36e9e..4b0870e6bc5e0 100644 --- a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1029: 'private' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1237: 'static' modifier cannot be used with 'abstract' modifier. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1237: 'static' modifier cannot be used with 'abstract' modifier. @@ -24,7 +24,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst !!! error TS1029: 'protected' modifier must precede 'abstract' modifier. abstract private foo_dd(); ~~~~~~~ -!!! error TS1029: 'private' modifier must precede 'abstract' modifier. +!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier. abstract static foo_d(); ~~~~~~ diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt index 30e7ca1153dc0..d3ee6308bc50f 100644 --- a/tests/baselines/reference/classAbstractProperties.errors.txt +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1236: 'abstract' modifier can only appear on a class or method declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1236: 'abstract' modifier can only appear on a class or method declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(10,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (5 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (6 errors) ==== abstract class A { abstract x : number; ~~~~~~~~ @@ -20,6 +21,10 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~~~~~~ !!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. + abstract m: () => void; + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. + abstract foo_x() : number; public abstract foo_y() : number; protected abstract foo_z() : number; diff --git a/tests/baselines/reference/classAbstractProperties.js b/tests/baselines/reference/classAbstractProperties.js index a410715e4f784..0cbebcf0de0e5 100644 --- a/tests/baselines/reference/classAbstractProperties.js +++ b/tests/baselines/reference/classAbstractProperties.js @@ -5,6 +5,8 @@ abstract class A { protected abstract z : number; private abstract w : number; + abstract m: () => void; + abstract foo_x() : number; public abstract foo_y() : number; protected abstract foo_z() : number; diff --git a/tests/baselines/reference/classAbstractSuperCalls.errors.txt b/tests/baselines/reference/classAbstractSuperCalls.errors.txt index ea81b2b60afc6..a9dbf0f7ba8ce 100644 --- a/tests/baselines/reference/classAbstractSuperCalls.errors.txt +++ b/tests/baselines/reference/classAbstractSuperCalls.errors.txt @@ -1,7 +1,8 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract method 'foo.B' cannot be called via super expression. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,41): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (1 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (2 errors) ==== class A { foo() { return 1; } @@ -15,9 +16,11 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst class C extends B { foo() { return 2; } - qux() { return super.foo(); } // error, super is abstract + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract ~~~ -!!! error TS2513: Abstract method 'foo.B' cannot be called via super expression. +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. norf() { return super.bar(); } } diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js index 152fd03f463ef..deccaa50ccf27 100644 --- a/tests/baselines/reference/classAbstractSuperCalls.js +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -12,7 +12,7 @@ abstract class B extends A { class C extends B { foo() { return 2; } - qux() { return super.foo(); } // error, super is abstract + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract norf() { return super.bar(); } } @@ -54,7 +54,7 @@ var C = (function (_super) { _super.apply(this, arguments); } C.prototype.foo = function () { return 2; }; - C.prototype.qux = function () { return _super.prototype.foo.call(this); }; // error, super is abstract + C.prototype.qux = function () { return _super.prototype.foo.call(this) || _super.prototype.foo; }; // 2 errors, foo is abstract C.prototype.norf = function () { return _super.prototype.bar.call(this); }; return C; })(B); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt similarity index 72% rename from tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt rename to tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt index 3ae5084e2db69..df3682a36afb3 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethod.errors.txt +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts(16,5): error TS2511: Cannot create an instance of the abstract class 'C'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts(16,5): error TS2511: Cannot create an instance of the abstract class 'C'. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod.ts (1 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts (1 errors) ==== abstract class A { abstract foo() : number; } diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod.js b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js similarity index 89% rename from tests/baselines/reference/classAbstractUsingAbstractMethod.js rename to tests/baselines/reference/classAbstractUsingAbstractMethod1.js index 74bc80b263005..18d22803a7d73 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethod.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js @@ -1,4 +1,4 @@ -//// [classAbstractUsingAbstractMethod.ts] +//// [classAbstractUsingAbstractMethod1.ts] abstract class A { abstract foo() : number; } @@ -17,7 +17,7 @@ a.foo(); a = new C; // error, cannot instantiate abstract class. a.foo(); -//// [classAbstractUsingAbstractMethod.js] +//// [classAbstractUsingAbstractMethod1.js] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt new file mode 100644 index 0000000000000..8a0e5735a2515 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(1,7): error TS2514: Classes containing abstract methods must be marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(2,5): error TS1238: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(5,7): error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(21,7): error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts (4 errors) ==== + class A { + ~ +!!! error TS2514: Classes containing abstract methods must be marked abstract. + abstract foo(); + ~~~~~~~~ +!!! error TS1238: Abstract methods can only appear within an abstract class. + } + + class B extends A {} + ~ +!!! error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. + + abstract class C extends A {} + + class D extends A { + foo() {} + } + + abstract class E extends A { + foo() {} + } + + abstract class AA { + abstract foo(); + } + + class BB extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + abstract class CC extends AA {} + + class DD extends AA { + foo() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classWithAbstractMethods.js b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js similarity index 91% rename from tests/baselines/reference/classWithAbstractMethods.js rename to tests/baselines/reference/classAbstractUsingAbstractMethods2.js index 91ccc5f9306ad..d579723292990 100644 --- a/tests/baselines/reference/classWithAbstractMethods.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js @@ -1,4 +1,4 @@ -//// [classWithAbstractMethods.ts] +//// [classAbstractUsingAbstractMethods2.ts] class A { abstract foo(); } @@ -27,7 +27,7 @@ class DD extends AA { foo() {} } -//// [classWithAbstractMethods.js] +//// [classAbstractUsingAbstractMethods2.js] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } diff --git a/tests/baselines/reference/classAbstractWithInterface.errors.txt b/tests/baselines/reference/classAbstractWithInterface.errors.txt new file mode 100644 index 0000000000000..7dc4dcd87c4b4 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1236: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts (1 errors) ==== + abstract interface I {} + ~~~~~~~~ +!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractWithInterface.js b/tests/baselines/reference/classAbstractWithInterface.js new file mode 100644 index 0000000000000..317e393a2f578 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.js @@ -0,0 +1,4 @@ +//// [classAbstractWithInterface.ts] +abstract interface I {} + +//// [classAbstractWithInterface.js] diff --git a/tests/baselines/reference/classWithAbstractMethods.errors.txt b/tests/baselines/reference/classWithAbstractMethods.errors.txt deleted file mode 100644 index d66303289abc1..0000000000000 --- a/tests/baselines/reference/classWithAbstractMethods.errors.txt +++ /dev/null @@ -1,42 +0,0 @@ -tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(1,7): error TS2514: Classes containing abstract functions must be marked abstract. -tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(2,5): error TS1238: Abstract methods can only appear within an abstract class. -tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(5,7): error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'A.foo'. -tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts(21,7): error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'AA.foo'. - - -==== tests/cases/conformance/classes/classDeclarations/classWithAbstractMethods.ts (4 errors) ==== - class A { - ~ -!!! error TS2514: Classes containing abstract functions must be marked abstract. - abstract foo(); - ~~~~~~~~ -!!! error TS1238: Abstract methods can only appear within an abstract class. - } - - class B extends A {} - ~ -!!! error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'A.foo'. - - abstract class C extends A {} - - class D extends A { - foo() {} - } - - abstract class E extends A { - foo() {} - } - - abstract class AA { - abstract foo(); - } - - class BB extends AA {} - ~~ -!!! error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'AA.foo'. - - abstract class CC extends AA {} - - class DD extends AA { - foo() {} - } \ No newline at end of file From b332727c7c2cddcd96a65d51d23fd9840e6a2d05 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 23 Jun 2015 13:30:10 -0700 Subject: [PATCH 144/250] updated comment in test and baseline --- .../reference/classAbstractInstantiations2.errors.txt | 4 ++-- tests/baselines/reference/classAbstractInstantiations2.js | 8 ++++---- .../classAbstractKeyword/classAbstractInstantiations2.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index 8252887e98d0b..1f64759f86d68 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -27,13 +27,13 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst new AA; function constructB(Factory : typeof B) { - new Factory; // error -- Factory is of type typeof C + new Factory; // error -- Factory is of type typeof B. ~~~~~~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'B'. } var BB = B; - new BB; // error -- BB is of type typeof C + new BB; // error -- BB is of type typeof B. ~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'B'. diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js index 5b868b3f7956f..1f45f02da0bb0 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.js +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -15,11 +15,11 @@ var AA: typeof A = BB; // error, AA is not of abstract type. new AA; function constructB(Factory : typeof B) { - new Factory; // error -- Factory is of type typeof C + new Factory; // error -- Factory is of type typeof B. } var BB = B; -new BB; // error -- BB is of type typeof C +new BB; // error -- BB is of type typeof B. var x : any = C; new x; // okay -- undefined behavior at runtime @@ -73,10 +73,10 @@ var BB = B; var AA = BB; // error, AA is not of abstract type. new AA; function constructB(Factory) { - new Factory; // error -- Factory is of type typeof C + new Factory; // error -- Factory is of type typeof B. } var BB = B; -new BB; // error -- BB is of type typeof C +new BB; // error -- BB is of type typeof B. var x = C; new x; // okay -- undefined behavior at runtime var C = (function (_super) { diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts index ef965dfe94be4..3b68b898b94d6 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -14,11 +14,11 @@ var AA: typeof A = BB; // error, AA is not of abstract type. new AA; function constructB(Factory : typeof B) { - new Factory; // error -- Factory is of type typeof C + new Factory; // error -- Factory is of type typeof B. } var BB = B; -new BB; // error -- BB is of type typeof C +new BB; // error -- BB is of type typeof B. var x : any = C; new x; // okay -- undefined behavior at runtime From 15c68421f1a9b9d8d38a37b7d8765172bdcc9cc0 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 24 Jun 2015 12:46:43 -0700 Subject: [PATCH 145/250] consolidated looping through class members into one loop --- src/compiler/checker.ts | 18 ++++++++++++++---- src/compiler/core.ts | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8554f4a009109..63ac250c2ff9d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10730,11 +10730,21 @@ namespace ts { }); } - forEach(node.members, checkSourceElement); + // forEach(node.members, checkSourceElement); + + if(node.flags & NodeFlags.Abstract) { + forEach(node.members, checkSourceElement); + } + else { + forEach(node.members, element => { + checkSourceElement(element); - // Classes containing abstract methods must be marked abstract - if (!(node.flags & NodeFlags.Abstract) && forEach(node.members, element => element.flags & NodeFlags.Abstract)) { - error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); + // Classes containing abstract methods must be marked abstract + if (element.flags & NodeFlags.Abstract) { + error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); + } + return undefined; + }); } if (produceDiagnostics) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ced477eeeec54..39ccbdb49397d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -59,6 +59,11 @@ namespace ts { export interface StringSet extends Map { } + /** + * Iterates through 'array' by index and performs the callback on each element of array + * until the callback returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array. + */ export function forEach(array: T[], callback: (element: T, index: number) => U): U { if (array) { for (let i = 0, len = array.length; i < len; i++) { From 593005237b9e904cd00d7243dfaad22daca63c84 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 24 Jun 2015 13:10:08 -0700 Subject: [PATCH 146/250] cleaner loop --- src/compiler/checker.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 63ac250c2ff9d..cc23103403eab 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10730,22 +10730,16 @@ namespace ts { }); } - // forEach(node.members, checkSourceElement); - - if(node.flags & NodeFlags.Abstract) { - forEach(node.members, checkSourceElement); - } - else { - forEach(node.members, element => { + forEach(node.members, node.flags & NodeFlags.Abstract ? + checkSourceElement : + element => { checkSourceElement(element); // Classes containing abstract methods must be marked abstract if (element.flags & NodeFlags.Abstract) { error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); } - return undefined; }); - } if (produceDiagnostics) { checkIndexConstraints(type); From 65828c4d9f2048b5c79468af7d27c96dd20020f5 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 24 Jun 2015 13:49:59 -0700 Subject: [PATCH 147/250] Spreaded anys should satisfy all required properties --- src/compiler/checker.ts | 13 +++++++--- .../reference/tsxAttributeResolution8.js | 16 ++++++++++++ .../reference/tsxAttributeResolution8.symbols | 23 +++++++++++++++++ .../reference/tsxAttributeResolution8.types | 25 +++++++++++++++++++ .../jsx/tsxAttributeResolution8.tsx | 12 +++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/tsxAttributeResolution8.js create mode 100644 tests/baselines/reference/tsxAttributeResolution8.symbols create mode 100644 tests/baselines/reference/tsxAttributeResolution8.types create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution8.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fe07a0eae80d7..dd3b29f25e399 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6830,6 +6830,7 @@ namespace ts { nameTable[prop.name] = true; } } + return type; } /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. @@ -7101,24 +7102,28 @@ namespace ts { // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and // thus should have their types ignored + let sawSpreadedAny = false; for (let i = node.attributes.length - 1; i >= 0; i--) { if (node.attributes[i].kind === SyntaxKind.JsxAttribute) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); - checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + let spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if(isTypeAny(spreadType)) { + sawSpreadedAny = true; + } } } - // Check that all required properties have been provided - if (targetAttributesType) { + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { let targetProperties = getPropertiesOfType(targetAttributesType); for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && nameTable[targetProperties[i].name] === undefined) { - console.log('oops?'); error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); } } diff --git a/tests/baselines/reference/tsxAttributeResolution8.js b/tests/baselines/reference/tsxAttributeResolution8.js new file mode 100644 index 0000000000000..50fff6c80fddc --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.js @@ -0,0 +1,16 @@ +//// [tsxAttributeResolution8.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: {x: string}; + } +} + +var x: any; +// Should be OK + + +//// [tsxAttributeResolution8.jsx] +var x; +// Should be OK +; diff --git a/tests/baselines/reference/tsxAttributeResolution8.symbols b/tests/baselines/reference/tsxAttributeResolution8.symbols new file mode 100644 index 0000000000000..9bb09c6cd85e4 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution8.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeResolution8.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxAttributeResolution8.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution8.tsx, 1, 22)) + + test1: {x: string}; +>test1 : Symbol(test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 3, 10)) + } +} + +var x: any; +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 7, 3)) + +// Should be OK + +>test1 : Symbol(JSX.IntrinsicElements.test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxAttributeResolution8.types b/tests/baselines/reference/tsxAttributeResolution8.types new file mode 100644 index 0000000000000..db89d6678b669 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution8.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + test1: {x: string}; +>test1 : { x: string; } +>x : string + } +} + +var x: any; +>x : any + +// Should be OK + +> : JSX.Element +>test1 : any +>x : any + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx new file mode 100644 index 0000000000000..ac99cd155930a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: {x: string}; + } +} + +var x: any; +// Should be OK + \ No newline at end of file From 643832dab5cbf4c11241d541f1352918a3e91816 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 24 Jun 2015 16:46:32 -0700 Subject: [PATCH 148/250] Implement intersection types --- src/compiler/checker.ts | 320 +++++++++++++++++++---------- src/compiler/declarationEmitter.ts | 6 + src/compiler/parser.ts | 23 ++- src/compiler/types.ts | 40 ++-- src/services/services.ts | 4 +- 5 files changed, 259 insertions(+), 134 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a18f2921a9a53..109ad1cf29f27 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -125,6 +125,7 @@ namespace ts { let tupleTypes: Map = {}; let unionTypes: Map = {}; + let intersectionTypes: Map = {}; let stringLiteralTypes: Map = {}; let emitExtends = false; let emitDecorate = false; @@ -1538,8 +1539,8 @@ namespace ts { else if (type.flags & TypeFlags.Tuple) { writeTupleType(type); } - else if (type.flags & TypeFlags.Union) { - writeUnionType(type, flags); + else if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { + writeUnionOrIntersectionType(type, flags); } else if (type.flags & TypeFlags.Anonymous) { writeAnonymousType(type, flags); @@ -1558,16 +1559,16 @@ namespace ts { } } - function writeTypeList(types: Type[], union: boolean) { + function writeTypeList(types: Type[], delimiter: SyntaxKind) { for (let i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== SyntaxKind.CommaToken) { writeSpace(writer); } - writePunctuation(writer, union ? SyntaxKind.BarToken : SyntaxKind.CommaToken); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? TypeFormatFlags.InElementType : TypeFormatFlags.None); + writeType(types[i], delimiter === SyntaxKind.CommaToken ? TypeFormatFlags.None : TypeFormatFlags.InElementType); } } @@ -1625,15 +1626,15 @@ namespace ts { function writeTupleType(type: TupleType) { writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes, /*union*/ false); + writeTypeList(type.elementTypes, SyntaxKind.CommaToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } - function writeUnionType(type: UnionType, flags: TypeFormatFlags) { + function writeUnionOrIntersectionType(type: UnionOrIntersectionType, flags: TypeFormatFlags) { if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.OpenParenToken); } - writeTypeList(type.types, /*union*/ true); + writeTypeList(type.types, type.flags & TypeFlags.Union ? SyntaxKind.BarToken : SyntaxKind.AmpersandToken); if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.CloseParenToken); } @@ -1710,7 +1711,7 @@ namespace ts { } function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, SyntaxKind.OpenBraceToken); @@ -2045,6 +2046,7 @@ namespace ts { case SyntaxKind.ArrayType: case SyntaxKind.TupleType: case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: case SyntaxKind.ParenthesizedType: return isDeclarationVisible(node.parent); @@ -2666,7 +2668,7 @@ namespace ts { if (baseConstructorType.flags & TypeFlags.ObjectType) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. - resolveObjectOrUnionTypeMembers(baseConstructorType); + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -2996,7 +2998,7 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -3062,6 +3064,26 @@ namespace ts { setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1: Type, type2: Type): Type { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + + function resolveIntersectionTypeMembers(type: IntersectionType) { + // The members and properties collections are empty for intersection types. To get all properties of an + // intersection type use getPropertiesOfType (only the language service uses this). + let callSignatures: Signature[] = emptyArray; + let constructSignatures: Signature[] = emptyArray; + let stringIndexType: Type = undefined; + let numberIndexType: Type = undefined; + for (let t of type.types) { + callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call)); + constructSignatures = concatenate(constructSignatures, getSignaturesOfType(t, SignatureKind.Construct)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, IndexKind.String)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, IndexKind.Number)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type: ObjectType) { let symbol = type.symbol; let members: SymbolTable; @@ -3106,7 +3128,7 @@ namespace ts { setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type: ObjectType): ResolvedType { + function resolveStructuredTypeMembers(type: ObjectType): ResolvedType { if (!(type).members) { if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) { resolveClassOrInterfaceMembers(type); @@ -3120,6 +3142,9 @@ namespace ts { else if (type.flags & TypeFlags.Union) { resolveUnionTypeMembers(type); } + else if (type.flags & TypeFlags.Intersection) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -3130,7 +3155,7 @@ namespace ts { // Return properties of an object type or an empty array for other types function getPropertiesOfObjectType(type: Type): Symbol[] { if (type.flags & TypeFlags.ObjectType) { - return resolveObjectOrUnionTypeMembers(type).properties; + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } @@ -3139,7 +3164,7 @@ namespace ts { // the symbol for that property. Otherwise return undefined. function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { let symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -3149,20 +3174,23 @@ namespace ts { } } - function getPropertiesOfUnionType(type: UnionType): Symbol[] { - let result: Symbol[] = []; - forEach(getPropertiesOfType(type.types[0]), prop => { - let unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] { + for (let current of type.types) { + for (let prop of getPropertiesOfType(current)) { + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + // The properties of a union type are those that are present in all constituent types, so + // we only need to check the properties of the first type + if (type.flags & TypeFlags.Union) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type: Type): Symbol[] { type = getApparentType(type); - return type.flags & TypeFlags.Union ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & TypeFlags.UnionOrIntersection ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } // For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -3195,24 +3223,33 @@ namespace ts { return type; } - function createUnionProperty(unionType: UnionType, name: string): Symbol { - let types = unionType.types; + function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol { + let types = containingType.types; let props: Symbol[]; for (let current of types) { let type = getApparentType(current); if (type !== unknownType) { let prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected)) { - return undefined; - } - if (!props) { - props = [prop]; + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected))) { + if (!props) { + props = [prop]; + } + else if (!contains(props, prop)) { + props.push(prop); + } } - else { - props.push(prop); + else if (containingType.flags & TypeFlags.Union) { + // A union type requires the property to be present in all constituent types + return undefined; } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } let propTypes: Type[] = []; let declarations: Declaration[] = []; for (let prop of props) { @@ -3221,19 +3258,19 @@ namespace ts { } propTypes.push(getTypeOfSymbol(prop)); } - let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.UnionProperty, name); - result.unionType = unionType; + let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty, name); + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type: UnionType, name: string): Symbol { + function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { let properties = type.resolvedProperties || (type.resolvedProperties = {}); if (hasProperty(properties, name)) { return properties[name]; } - let property = createUnionProperty(type, name); + let property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -3246,7 +3283,7 @@ namespace ts { function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { let symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -3261,15 +3298,15 @@ namespace ts { } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & TypeFlags.Union) { - return getPropertyOfUnionType(type, name); + if (type.flags & TypeFlags.UnionOrIntersection) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type: Type, kind: SignatureKind): Signature[] { - if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { + if (type.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); return kind === SignatureKind.Call ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; @@ -3278,22 +3315,21 @@ namespace ts { // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and // maps primitive types and type parameters are to their apparent types. function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } function typeHasCallOrConstructSignatures(type: Type): boolean { let apparentType = getApparentType(type); - if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type: Type, kind: IndexKind): Type { - if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type { + if (type.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); return kind === IndexKind.String ? resolved.stringIndexType : resolved.numberIndexType; } } @@ -3301,7 +3337,7 @@ namespace ts { // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type: Type, kind: IndexKind): Type { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual @@ -3828,9 +3864,9 @@ namespace ts { return links.resolvedType; } - function addTypeToSortedSet(sortedSet: Type[], type: Type) { - if (type.flags & TypeFlags.Union) { - addTypesToSortedSet(sortedSet, (type).types); + function addTypeToSortedSet(sortedSet: Type[], type: Type, typeKind: TypeFlags) { + if (type.flags & typeKind) { + addTypesToSortedSet(sortedSet, (type).types, typeKind); } else { let i = 0; @@ -3844,9 +3880,9 @@ namespace ts { } } - function addTypesToSortedSet(sortedTypes: Type[], types: Type[]) { + function addTypesToSortedSet(sortedTypes: Type[], types: Type[], typeKind: TypeFlags) { for (let type of types) { - addTypeToSortedSet(sortedTypes, type); + addTypeToSortedSet(sortedTypes, type, typeKind); } } @@ -3897,7 +3933,7 @@ namespace ts { return emptyObjectType; } let sortedTypes: Type[] = []; - addTypesToSortedSet(sortedTypes, types); + addTypesToSortedSet(sortedTypes, types, TypeFlags.Union); if (noSubtypeReduction) { if (containsTypeAny(sortedTypes)) { return anyType; @@ -3947,6 +3983,35 @@ namespace ts { return links.resolvedType; } + // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // type operator and we can't reduce those because we want to support recursive intersection types. For example, + // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. + function getIntersectionType(types: Type[]): Type { + let sortedTypes: Type[] = []; + addTypesToSortedSet(sortedTypes, types, TypeFlags.Intersection); + if (containsTypeAny(sortedTypes)) { + return anyType; + } + if (sortedTypes.length === 1) { + return sortedTypes[0]; + } + let id = getTypeListId(sortedTypes); + let type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(sortedTypes)); + type.types = sortedTypes; + } + return type; + } + + function getTypeFromIntersectionTypeNode(node: IntersectionTypeNode): Type { + let links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: Node): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -4004,6 +4069,8 @@ namespace ts { return getTypeFromTupleTypeNode(node); case SyntaxKind.UnionType: return getTypeFromUnionTypeNode(node); + case SyntaxKind.IntersectionType: + return getTypeFromIntersectionTypeNode(node); case SyntaxKind.ParenthesizedType: return getTypeFromTypeNode((node).type); case SyntaxKind.FunctionType: @@ -4191,6 +4258,9 @@ namespace ts { if (type.flags & TypeFlags.Union) { return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } + if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); + } } return type; } @@ -4231,7 +4301,7 @@ namespace ts { function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { let result = createObjectType(TypeFlags.Anonymous, type.symbol); result.members = resolved.members; @@ -4341,48 +4411,50 @@ namespace ts { } } let saveErrorInfo = errorInfo; - if (source.flags & TypeFlags.Union || target.flags & TypeFlags.Union) { - if (relation === identityRelation) { - if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } + if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { + return result; + } + } + else if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { + if (result = typeParameterRelatedTo(source, target, reportErrors)) { + return result; + } + } + else if (relation !== identityRelation) { + if (source.flags & TypeFlags.Union) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } + } + else if (target.flags & TypeFlags.Intersection) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; } } else { - if (source.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { + if (source.flags & TypeFlags.Intersection) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { return result; } } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { + if (target.flags & TypeFlags.Union) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { return result; } } } } - else if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { - return result; + else { + if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || + source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } @@ -4398,9 +4470,9 @@ namespace ts { return result; } } - else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) { + else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.UnionOrIntersection) { // We clear the errors first because the following check often gives a better error than - // the union comparison above if it is applicable. + // the union or intersection comparison above if it is applicable. errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -4420,11 +4492,11 @@ namespace ts { return Ternary.False; } - function unionTypeRelatedToUnionType(source: UnionType, target: UnionType): Ternary { + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; let sourceTypes = source.types; for (let sourceType of sourceTypes) { - let related = typeRelatedToUnionType(sourceType, target, false); + let related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return Ternary.False; } @@ -4433,7 +4505,7 @@ namespace ts { return result; } - function typeRelatedToUnionType(source: Type, target: UnionType, reportErrors: boolean): Ternary { + function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { let targetTypes = target.types; for (let i = 0, len = targetTypes.length; i < len; i++) { let related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -4444,7 +4516,31 @@ namespace ts { return Ternary.False; } - function unionTypeRelatedToType(source: UnionType, target: Type, reportErrors: boolean): Ternary { + function typeRelatedToEachType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { + let result = Ternary.True; + let targetTypes = target.types; + for (let targetType of targetTypes) { + let related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return Ternary.False; + } + result &= related; + } + return result; + } + + function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { + let sourceTypes = source.types; + for (let i = 0, len = sourceTypes.length; i < len; i++) { + let related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return Ternary.False; + } + + function eachTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { let result = Ternary.True; let sourceTypes = source.types; for (let sourceType of sourceTypes) { @@ -5284,9 +5380,9 @@ namespace ts { inferiority--; } } - else if (source.flags & TypeFlags.Union) { - // Source is a union type, infer from each consituent type - let sourceTypes = (source).types; + else if (source.flags & TypeFlags.UnionOrIntersection) { + // Source is a union or intersection type, infer from each consituent type + let sourceTypes = (source).types; for (let sourceType of sourceTypes) { inferFromTypes(sourceType, target); } @@ -6245,7 +6341,7 @@ namespace ts { } function getIndexTypeOfContextualType(type: Type, kind: IndexKind) { - return applyToContextualType(type, t => getIndexTypeOfObjectOrUnionType(t, kind)); + return applyToContextualType(type, t => getIndexTypeOfStructuredType(t, kind)); } // Return true if the given contextual type is a tuple-like type @@ -6255,7 +6351,7 @@ namespace ts { // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type: Type, kind: IndexKind): boolean { - return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfObjectOrUnionType(t, kind)) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfStructuredType(t, kind)) : getIndexTypeOfStructuredType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of @@ -6363,7 +6459,7 @@ namespace ts { // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type: Type): Signature { - let signatures = getSignaturesOfObjectOrUnionType(type, SignatureKind.Call); + let signatures = getSignaturesOfStructuredType(type, SignatureKind.Call); if (signatures.length === 1) { let signature = signatures[0]; if (!signature.typeParameters) { @@ -6405,7 +6501,7 @@ namespace ts { // The signature set of all constituent type with call signatures should match // So number of signatures allowed is either 0 or 1 if (signatureList && - getSignaturesOfObjectOrUnionType(current, SignatureKind.Call).length > 1) { + getSignaturesOfStructuredType(current, SignatureKind.Call).length > 1) { return undefined; } @@ -7081,7 +7177,7 @@ namespace ts { // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type: Type): Signature { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -8028,7 +8124,7 @@ namespace ts { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.Union) { + if (type.flags & TypeFlags.UnionOrIntersection) { let types = (type).types; for (let current of types) { if (current.flags & kind) { @@ -8040,12 +8136,12 @@ namespace ts { return false; } - // Return true if type has the given flags, or is a union type composed of types that all have those flags. + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. function allConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.Union) { + if (type.flags & TypeFlags.UnionOrIntersection) { let types = (type).types; for (let current of types) { if (!(current.flags & kind)) { @@ -9048,7 +9144,7 @@ namespace ts { forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node: UnionTypeNode) { + function checkUnionOrIntersectionType(node: UnionOrIntersectionTypeNode) { forEach(node.types, checkSourceElement); } @@ -11464,7 +11560,8 @@ namespace ts { case SyntaxKind.TupleType: return checkTupleType(node); case SyntaxKind.UnionType: - return checkUnionType(node); + case SyntaxKind.IntersectionType: + return checkUnionOrIntersectionType(node); case SyntaxKind.ParenthesizedType: return checkSourceElement((node).type); case SyntaxKind.FunctionDeclaration: @@ -12092,10 +12189,10 @@ namespace ts { } function getRootSymbols(symbol: Symbol): Symbol[] { - if (symbol.flags & SymbolFlags.UnionProperty) { + if (symbol.flags & SymbolFlags.SyntheticProperty) { let symbols: Symbol[] = []; let name = symbol.name; - forEach(getSymbolLinks(symbol).unionType.types, t => { + forEach(getSymbolLinks(symbol).containingType.types, t => { symbols.push(getPropertyOfType(t, name)); }); return symbols; @@ -12392,6 +12489,7 @@ namespace ts { case SyntaxKind.TypeQuery: case SyntaxKind.TypeLiteral: case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: case SyntaxKind.AnyKeyword: break; default: diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 2ba88f1ac295e..7f1d61d73c56c 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -341,6 +341,8 @@ namespace ts { return emitTupleType(type); case SyntaxKind.UnionType: return emitUnionType(type); + case SyntaxKind.IntersectionType: + return emitIntersectionType(type); case SyntaxKind.ParenthesizedType: return emitParenType(type); case SyntaxKind.FunctionType: @@ -417,6 +419,10 @@ namespace ts { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type: IntersectionTypeNode) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type: ParenthesizedTypeNode) { write("("); emitType(type.type); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fbb3dad5037b8..d77b7a7a5dded 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -115,7 +115,8 @@ namespace ts { case SyntaxKind.TupleType: return visitNodes(cbNodes, (node).elementTypes); case SyntaxKind.UnionType: - return visitNodes(cbNodes, (node).types); + case SyntaxKind.IntersectionType: + return visitNodes(cbNodes, (node).types); case SyntaxKind.ParenthesizedType: return visitNode(cbNode, (node).type); case SyntaxKind.ObjectBindingPattern: @@ -2353,22 +2354,30 @@ namespace ts { return type; } - function parseUnionTypeOrHigher(): TypeNode { - let type = parseArrayTypeOrHigher(); - if (token === SyntaxKind.BarToken) { + function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { + let type = parseConstituentType(); + if (token === operator) { let types = >[type]; types.pos = type.pos; - while (parseOptional(SyntaxKind.BarToken)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - let node = createNode(SyntaxKind.UnionType, type.pos); + let node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher(): TypeNode { + return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseArrayTypeOrHigher, SyntaxKind.AmpersandToken); + } + + function parseUnionTypeOrHigher(): TypeNode { + return parseUnionOrIntersectionType(SyntaxKind.UnionType, parseIntersectionTypeOrHigher, SyntaxKind.BarToken); + } + function isStartOfFunctionType(): boolean { if (token === SyntaxKind.LessThanToken) { return true; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f9a2fa3b7b434..460cd73af5090 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -187,6 +187,7 @@ namespace ts { ArrayType, TupleType, UnionType, + IntersectionType, ParenthesizedType, // Binding patterns ObjectBindingPattern, @@ -634,10 +635,14 @@ namespace ts { elementTypes: NodeArray; } - export interface UnionTypeNode extends TypeNode { + export interface UnionOrIntersectionTypeNode extends TypeNode { types: NodeArray; } + export interface UnionTypeNode extends UnionOrIntersectionTypeNode { } + + export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { } + export interface ParenthesizedTypeNode extends TypeNode { type: TypeNode; } @@ -1479,7 +1484,7 @@ namespace ts { Merged = 0x02000000, // Merged symbol (created during program binding) Transient = 0x04000000, // Transient symbol (created during type check) Prototype = 0x08000000, // Prototype property (no source representation) - UnionProperty = 0x10000000, // Property in union type + SyntheticProperty = 0x10000000, // Property in union or intersection type Optional = 0x20000000, // Optional property ExportStar = 0x40000000, // Export * declaration @@ -1558,7 +1563,7 @@ namespace ts { instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value - unionType?: UnionType; // Containing union type for union property + containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration @@ -1620,17 +1625,18 @@ namespace ts { Interface = 0x00000800, // Interface Reference = 0x00001000, // Generic type reference Tuple = 0x00002000, // Tuple - Union = 0x00004000, // Union - Anonymous = 0x00008000, // Anonymous - Instantiated = 0x00010000, // Instantiated anonymous type + Union = 0x00004000, // Union (T | U) + Intersection = 0x00008000, // Intersection (T & U) + Anonymous = 0x00010000, // Anonymous + Instantiated = 0x00020000, // Instantiated anonymous type /* @internal */ - FromSignature = 0x00020000, // Created for signature assignment check - ObjectLiteral = 0x00040000, // Originates in an object literal + FromSignature = 0x00040000, // Created for signature assignment check + ObjectLiteral = 0x00080000, // Originates in an object literal /* @internal */ - ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type + ContainsUndefinedOrNull = 0x00100000, // Type is or contains Undefined or Null type /* @internal */ - ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type - ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6 + ContainsObjectLiteral = 0x00200000, // Type is or contains object literal type + ESSymbol = 0x00400000, // Type of symbol primitive introduced in ES6 /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1639,6 +1645,8 @@ namespace ts { StringLike = String | StringLiteral, NumberLike = Number | Enum, ObjectType = Class | Interface | Reference | Tuple | Anonymous, + UnionOrIntersection = Union | Intersection, + StructuredType = ObjectType | Union | Intersection, /* @internal */ RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral } @@ -1698,7 +1706,7 @@ namespace ts { baseArrayType: TypeReference; // Array where T is best common type of element types } - export interface UnionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ reducedType: Type; // Reduced union type (all subtypes removed) @@ -1706,9 +1714,13 @@ namespace ts { resolvedProperties: SymbolTable; // Cache of resolved properties } + export interface UnionType extends UnionOrIntersectionType { } + + export interface IntersectionType extends UnionOrIntersectionType { } + /* @internal */ - // Resolved object or union type - export interface ResolvedType extends ObjectType, UnionType { + // Resolved object, union, or intersection type + export interface ResolvedType extends ObjectType, UnionOrIntersectionType { members: SymbolTable; // Properties by name properties: Symbol[]; // Properties callSignatures: Signature[]; // Call signatures of type diff --git a/src/services/services.ts b/src/services/services.ts index 70022cfe0bf47..9fda4d6db37e0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3576,7 +3576,7 @@ namespace ts { if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; if (flags & SymbolFlags.Property) { - if (flags & SymbolFlags.UnionProperty) { + if (flags & SymbolFlags.SyntheticProperty) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property let unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { let rootSymbolFlags = rootSymbol.getFlags(); @@ -5078,7 +5078,7 @@ namespace ts { // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & SymbolFlags.UnionProperty)) { + if (symbol.parent || (symbol.flags & SymbolFlags.SyntheticProperty)) { return undefined; } From d2955e8a857925aa6384b6cb5ba93c1d7c0172e9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 24 Jun 2015 17:53:33 -0700 Subject: [PATCH 149/250] Accepting new baselines --- tests/baselines/reference/APISample_linter.js | 20 +++++++++---------- .../typeParameterExtendingUnion1.symbols | 4 ++-- .../typeParameterExtendingUnion2.symbols | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 9b2675535f22e..5c2a8953a6123 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: - if (node.statement.kind !== 182 /* Block */) { + case 190 /* ForStatement */: + case 191 /* ForInStatement */: + case 189 /* WhileStatement */: + case 188 /* DoStatement */: + if (node.statement.kind !== 183 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 186 /* IfStatement */: + case 187 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 182 /* Block */) { + if (ifStatement.thenStatement.kind !== 183 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 182 /* Block */ && - ifStatement.elseStatement.kind !== 186 /* IfStatement */) { + ifStatement.elseStatement.kind !== 183 /* Block */ && + ifStatement.elseStatement.kind !== 187 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 172 /* BinaryExpression */: + case 173 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.symbols b/tests/baselines/reference/typeParameterExtendingUnion1.symbols index 39b67e6428cc9..97d900b5d5ef0 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion1.symbols @@ -33,9 +33,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.symbols b/tests/baselines/reference/typeParameterExtendingUnion2.symbols index 44d47692a82bc..21866b3df9244 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion2.symbols @@ -20,9 +20,9 @@ function run(a: Cat | Dog) { >Dog : Symbol(Dog, Decl(typeParameterExtendingUnion2.ts, 1, 33)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 4, 13)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) } function f(a: T) { @@ -34,9 +34,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion2.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 2, 33)) From d5710349a29041290d2d2ce9e875e03c18fd79ae Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 24 Jun 2015 17:53:43 -0700 Subject: [PATCH 150/250] Adding tests --- .../intersectionAndUnionTypes.errors.txt | 162 ++++++++++++++++++ .../reference/intersectionAndUnionTypes.js | 72 ++++++++ .../reference/intersectionTypeEquivalence.js | 31 ++++ .../intersectionTypeEquivalence.symbols | 63 +++++++ .../intersectionTypeEquivalence.types | 63 +++++++ .../intersectionTypeInference.errors.txt | 27 +++ .../reference/intersectionTypeInference.js | 28 +++ .../reference/intersectionTypeMembers.js | 44 +++++ .../reference/intersectionTypeMembers.symbols | 100 +++++++++++ .../reference/intersectionTypeMembers.types | 116 +++++++++++++ .../recursiveIntersectionTypes.errors.txt | 32 ++++ .../reference/recursiveIntersectionTypes.js | 31 ++++ .../intersection/intersectionAndUnionTypes.ts | 38 ++++ .../intersectionTypeEquivalence.ts | 16 ++ .../intersection/intersectionTypeInference.ts | 13 ++ .../intersection/intersectionTypeMembers.ts | 27 +++ .../recursiveIntersectionTypes.ts | 19 ++ 17 files changed, 882 insertions(+) create mode 100644 tests/baselines/reference/intersectionAndUnionTypes.errors.txt create mode 100644 tests/baselines/reference/intersectionAndUnionTypes.js create mode 100644 tests/baselines/reference/intersectionTypeEquivalence.js create mode 100644 tests/baselines/reference/intersectionTypeEquivalence.symbols create mode 100644 tests/baselines/reference/intersectionTypeEquivalence.types create mode 100644 tests/baselines/reference/intersectionTypeInference.errors.txt create mode 100644 tests/baselines/reference/intersectionTypeInference.js create mode 100644 tests/baselines/reference/intersectionTypeMembers.js create mode 100644 tests/baselines/reference/intersectionTypeMembers.symbols create mode 100644 tests/baselines/reference/intersectionTypeMembers.types create mode 100644 tests/baselines/reference/recursiveIntersectionTypes.errors.txt create mode 100644 tests/baselines/reference/recursiveIntersectionTypes.js create mode 100644 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeInference.ts create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeMembers.ts create mode 100644 tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts diff --git a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt new file mode 100644 index 0000000000000..4f26cc63ba3f2 --- /dev/null +++ b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt @@ -0,0 +1,162 @@ +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(19,1): error TS2322: Type 'A' is not assignable to type 'A & B'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(20,1): error TS2322: Type 'B' is not assignable to type 'A & B'. + Type 'B' is not assignable to type 'A'. + Property 'a' is missing in type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(23,1): error TS2322: Type 'A | B' is not assignable to type '(A & B) | (C & D)'. + Type 'A' is not assignable to type '(A & B) | (C & D)'. + Type 'A' is not assignable to type 'C & D'. + Type 'A' is not assignable to type 'C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(25,1): error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. + Type 'C' is not assignable to type '(A & B) | (C & D)'. + Type 'C' is not assignable to type 'C & D'. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(26,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. + Type 'C & D' is not assignable to type 'A & B'. + Type 'C & D' is not assignable to type 'A'. + Type 'D' is not assignable to type 'A'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(27,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'B'. + Type 'D' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(28,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. + Type 'A & B' is not assignable to type 'C & D'. + Type 'A & B' is not assignable to type 'C'. + Type 'B' is not assignable to type 'C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'D'. + Type 'B' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. + Type 'A & B' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'D'. + Type 'B' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. + Type 'A' is not assignable to type '(A | B) & (C | D)'. + Type 'A' is not assignable to type 'C | D'. + Type 'A' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. + Type 'C & D' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'B'. + Type 'D' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. + Type 'C' is not assignable to type '(A | B) & (C | D)'. + Type 'C' is not assignable to type 'A | B'. + Type 'C' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. + Type '(A | B) & (C | D)' is not assignable to type 'A'. + Type 'C | D' is not assignable to type 'A'. + Type 'C' is not assignable to type 'A'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. + Type '(A | B) & (C | D)' is not assignable to type 'C'. + Type 'C | D' is not assignable to type 'C'. + Type 'D' is not assignable to type 'C'. + + +==== tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts (14 errors) ==== + interface A { a: string } + interface B { b: string } + interface C { c: string } + interface D { d: string } + + var a: A; + var b: B; + var c: C; + var d: D; + var anb: A & B; + var aob: A | B; + var cnd: C & D; + var cod: C | D; + var x: A & B | C & D; + var y: (A | B) & (C | D); + + a = anb; // Ok + b = anb; // Ok + anb = a; + ~~~ +!!! error TS2322: Type 'A' is not assignable to type 'A & B'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. + anb = b; + ~~~ +!!! error TS2322: Type 'B' is not assignable to type 'A & B'. +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type 'B'. + + x = anb; // Ok + x = aob; + ~ +!!! error TS2322: Type 'A | B' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'A' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A' is not assignable to type 'C'. + x = cnd; // Ok + x = cod; + ~ +!!! error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'C' is not assignable to type 'C & D'. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + anb = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A & B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A'. +!!! error TS2322: Type 'D' is not assignable to type 'A'. + aob = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Type 'D' is not assignable to type 'B'. + cnd = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C'. +!!! error TS2322: Type 'B' is not assignable to type 'C'. + cod = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Type 'B' is not assignable to type 'D'. + + y = anb; + ~ +!!! error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Type 'B' is not assignable to type 'D'. + y = aob; + ~ +!!! error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A' is not assignable to type 'D'. + y = cnd; + ~ +!!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Type 'D' is not assignable to type 'B'. + y = cod; + ~ +!!! error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C' is not assignable to type 'B'. + anb = y; + ~~~ +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A'. +!!! error TS2322: Type 'C | D' is not assignable to type 'A'. +!!! error TS2322: Type 'C' is not assignable to type 'A'. + aob = y; // Ok + cnd = y; + ~~~ +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C'. +!!! error TS2322: Type 'C | D' is not assignable to type 'C'. +!!! error TS2322: Type 'D' is not assignable to type 'C'. + cod = y; // Ok + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionAndUnionTypes.js b/tests/baselines/reference/intersectionAndUnionTypes.js new file mode 100644 index 0000000000000..ec0adaab8b81e --- /dev/null +++ b/tests/baselines/reference/intersectionAndUnionTypes.js @@ -0,0 +1,72 @@ +//// [intersectionAndUnionTypes.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +var a: A; +var b: B; +var c: C; +var d: D; +var anb: A & B; +var aob: A | B; +var cnd: C & D; +var cod: C | D; +var x: A & B | C & D; +var y: (A | B) & (C | D); + +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; + +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; + +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok + + +//// [intersectionAndUnionTypes.js] +var a; +var b; +var c; +var d; +var anb; +var aob; +var cnd; +var cod; +var x; +var y; +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok diff --git a/tests/baselines/reference/intersectionTypeEquivalence.js b/tests/baselines/reference/intersectionTypeEquivalence.js new file mode 100644 index 0000000000000..be04bfe79471e --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.js @@ -0,0 +1,31 @@ +//// [intersectionTypeEquivalence.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } + +// A & B is equivalent to B & A. +var y: A & B; +var y : B & A; + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +var z : (A & B) & C; +var z : A & (B & C); +var ab : A & B; +var bc : B & C; +var z1: typeof ab & C; +var z1: A & typeof bc; + + +//// [intersectionTypeEquivalence.js] +// A & B is equivalent to B & A. +var y; +var y; +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z; +var z; +var z; +var ab; +var bc; +var z1; +var z1; diff --git a/tests/baselines/reference/intersectionTypeEquivalence.symbols b/tests/baselines/reference/intersectionTypeEquivalence.symbols new file mode 100644 index 0000000000000..2bec452c44ec8 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts === +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeEquivalence.ts, 0, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>b : Symbol(b, Decl(intersectionTypeEquivalence.ts, 1, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) +>c : Symbol(c, Decl(intersectionTypeEquivalence.ts, 2, 13)) + +// A & B is equivalent to B & A. +var y: A & B; +>y : Symbol(y, Decl(intersectionTypeEquivalence.ts, 5, 3), Decl(intersectionTypeEquivalence.ts, 6, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) + +var y : B & A; +>y : Symbol(y, Decl(intersectionTypeEquivalence.ts, 5, 3), Decl(intersectionTypeEquivalence.ts, 6, 3)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z : (A & B) & C; +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z : A & (B & C); +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var ab : A & B; +>ab : Symbol(ab, Decl(intersectionTypeEquivalence.ts, 12, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) + +var bc : B & C; +>bc : Symbol(bc, Decl(intersectionTypeEquivalence.ts, 13, 3)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z1: typeof ab & C; +>z1 : Symbol(z1, Decl(intersectionTypeEquivalence.ts, 14, 3), Decl(intersectionTypeEquivalence.ts, 15, 3)) +>ab : Symbol(ab, Decl(intersectionTypeEquivalence.ts, 12, 3)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z1: A & typeof bc; +>z1 : Symbol(z1, Decl(intersectionTypeEquivalence.ts, 14, 3), Decl(intersectionTypeEquivalence.ts, 15, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>bc : Symbol(bc, Decl(intersectionTypeEquivalence.ts, 13, 3)) + diff --git a/tests/baselines/reference/intersectionTypeEquivalence.types b/tests/baselines/reference/intersectionTypeEquivalence.types new file mode 100644 index 0000000000000..25e175275d7ad --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts === +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +// A & B is equivalent to B & A. +var y: A & B; +>y : A & B +>A : A +>B : B + +var y : B & A; +>y : A & B +>B : B +>A : A + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +>z : A & B & C +>A : A +>B : B +>C : C + +var z : (A & B) & C; +>z : A & B & C +>A : A +>B : B +>C : C + +var z : A & (B & C); +>z : A & B & C +>A : A +>B : B +>C : C + +var ab : A & B; +>ab : A & B +>A : A +>B : B + +var bc : B & C; +>bc : B & C +>B : B +>C : C + +var z1: typeof ab & C; +>z1 : A & B & C +>ab : A & B +>C : C + +var z1: A & typeof bc; +>z1 : A & B & C +>A : A +>bc : B & C + diff --git a/tests/baselines/reference/intersectionTypeInference.errors.txt b/tests/baselines/reference/intersectionTypeInference.errors.txt new file mode 100644 index 0000000000000..33c24e111dcf8 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): error TS2322: Type 'T' is not assignable to type 'T & U'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(7,5): error TS2322: Type 'U' is not assignable to type 'T & U'. + Type 'U' is not assignable to type 'T'. + + +==== tests/cases/conformance/types/intersection/intersectionTypeInference.ts (2 errors) ==== + + function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + ~~~~~~ +!!! error TS2322: Type 'T' is not assignable to type 'T & U'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + result = obj2; // Error + ~~~~~~ +!!! error TS2322: Type 'U' is not assignable to type 'T & U'. +!!! error TS2322: Type 'U' is not assignable to type 'T'. + return result; + } + + var x = extend({ a: "hello" }, { b: 42 }); + var s = x.a; + var n = x.b; + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeInference.js b/tests/baselines/reference/intersectionTypeInference.js new file mode 100644 index 0000000000000..0b95879a6c02a --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference.js @@ -0,0 +1,28 @@ +//// [intersectionTypeInference.ts] + +function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; + + +//// [intersectionTypeInference.js] +function extend(obj1, obj2) { + var result; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; diff --git a/tests/baselines/reference/intersectionTypeMembers.js b/tests/baselines/reference/intersectionTypeMembers.js new file mode 100644 index 0000000000000..9c1cd75d601fa --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.js @@ -0,0 +1,44 @@ +//// [intersectionTypeMembers.ts] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +interface B { b: string } +interface C { c: string } + +var abc: A & B & C; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; + +interface X { x: A } +interface Y { x: B } +interface Z { x: C } + +var xyz: X & Y & Z; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; + +type F1 = (x: string) => string; +type F2 = (x: number) => number; + +var f: F1 & F2; +var s = f("hello"); +var n = f(42); + + +//// [intersectionTypeMembers.js] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types +var abc; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; +var xyz; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; +var f; +var s = f("hello"); +var n = f(42); diff --git a/tests/baselines/reference/intersectionTypeMembers.symbols b/tests/baselines/reference/intersectionTypeMembers.symbols new file mode 100644 index 0000000000000..ebec69b4ebeeb --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.symbols @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeMembers.ts === +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeMembers.ts, 3, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) +>b : Symbol(b, Decl(intersectionTypeMembers.ts, 4, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) +>c : Symbol(c, Decl(intersectionTypeMembers.ts, 5, 13)) + +var abc: A & B & C; +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) + +abc.a = "hello"; +>abc.a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) + +abc.b = "hello"; +>abc.b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) + +abc.c = "hello"; +>abc.c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) + +interface X { x: A } +>X : Symbol(X, Decl(intersectionTypeMembers.ts, 10, 16)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13)) +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) + +interface Y { x: B } +>Y : Symbol(Y, Decl(intersectionTypeMembers.ts, 12, 20)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 13, 13)) +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) + +interface Z { x: C } +>Z : Symbol(Z, Decl(intersectionTypeMembers.ts, 13, 20)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 14, 13)) +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) + +var xyz: X & Y & Z; +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>X : Symbol(X, Decl(intersectionTypeMembers.ts, 10, 16)) +>Y : Symbol(Y, Decl(intersectionTypeMembers.ts, 12, 20)) +>Z : Symbol(Z, Decl(intersectionTypeMembers.ts, 13, 20)) + +xyz.x.a = "hello"; +>xyz.x.a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) + +xyz.x.b = "hello"; +>xyz.x.b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) + +xyz.x.c = "hello"; +>xyz.x.c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) + +type F1 = (x: string) => string; +>F1 : Symbol(F1, Decl(intersectionTypeMembers.ts, 19, 18)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 21, 11)) + +type F2 = (x: number) => number; +>F2 : Symbol(F2, Decl(intersectionTypeMembers.ts, 21, 32)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 22, 11)) + +var f: F1 & F2; +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) +>F1 : Symbol(F1, Decl(intersectionTypeMembers.ts, 19, 18)) +>F2 : Symbol(F2, Decl(intersectionTypeMembers.ts, 21, 32)) + +var s = f("hello"); +>s : Symbol(s, Decl(intersectionTypeMembers.ts, 25, 3)) +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) + +var n = f(42); +>n : Symbol(n, Decl(intersectionTypeMembers.ts, 26, 3)) +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) + diff --git a/tests/baselines/reference/intersectionTypeMembers.types b/tests/baselines/reference/intersectionTypeMembers.types new file mode 100644 index 0000000000000..a97a54c7a8138 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeMembers.ts === +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +var abc: A & B & C; +>abc : A & B & C +>A : A +>B : B +>C : C + +abc.a = "hello"; +>abc.a = "hello" : string +>abc.a : string +>abc : A & B & C +>a : string +>"hello" : string + +abc.b = "hello"; +>abc.b = "hello" : string +>abc.b : string +>abc : A & B & C +>b : string +>"hello" : string + +abc.c = "hello"; +>abc.c = "hello" : string +>abc.c : string +>abc : A & B & C +>c : string +>"hello" : string + +interface X { x: A } +>X : X +>x : A +>A : A + +interface Y { x: B } +>Y : Y +>x : B +>B : B + +interface Z { x: C } +>Z : Z +>x : C +>C : C + +var xyz: X & Y & Z; +>xyz : X & Y & Z +>X : X +>Y : Y +>Z : Z + +xyz.x.a = "hello"; +>xyz.x.a = "hello" : string +>xyz.x.a : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>a : string +>"hello" : string + +xyz.x.b = "hello"; +>xyz.x.b = "hello" : string +>xyz.x.b : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>b : string +>"hello" : string + +xyz.x.c = "hello"; +>xyz.x.c = "hello" : string +>xyz.x.c : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>c : string +>"hello" : string + +type F1 = (x: string) => string; +>F1 : (x: string) => string +>x : string + +type F2 = (x: number) => number; +>F2 : (x: number) => number +>x : number + +var f: F1 & F2; +>f : ((x: string) => string) & ((x: number) => number) +>F1 : (x: string) => string +>F2 : (x: number) => number + +var s = f("hello"); +>s : string +>f("hello") : string +>f : ((x: string) => string) & ((x: number) => number) +>"hello" : string + +var n = f(42); +>n : number +>f(42) : number +>f : ((x: string) => string) & ((x: number) => number) +>42 : number + diff --git a/tests/baselines/reference/recursiveIntersectionTypes.errors.txt b/tests/baselines/reference/recursiveIntersectionTypes.errors.txt new file mode 100644 index 0000000000000..bac97470e5518 --- /dev/null +++ b/tests/baselines/reference/recursiveIntersectionTypes.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts(19,1): error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product & { next: Product & any; }'. + Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product'. + Type '{ next: Entity & any; }' is not assignable to type 'Product'. + Property 'price' is missing in type '{ next: Entity & any; }'. + + +==== tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts (1 errors) ==== + type LinkedList = T & { next: LinkedList }; + + interface Entity { + name: string; + } + + interface Product extends Entity { + price: number; + } + + var entityList: LinkedList; + var s = entityList.name; + var s = entityList.next.name; + var s = entityList.next.next.name; + var s = entityList.next.next.next.name; + + var productList: LinkedList; + entityList = productList; + productList = entityList; // Error + ~~~~~~~~~~~ +!!! error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product & { next: Product & any; }'. +!!! error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product'. +!!! error TS2322: Type '{ next: Entity & any; }' is not assignable to type 'Product'. +!!! error TS2322: Property 'price' is missing in type '{ next: Entity & any; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/recursiveIntersectionTypes.js b/tests/baselines/reference/recursiveIntersectionTypes.js new file mode 100644 index 0000000000000..88b7e6f831b35 --- /dev/null +++ b/tests/baselines/reference/recursiveIntersectionTypes.js @@ -0,0 +1,31 @@ +//// [recursiveIntersectionTypes.ts] +type LinkedList = T & { next: LinkedList }; + +interface Entity { + name: string; +} + +interface Product extends Entity { + price: number; +} + +var entityList: LinkedList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; + +var productList: LinkedList; +entityList = productList; +productList = entityList; // Error + + +//// [recursiveIntersectionTypes.js] +var entityList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; +var productList; +entityList = productList; +productList = entityList; // Error diff --git a/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts b/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts new file mode 100644 index 0000000000000..e6bd671c6b203 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts @@ -0,0 +1,38 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +var a: A; +var b: B; +var c: C; +var d: D; +var anb: A & B; +var aob: A | B; +var cnd: C & D; +var cod: C | D; +var x: A & B | C & D; +var y: (A | B) & (C | D); + +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; + +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; + +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok diff --git a/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts b/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts new file mode 100644 index 0000000000000..fce399eff94c1 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts @@ -0,0 +1,16 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } + +// A & B is equivalent to B & A. +var y: A & B; +var y : B & A; + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +var z : (A & B) & C; +var z : A & (B & C); +var ab : A & B; +var bc : B & C; +var z1: typeof ab & C; +var z1: A & typeof bc; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeInference.ts b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts new file mode 100644 index 0000000000000..3126ce09448b5 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts @@ -0,0 +1,13 @@ + +function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts new file mode 100644 index 0000000000000..a8c92647f479e --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts @@ -0,0 +1,27 @@ +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +interface B { b: string } +interface C { c: string } + +var abc: A & B & C; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; + +interface X { x: A } +interface Y { x: B } +interface Z { x: C } + +var xyz: X & Y & Z; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; + +type F1 = (x: string) => string; +type F2 = (x: number) => number; + +var f: F1 & F2; +var s = f("hello"); +var n = f(42); diff --git a/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts b/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts new file mode 100644 index 0000000000000..d741d30ac1f73 --- /dev/null +++ b/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts @@ -0,0 +1,19 @@ +type LinkedList = T & { next: LinkedList }; + +interface Entity { + name: string; +} + +interface Product extends Entity { + price: number; +} + +var entityList: LinkedList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; + +var productList: LinkedList; +entityList = productList; +productList = entityList; // Error From f8b95a5acf5162ca6e35328e67aaf7852657c6a8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 25 Jun 2015 10:41:39 -0700 Subject: [PATCH 151/250] Drafting constructor assignability restrictions --- src/compiler/checker.ts | 14 ++++++++++++++ src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc23103403eab..9c810809f0f62 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4553,6 +4553,9 @@ namespace ts { result &= stringIndexTypesRelatedTo(source, target, reportErrors); if (result) { result &= numberIndexTypesRelatedTo(source, target, reportErrors); + // if(relation == subtypeRelation && result) { + // result &= abstractnessRelatedTo(source, target, reportErrors); + // } } } } @@ -4574,6 +4577,17 @@ namespace ts { return result; } + function abstractnessRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + if ( source.symbol && target.symbol && getDeclarationFlagsFromSymbol(source.symbol) & NodeFlags.Abstract && + !(getDeclarationFlagsFromSymbol(target.symbol) & NodeFlags.Abstract)) { + if (reportErrors) { + reportError(Diagnostics.Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type); + } + return Ternary.False; + } + return Ternary.True; + } + function propertiesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 853ee81359c51..89c6e8bf10973 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -399,6 +399,7 @@ namespace ts { Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, 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 3605bae69006a..fa50f5cdcc534 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1583,6 +1583,10 @@ "category": "Error", "code": 2516 }, + "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": { + "category": "Error", + "code":2517 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From 8180b7d06f6389783fd62e508683c7608475d3be Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 25 Jun 2015 11:14:45 -0700 Subject: [PATCH 152/250] Don't error on JSX elements when JSX.Element isn't present --- src/compiler/checker.ts | 12 +- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../reference/jsxAndTypeAssertion.errors.txt | 69 +--- .../jsxEsprimaFbTestSuite.errors.txt | 131 ------- .../reference/jsxEsprimaFbTestSuite.symbols | 92 +++++ .../reference/jsxEsprimaFbTestSuite.types | 160 +++++++++ .../jsxInvalidEsprimaTestSuite.errors.txt | 92 +---- .../reference/jsxReactTestSuite.errors.txt | 246 ------------- .../reference/jsxReactTestSuite.symbols | 194 ++++++++++ .../reference/jsxReactTestSuite.types | 332 ++++++++++++++++++ .../reference/tsxElementResolution.errors.txt | 40 --- .../reference/tsxElementResolution.symbols | 51 +++ .../reference/tsxElementResolution.types | 56 +++ .../tsxElementResolution16.errors.txt | 11 +- .../reference/tsxElementResolution16.js | 4 +- .../reference/tsxElementResolution16.symbols | 18 + .../reference/tsxElementResolution16.types | 20 ++ tests/baselines/reference/tsxNoJsx.errors.txt | 9 - tests/baselines/reference/tsxNoJsx.symbols | 5 + tests/baselines/reference/tsxNoJsx.types | 6 + .../reference/tsxTypeErrors.errors.txt | 55 --- .../baselines/reference/tsxTypeErrors.symbols | 65 ++++ tests/baselines/reference/tsxTypeErrors.types | 82 +++++ .../jsx/tsxElementResolution16.tsx | 3 +- .../conformance/jsx/tsxInArrowFunction.tsx | 23 ++ 26 files changed, 1126 insertions(+), 654 deletions(-) delete mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt create mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.symbols create mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.types delete mode 100644 tests/baselines/reference/jsxReactTestSuite.errors.txt create mode 100644 tests/baselines/reference/jsxReactTestSuite.symbols create mode 100644 tests/baselines/reference/jsxReactTestSuite.types delete mode 100644 tests/baselines/reference/tsxElementResolution.errors.txt create mode 100644 tests/baselines/reference/tsxElementResolution.symbols create mode 100644 tests/baselines/reference/tsxElementResolution.types create mode 100644 tests/baselines/reference/tsxElementResolution16.symbols create mode 100644 tests/baselines/reference/tsxElementResolution16.types delete mode 100644 tests/baselines/reference/tsxNoJsx.errors.txt create mode 100644 tests/baselines/reference/tsxNoJsx.symbols create mode 100644 tests/baselines/reference/tsxNoJsx.types delete mode 100644 tests/baselines/reference/tsxTypeErrors.errors.txt create mode 100644 tests/baselines/reference/tsxTypeErrors.symbols create mode 100644 tests/baselines/reference/tsxTypeErrors.types create mode 100644 tests/cases/conformance/jsx/tsxInArrowFunction.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dd3b29f25e399..101b8ceb23c1d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3800,7 +3800,7 @@ namespace ts { function getExportedTypeFromNamespace(namespace: string, name: string): Type { var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); - return (typeSymbol && getDeclaredTypeOfSymbol(typeSymbol)) || unknownType; + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } function getGlobalESSymbolConstructorSymbol() { @@ -6712,7 +6712,7 @@ namespace ts { function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { checkJsxOpeningLikeElement(node); - return jsxElementType; + return jsxElementType || anyType; } function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean { @@ -6755,7 +6755,7 @@ namespace ts { } } - return jsxElementType; + return jsxElementType || anyType; } /** @@ -7087,8 +7087,10 @@ namespace ts { error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === unknownType) { - error(errorNode, Diagnostics.The_global_type_JSX_Element_must_exist_when_using_JSX); + if (jsxElementType === undefined) { + if(compilerOptions.noImplicitAny) { + error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 0d90897359479..674d683190408 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -391,7 +391,7 @@ namespace ts { Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, - The_global_type_JSX_Element_must_exist_when_using_JSX: { code: 2602, category: DiagnosticCategory.Error, key: "The global type 'JSX.Element' must exist when using JSX." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 21e352af339ec..468f162ce3f78 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1554,7 +1554,7 @@ "category": "Error", "code": 2601 }, - "The global type 'JSX.Element' must exist when using JSX.": { + "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist.": { "category": "Error", "code": 2602 }, diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt index ead030952a517..aebabf15133e8 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -1,34 +1,14 @@ -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,13): error TS2304: Cannot find name 'test'. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,17): error TS1005: '}' expected. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,19): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(9,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(9,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,17): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,32): error TS1005: '}' expected. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,16): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,36): error TS1005: '}' expected. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,16): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,31): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,45): error TS1005: '}' expected. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(17,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(17,23): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,7): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,12): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,34): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,39): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,53): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(19,58): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS1005: ':' expected. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'any'. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'foo'. -==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (28 errors) ==== +==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (8 errors) ==== declare var createElement: any; @@ -36,78 +16,31 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expect var x: any; x = { test: }; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~ !!! error TS2304: Cannot find name 'test'. ~ !!! error TS1005: '}' expected. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. x = ; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. x = hello {{}} ; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '}' expected. x = {}}>hello; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '}' expected. x = {}}>hello{{}}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '}' expected. - x = x, x = ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {{/foo/.test(x) ? : }} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ~~~~ - -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. !!! error TS1005: ':' expected. diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt deleted file mode 100644 index b6c083e33096f..0000000000000 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt +++ /dev/null @@ -1,131 +0,0 @@ -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(9,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(18,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(21,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(23,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(29,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(29,11): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(29,19): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(31,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(33,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(35,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(37,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(37,6): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,17): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,29): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(43,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(45,2): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(47,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(49,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(51,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(53,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. - - -==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (24 errors) ==== - declare var React: any; - declare var 日本語; - declare var AbC_def; - declare var LeftRight; - declare var x; - declare var a; - declare var props; - - ; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - //; Namespace unsuported - - // {value} ; Namespace unsuported - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ; - ~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - <日本語>; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - bar - baz - ; - - : } />; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - {}; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
{/* this is a comment */}; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
@test content
; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -

7x invalid-js-identifier
; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - right=monkeys /> gorillas />; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - (
) < x; - ~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - \ No newline at end of file diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols new file mode 100644 index 0000000000000..570bf89f0a4c2 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols @@ -0,0 +1,92 @@ +=== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx === +declare var React: any; +>React : Symbol(React, Decl(jsxEsprimaFbTestSuite.tsx, 0, 11)) + +declare var 日本語; +>日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) + +declare var AbC_def; +>AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) + +declare var LeftRight; +>LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) + +declare var x; +>x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) + +declare var a; +>a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11)) + +declare var props; +>props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11)) + +; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; +>b : Symbol(unknown) +>c : Symbol(unknown) +>d : Symbol(unknown) +>e : Symbol(unknown) +>f : Symbol(unknown) +>g : Symbol(unknown) +>h : Symbol(unknown) + +; +>b : Symbol(unknown) + +; + +<日本語>; + +AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) + + test="&&"> +>test : Symbol(unknown) + +bar +baz +; + + : } />; +>b : Symbol(unknown) +>x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; +>LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) +>left : Symbol(unknown) +>right : Symbol(unknown) + +; +>b : Symbol(unknown) + +; +>c : Symbol(unknown) + +(
) < x; +>x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) + +
; + +
; +>post : Symbol(unknown) + +
; +>pre : Symbol(unknown) +>pre2 : Symbol(unknown) + + ; + diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.types b/tests/baselines/reference/jsxEsprimaFbTestSuite.types new file mode 100644 index 0000000000000..f32d62fd03f66 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.types @@ -0,0 +1,160 @@ +=== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx === +declare var React: any; +>React : any + +declare var 日本語; +>日本語 : any + +declare var AbC_def; +>AbC_def : any + +declare var LeftRight; +>LeftRight : any + +declare var x; +>x : any + +declare var a; +>a : any + +declare var props; +>props : any + +; +> : any +>a : any + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; +> : any +>a : any +>b : any +>c : any +>d : any +>e : any +>f : any +>g : any +>h : any + +; +> : any +>a : any +>b : any + + : any +>a : any + +/>; + +<日本語>; +><日本語> : any +>日本語 : any +>日本語 : any + +barbaz : any +>AbC_def : any + + test="&&"> +>test : any + +bar +baz +; +>AbC_def : any + + : } />; +> : } /> : any +>a : any +>b : any +>x ? : : any +>x : any +> : any +>c : any +> : any +>d : any + +{}; +>
{} : any +>a : any +>a : any + +{/* this is a comment */}; +>{/* this is a comment */} : any +>a : any +>a : any + +
@test content
; +>
@test content
: any +>div : any +>div : any + +

7x invalid-js-identifier
; +>

7x invalid-js-identifier
: any +>div : any +>
: any +>br : any +>div : any + + right=monkeys /> gorillas />; +> right=monkeys /> gorillas /> : any +>LeftRight : any +>left : any +> : any +>a : any +>right : any +>monkeys /> gorillas : any +>b : any +>b : any + +; +> : any +>a : any +>b : any +>a : any +>b : any + +; +> : any +>a : any +>b : any +>c : any +>a : any +>b : any +>c : any + +(
) < x; +>(
) < x : boolean +>(
) : any +>
: any +>div : any +>x : any + +
; +>
: any +>div : any +>props : any + +
; +>
: any +>div : any +>props : any +>post : any + +
; +>
: any +>div : any +>pre : any +>pre2 : any +>props : any +>div : any + + ; +>
: any +>a : any +>a : any + diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index f509044703a32..e63809913f224 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -1,14 +1,12 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1128: Declaration or statement expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,4): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,3): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,6): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,7): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS1005: '{' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS2304: Cannot find name 'd'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,9): error TS1109: Expression expected. @@ -16,9 +14,7 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,10): error TS1109: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,4): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,4): error TS17002: Expected corresponding JSX closing tag for 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,13): error TS1002: Unterminated string literal. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,2): error TS2304: Cannot find name 'a'. @@ -27,19 +23,16 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2304: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,8): error TS2304: Cannot find name 'b'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,10): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,12): error TS2304: Cannot find name 'b'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,16): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,14): error TS2304: Cannot find name 'c'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,16): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS1109: Expression expected. @@ -48,59 +41,36 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,5): error TS1109: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1128: Declaration or statement expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,8): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,10): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,9): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,13): error TS2304: Cannot find name 'foo'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,18): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,11): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,22): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,4): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(19,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(20,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(20,23): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(21,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(21,50): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,10): error TS1005: '}' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,20): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,15): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS1005: '...' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS2304: Cannot find name 'props'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,17): error TS1005: '>' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,18): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: Cannot find name 'props'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,29): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(30,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(31,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(34,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002: Expected corresponding JSX closing tag for 'a'. -==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (100 errors) ==== +==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (70 errors) ==== declare var React: any; ; @@ -111,8 +81,6 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ~ !!! error TS1109: Expression expected. ; - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1003: Identifier expected. <:a />; @@ -127,8 +95,6 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ~ !!! error TS1109: Expression expected. ; - ~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '{' expected. ~ @@ -145,13 +111,9 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ~ !!! error TS1109: Expression expected. ; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~ !!! error TS17002: Expected corresponding JSX closing tag for 'a'. ; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '}' expected. ; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1003: Identifier expected.
; - ~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~~ !!! error TS1003: Identifier expected.
; - ~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~~ !!! error TS1005: '...' expected. ~~~~~ !!! error TS2304: Cannot find name 'props'.
stuff
; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '>' expected. ~~~ !!! error TS1109: Expression expected.
stuff
; - ~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~~~ !!! error TS2304: Cannot find name 'props'. ~ @@ -309,29 +233,15 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 !!! error TS1109: Expression expected.
>; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. >; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ; - ~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1005: '{' expected. ; - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~ !!! error TS1003: Identifier expected. }; - ~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ; - ~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. ~~~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/jsxReactTestSuite.errors.txt b/tests/baselines/reference/jsxReactTestSuite.errors.txt deleted file mode 100644 index 4e9e5c42492d2..0000000000000 --- a/tests/baselines/reference/jsxReactTestSuite.errors.txt +++ /dev/null @@ -1,246 +0,0 @@ -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(15,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(17,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(21,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(22,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(22,8): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(23,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(23,19): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(24,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(28,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(32,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(33,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(37,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(55,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(58,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(62,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(69,3): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(73,5): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(79,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(81,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(83,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(85,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(87,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(89,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(91,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(94,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(97,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(99,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(101,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(103,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(105,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(107,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(109,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(112,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(112,38): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/jsxReactTestSuite.tsx(114,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. - - -==== tests/cases/conformance/jsx/jsxReactTestSuite.tsx (35 errors) ==== - - declare var React: any; - declare var Component:any; - declare var Composite:any; - declare var Composite2:any; - declare var Child:any; - declare var Namespace:any; - declare var foo: any; - declare var bar: any; - declare var y:any; - declare var x:any; - declare var z:any; - declare var hasOwnProperty:any; - -
text
; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
- ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {this.props.children} -
; - -
- ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. -

- ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {foo}
{bar}
- ~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. -
- ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. -
; - - - - ~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {this.props.children} - ; - - - ~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ; - - var x = -
- ~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. -
; - - ( -
- ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {/* A comment at the beginning */} - {/* A second comment at the beginning */} - - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {/* A nested comment */} - - {/* A sandwiched comment */} -
- ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - {/* A comment at the end */} - {/* A second comment at the end */} -
- ); - - ( -
- ~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. -
- ); - -
 
; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - -
 
; - ~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - testing; - ~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - - ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - ~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - Text; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - - \ No newline at end of file diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols new file mode 100644 index 0000000000000..9e382742f0d4b --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/jsxReactTestSuite.tsx === + +declare var React: any; +>React : Symbol(React, Decl(jsxReactTestSuite.tsx, 1, 11)) + +declare var Component:any; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +declare var Composite:any; +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + +declare var Composite2:any; +>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) + +declare var Child:any; +>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) + +declare var Namespace:any; +>Namespace : Symbol(Namespace, Decl(jsxReactTestSuite.tsx, 6, 11)) + +declare var foo: any; +>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11)) + +declare var bar: any; +>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11)) + +declare var y:any; +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) + +declare var x:any; +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) + +declare var z:any; +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) + +declare var hasOwnProperty:any; +>hasOwnProperty : Symbol(hasOwnProperty, Decl(jsxReactTestSuite.tsx, 12, 11)) + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +
+
; + + + +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + + {this.props.children} +; + + +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + + +>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) + +; + +var x = +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) + +
attr1 : Symbol(unknown) + + "foo" + "bar" + } + attr2={ +>attr2 : Symbol(unknown) + + "foo" + "bar" + + + "baz" + "bug" + } + attr3={ +>attr3 : Symbol(unknown) + + "foo" + "bar" + + "baz" + "bug" + // Extra line here. + } + attr4="baz"> +>attr4 : Symbol(unknown) + +
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+>attr1 : Symbol(unknown) + + attr2 : Symbol(unknown) + + /> +
+); + +
 
; + +
 
; + +testing; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>constructor : Symbol(unknown) + +; +>Component : Symbol(unknown) + +; +>Component : Symbol(unknown) + +Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) + +={2 } z />; +>z : Symbol(unknown) + +Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + + {...this.props} sound="moo" />; +>sound : Symbol(unknown) + +; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) + +; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) +>z : Symbol(unknown) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) + + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) +>y : Symbol(unknown) +>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) + +Text; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 113, 27)) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>z : Symbol(unknown) + + + diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types new file mode 100644 index 0000000000000..db7ebf8d912dc --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -0,0 +1,332 @@ +=== tests/cases/conformance/jsx/jsxReactTestSuite.tsx === + +declare var React: any; +>React : any + +declare var Component:any; +>Component : any + +declare var Composite:any; +>Composite : any + +declare var Composite2:any; +>Composite2 : any + +declare var Child:any; +>Child : any + +declare var Namespace:any; +>Namespace : any + +declare var foo: any; +>foo : any + +declare var bar: any; +>bar : any + +declare var y:any; +>y : any + +declare var x:any; +>x : any + +declare var z:any; +>z : any + +declare var hasOwnProperty:any; +>hasOwnProperty : any + +
text
; +>
text
: any +>div : any +>div : any + +
+>
{this.props.children}
: any +>div : any + + {this.props.children} +>this.props.children : any +>this.props : any +>this : any +>props : any +>children : any + +
; +>div : any + +
+>

{foo}
{bar}

: any +>div : any + +

+>

: any +>div : any +>
: any +>br : any +>div : any + + {foo}
{bar}
+>{foo}
{bar}
: any +>Component : any +>foo : any +>
: any +>br : any +>bar : any +>Component : any + +
+>
: any +>br : any + +
; +>div : any + + + +> {this.props.children} : any +>Composite : any + + {this.props.children} +>this.props.children : any +>this.props : any +>this : any +>props : any +>children : any + +; +>Composite : any + + +> : any +>Composite : any + + +> : any +>Composite2 : any + +; +>Composite : any + +var x = +>x : any + +
: any +>div : any + + attr1={ +>attr1 : any + + "foo" + "bar" +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + } + attr2={ +>attr2 : any + + "foo" + "bar" + +>"foo" + "bar" + "baz" + "bug" : string +>"foo" + "bar" + "baz" : string +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + + "baz" + "bug" +>"baz" : string +>"bug" : string + } + attr3={ +>attr3 : any + + "foo" + "bar" + +>"foo" + "bar" + "baz" + "bug" : string +>"foo" + "bar" + "baz" : string +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + + "baz" + "bug" +>"baz" : string +>"bug" : string + + // Extra line here. + } + attr4="baz"> +>attr4 : any + +
; +>div : any + +( +>(
{/* A comment at the beginning */} {/* A second comment at the beginning */} {/* A nested comment */} {/* A sandwiched comment */}
{/* A comment at the end */} {/* A second comment at the end */}
) : any + +
+>
{/* A comment at the beginning */} {/* A second comment at the beginning */} {/* A nested comment */} {/* A sandwiched comment */}
{/* A comment at the end */} {/* A second comment at the end */}
: any +>div : any + + {/* A comment at the beginning */} + {/* A second comment at the beginning */} + +> {/* A nested comment */} : any +>span : any + + {/* A nested comment */} + +>span : any + + {/* A sandwiched comment */} +
+>
: any +>br : any + + {/* A comment at the end */} + {/* A second comment at the end */} +
+>div : any + +); + +( +>(
) : any + +
: any +>div : any + + /* a multi-line + comment */ + attr1="foo"> +>attr1 : any + + : any +>span : any + + attr2="bar" +>attr2 : any + + /> +
+>div : any + +); + +
 
; +>
 
: any +>div : any +>div : any + +
 
; +>
 
: any +>div : any +>div : any + +testing; +>testing : any +>hasOwnProperty : any +>hasOwnProperty : any + +; +> : any +>Component : any +>constructor : any + +; +> : any +>Namespace : any +>Component : any + +; +> : any +>Namespace : any +>DeepNamespace : any +>Component : any + + : any +>Component : any +>x : any +>y : any + +={2 } z />; +>z : any + + : any +>Component : any + + {...this.props} sound="moo" />; +>this.props : any +>this : any +>props : any +>sound : any + +; +> : any +>font-face : any + +; +> : any +>Component : any +>x : any +>y : any + +; +> : any +>x-component : any + +; +> : any +>Component : any +>x : any + +; +> : any +>Component : any +>x : any +>y : any + +; +> : any +>Component : any +>x : any +>y : any +>z : any + +; +> : any +>Component : any +>x : any +>y : any + + +; +> : any +>Component : any +>x : any +>y : any +>z : any +>z : any +> : any +>Child : any +>Component : any + +Text; +>Text : any +>Component : any +>x : any +>(z = { y: 2 }, z) : any +>z = { y: 2 }, z : any +>z = { y: 2 } : { y: number; } +>z : any +>{ y: 2 } : { y: number; } +>y : number +>2 : number +>z : any +>z : any +>Component : any + + + diff --git a/tests/baselines/reference/tsxElementResolution.errors.txt b/tests/baselines/reference/tsxElementResolution.errors.txt deleted file mode 100644 index 4e5cb93b00769..0000000000000 --- a/tests/baselines/reference/tsxElementResolution.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/jsx/tsxElementResolution.tsx(18,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxElementResolution.tsx(19,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxElementResolution.tsx(23,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxElementResolution.tsx(24,9): error TS2602: The global type 'JSX.Element' must exist when using JSX. - - -==== tests/cases/conformance/jsx/tsxElementResolution.tsx (4 errors) ==== - - declare namespace JSX { - interface IntrinsicElements { - foundFirst: { x: string }; - 'string_named'; - 'var'; - } - } - - class foundFirst { } - class Other {} - - module Dotted { - export class Name { } - } - - // Should find the intrinsic element, not the class element - var a = ; - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - var b = ; - ~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - // TODO: This should not be a parse error (should - // parse a property name here, not identifier) - // var c = ; - var d = ; - ~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - var e = ; - ~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution.symbols b/tests/baselines/reference/tsxElementResolution.symbols new file mode 100644 index 0000000000000..4cdd0c23cf16d --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/jsx/tsxElementResolution.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution.tsx, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution.tsx, 1, 23)) + + foundFirst: { x: string }; +>foundFirst : Symbol(foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) + + 'string_named'; + 'var'; + } +} + +class foundFirst { } +>foundFirst : Symbol(foundFirst, Decl(tsxElementResolution.tsx, 7, 1)) + +class Other {} +>Other : Symbol(Other, Decl(tsxElementResolution.tsx, 9, 20)) + +module Dotted { +>Dotted : Symbol(Dotted, Decl(tsxElementResolution.tsx, 10, 14)) + + export class Name { } +>Name : Symbol(Name, Decl(tsxElementResolution.tsx, 12, 15)) +} + +// Should find the intrinsic element, not the class element +var a = ; +>a : Symbol(a, Decl(tsxElementResolution.tsx, 17, 3)) +>foundFirst : Symbol(JSX.IntrinsicElements.foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) + +var b = ; +>b : Symbol(b, Decl(tsxElementResolution.tsx, 18, 3)) +>string_named : Symbol(JSX.IntrinsicElements.'string_named', Decl(tsxElementResolution.tsx, 3, 28)) + +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +>d : Symbol(d, Decl(tsxElementResolution.tsx, 22, 3)) +>Other : Symbol(Other, Decl(tsxElementResolution.tsx, 9, 20)) + +var e = ; +>e : Symbol(e, Decl(tsxElementResolution.tsx, 23, 3)) +>Name : Symbol(Dotted.Name, Decl(tsxElementResolution.tsx, 12, 15)) + diff --git a/tests/baselines/reference/tsxElementResolution.types b/tests/baselines/reference/tsxElementResolution.types new file mode 100644 index 0000000000000..89600bbbc2f34 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/jsx/tsxElementResolution.tsx === + +declare namespace JSX { +>JSX : any + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + foundFirst: { x: string }; +>foundFirst : { x: string; } +>x : string + + 'string_named'; + 'var'; + } +} + +class foundFirst { } +>foundFirst : foundFirst + +class Other {} +>Other : Other + +module Dotted { +>Dotted : typeof Dotted + + export class Name { } +>Name : Name +} + +// Should find the intrinsic element, not the class element +var a = ; +>a : any +> : any +>foundFirst : typeof foundFirst +>x : any + +var b = ; +>b : any +> : any +>string_named : any + +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +>d : any +> : any +>Other : typeof Other + +var e = ; +>e : any +> : any +>Dotted : any +>Name : any + diff --git a/tests/baselines/reference/tsxElementResolution16.errors.txt b/tests/baselines/reference/tsxElementResolution16.errors.txt index 3bdc9286c5679..0e30cad9673a0 100644 --- a/tests/baselines/reference/tsxElementResolution16.errors.txt +++ b/tests/baselines/reference/tsxElementResolution16.errors.txt @@ -1,7 +1,8 @@ -tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist. +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists -==== tests/cases/conformance/jsx/tsxElementResolution16.tsx (1 errors) ==== +==== tests/cases/conformance/jsx/tsxElementResolution16.tsx (2 errors) ==== declare module JSX { } @@ -9,7 +10,9 @@ tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS2602: The g new(n: string): {}; } var obj1: Obj1; - ; // Error (JSX.Element is missing) + ; // Error (JSX.Element is implicit any) ~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. +!!! error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist. + ~~~~~~~~~~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution16.js b/tests/baselines/reference/tsxElementResolution16.js index c63c3b7f83a35..1961215fa05e2 100644 --- a/tests/baselines/reference/tsxElementResolution16.js +++ b/tests/baselines/reference/tsxElementResolution16.js @@ -6,9 +6,9 @@ interface Obj1 { new(n: string): {}; } var obj1: Obj1; -; // Error (JSX.Element is missing) +; // Error (JSX.Element is implicit any) //// [tsxElementResolution16.jsx] var obj1; -; // Error (JSX.Element is missing) +; // Error (JSX.Element is implicit any) diff --git a/tests/baselines/reference/tsxElementResolution16.symbols b/tests/baselines/reference/tsxElementResolution16.symbols new file mode 100644 index 0000000000000..e01f19b991f48 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsx/tsxElementResolution16.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution16.tsx, 0, 0)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution16.tsx, 1, 1)) + + new(n: string): {}; +>n : Symbol(n, Decl(tsxElementResolution16.tsx, 4, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution16.tsx, 6, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution16.tsx, 1, 1)) + +; // Error (JSX.Element is missing) +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution16.types b/tests/baselines/reference/tsxElementResolution16.types new file mode 100644 index 0000000000000..3b8604e737d20 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxElementResolution16.tsx === +declare module JSX { +>JSX : any +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): {}; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // Error (JSX.Element is missing) +> : any +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxNoJsx.errors.txt b/tests/baselines/reference/tsxNoJsx.errors.txt deleted file mode 100644 index 9e5c6762c9eaf..0000000000000 --- a/tests/baselines/reference/tsxNoJsx.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/jsx/tsxNoJsx.tsx(2,1): error TS2602: The global type 'JSX.Element' must exist when using JSX. - - -==== tests/cases/conformance/jsx/tsxNoJsx.tsx (1 errors) ==== - - ; - ~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - \ No newline at end of file diff --git a/tests/baselines/reference/tsxNoJsx.symbols b/tests/baselines/reference/tsxNoJsx.symbols new file mode 100644 index 0000000000000..6744c2edb10eb --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/jsx/tsxNoJsx.tsx === + +No type information for this code.; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/tsxNoJsx.types b/tests/baselines/reference/tsxNoJsx.types new file mode 100644 index 0000000000000..52e6769795eb7 --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/jsx/tsxNoJsx.tsx === + +; +> : any +>nope : any + diff --git a/tests/baselines/reference/tsxTypeErrors.errors.txt b/tests/baselines/reference/tsxTypeErrors.errors.txt deleted file mode 100644 index 42959efe6fe4b..0000000000000 --- a/tests/baselines/reference/tsxTypeErrors.errors.txt +++ /dev/null @@ -1,55 +0,0 @@ -tests/cases/conformance/jsx/tsxTypeErrors.tsx(3,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxTypeErrors.tsx(6,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxTypeErrors.tsx(10,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxTypeErrors.tsx(13,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxTypeErrors.tsx(26,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. -tests/cases/conformance/jsx/tsxTypeErrors.tsx(32,10): error TS2602: The global type 'JSX.Element' must exist when using JSX. - - -==== tests/cases/conformance/jsx/tsxTypeErrors.tsx (6 errors) ==== - - // A built-in element (OK) - var a1 =
; - ~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - // A built-in element with a mistyped property (error) - var a2 = - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - // A built-in element with a badly-typed attribute value (error) - var thing = { oops: 100 }; - var a3 =
- ~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - // Mistyped html name (error) - var e1 = - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - // A custom type - class MyClass { - props: { - pt?: { x: number; y: number; }; - name?: string; - reqd: boolean; - } - } - - // Let's use it - // TODO: Error on missing 'reqd' - var b1 = ; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - // Mistyped attribute member - // sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. - // Types of property 'y' are incompatible. - // Type 'string' is not assignable to type 'number'. - var b2 = ; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2602: The global type 'JSX.Element' must exist when using JSX. - - \ No newline at end of file diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols new file mode 100644 index 0000000000000..bfe0c5686403e --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -0,0 +1,65 @@ +=== tests/cases/conformance/jsx/tsxTypeErrors.tsx === + +// A built-in element (OK) +var a1 =
; +>a1 : Symbol(a1, Decl(tsxTypeErrors.tsx, 2, 3)) +>id : Symbol(unknown) + +// A built-in element with a mistyped property (error) +var a2 = +>a2 : Symbol(a2, Decl(tsxTypeErrors.tsx, 5, 3)) +>srce : Symbol(unknown) + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3)) +>oops : Symbol(oops, Decl(tsxTypeErrors.tsx, 8, 13)) + +var a3 =
+>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3)) +>id : Symbol(unknown) + +// Mistyped html name (error) +var e1 = +>e1 : Symbol(e1, Decl(tsxTypeErrors.tsx, 12, 3)) +>src : Symbol(unknown) + +// A custom type +class MyClass { +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) + + props: { +>props : Symbol(props, Decl(tsxTypeErrors.tsx, 15, 15)) + + pt?: { x: number; y: number; }; +>pt : Symbol(pt, Decl(tsxTypeErrors.tsx, 16, 10)) +>x : Symbol(x, Decl(tsxTypeErrors.tsx, 17, 10)) +>y : Symbol(y, Decl(tsxTypeErrors.tsx, 17, 21)) + + name?: string; +>name : Symbol(name, Decl(tsxTypeErrors.tsx, 17, 35)) + + reqd: boolean; +>reqd : Symbol(reqd, Decl(tsxTypeErrors.tsx, 18, 15)) + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +>b1 : Symbol(b1, Decl(tsxTypeErrors.tsx, 25, 3)) +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) +>reqd : Symbol(unknown) + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; +>b2 : Symbol(b2, Decl(tsxTypeErrors.tsx, 31, 3)) +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) +>pt : Symbol(unknown) +>x : Symbol(x, Decl(tsxTypeErrors.tsx, 31, 23)) +>y : Symbol(y, Decl(tsxTypeErrors.tsx, 31, 28)) + + diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types new file mode 100644 index 0000000000000..92c7148b3147f --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/jsx/tsxTypeErrors.tsx === + +// A built-in element (OK) +var a1 =
; +>a1 : any +>
: any +>div : any +>id : any + +// A built-in element with a mistyped property (error) +var a2 = +>a2 : any +> : any +>img : any +>srce : any + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +>thing : { oops: number; } +>{ oops: 100 } : { oops: number; } +>oops : number +>100 : number + +var a3 =
+>a3 : any +>
: any +>div : any +>id : any +>thing : any + +// Mistyped html name (error) +var e1 = +>e1 : any +> : any +>imag : any +>src : any + +// A custom type +class MyClass { +>MyClass : MyClass + + props: { +>props : { pt?: { x: number; y: number; }; name?: string; reqd: boolean; } + + pt?: { x: number; y: number; }; +>pt : { x: number; y: number; } +>x : number +>y : number + + name?: string; +>name : string + + reqd: boolean; +>reqd : boolean + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +>b1 : any +> : any +>MyClass : typeof MyClass +>reqd : any +>true : boolean + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; +>b2 : any +> : any +>MyClass : typeof MyClass +>pt : any +>{x: 4, y: 'oops'} : { x: number; y: string; } +>x : number +>4 : number +>y : string +>'oops' : string + + diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.tsx b/tests/cases/conformance/jsx/tsxElementResolution16.tsx index 7d71b5f2b69b4..3b5b23d77f52d 100644 --- a/tests/cases/conformance/jsx/tsxElementResolution16.tsx +++ b/tests/cases/conformance/jsx/tsxElementResolution16.tsx @@ -1,5 +1,6 @@ //@filename: file.tsx //@jsx: preserve +//@noImplicitAny: true declare module JSX { } @@ -7,4 +8,4 @@ interface Obj1 { new(n: string): {}; } var obj1: Obj1; -; // Error (JSX.Element is missing) +; // Error (JSX.Element is implicit any) diff --git a/tests/cases/conformance/jsx/tsxInArrowFunction.tsx b/tests/cases/conformance/jsx/tsxInArrowFunction.tsx new file mode 100644 index 0000000000000..36951e0d09292 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxInArrowFunction.tsx @@ -0,0 +1,23 @@ +// @jsx: preserve + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + } + } +} + + +// didn't work +
{() =>
}
; + +// didn't work +
{x =>
}
; + +// worked +
{() => (
)}
; + +// worked (!) +
{() =>
}
; From 46401483ce7e80383e504cca14fc2595c31b1d15 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 25 Jun 2015 11:50:14 -0700 Subject: [PATCH 153/250] added context flag --- src/compiler/checker.ts | 79 +++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efee668a24bd4..26889c852331a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4263,27 +4263,27 @@ namespace ts { // TYPE CHECKING function isTypeIdenticalTo(source: Type, target: Type): boolean { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*context*/ undefined, /*errorNode*/ undefined); } function compareTypes(source: Type, target: Type): Ternary { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; + return checkTypeRelatedTo(source, target, identityRelation, /*context*/ undefined, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; } function isTypeSubtypeOf(source: Type, target: Type): boolean { - return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); + return checkTypeSubtypeOf(source, target, /*context*/ undefined, /*errorNode*/ undefined); } function isTypeAssignableTo(source: Type, target: Type): boolean { - return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); + return checkTypeAssignableTo(source, target, /*context*/ undefined, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + return checkTypeRelatedTo(source, target, subtypeRelation, /*context*/ undefined, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source: Type, target: Type, context?: SyntaxKind, errorNode?: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + return checkTypeRelatedTo(source, target, assignableRelation, /*context*/ context, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source: Signature, target: Signature): boolean { @@ -4292,13 +4292,28 @@ namespace ts { return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param The context in which the checking occurs. Currently used only for distinguishing extending classes from + * other assignability relations. + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + + */ function checkTypeRelatedTo( source: Type, target: Type, relation: Map, - errorNode: Node, + context?: SyntaxKind, + errorNode?: Node, headMessage?: DiagnosticMessage, - containingMessageChain?: DiagnosticMessageChain): boolean { + containingMessageChain?: DiagnosticMessageChain + ): boolean { let errorInfo: DiagnosticMessageChain; let sourceStack: ObjectType[]; @@ -7212,6 +7227,7 @@ namespace ts { typeArgumentsAreAssignable = checkTypeAssignableTo( typeArgument, constraint, + /*context */ undefined, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); @@ -7243,7 +7259,7 @@ namespace ts { // Use argument expression as error location when reporting errors let errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; let headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { + if (!checkTypeRelatedTo(argType, paramType, relation, /*context */ undefined, errorNode, headMessage)) { return false; } } @@ -8040,7 +8056,7 @@ namespace ts { if (produceDiagnostics && targetType !== unknownType) { let widenedType = getWidenedType(exprType); if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + checkTypeAssignableTo(exprType, targetType, /*context */ undefined, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } } return targetType; @@ -8274,7 +8290,7 @@ namespace ts { else { let exprType = checkExpression(node.body); if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), /*context */ undefined, node.body, /*headMessage*/ undefined); } checkFunctionAndClassExpressionBodies(node.body); } @@ -8582,7 +8598,7 @@ namespace ts { function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type { let targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableTo(sourceType, targetType, /*context */ undefined, target, /*headMessage*/ undefined); } return sourceType; } @@ -8757,7 +8773,7 @@ namespace ts { // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, /*context */ undefined, node.left, /*headMessage*/ undefined); } } } @@ -8808,10 +8824,10 @@ namespace ts { if (func.type) { let signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, /*context */ undefined, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(expressionType, signatureElementType, /*context */ undefined, node.expression, /*headMessage*/ undefined); } } } @@ -9119,7 +9135,7 @@ namespace ts { else { checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), - typePredicateNode.type); + /*context */ undefined, typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -9197,7 +9213,7 @@ namespace ts { // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, /*context */ undefined, node.type); } } } @@ -9399,7 +9415,7 @@ namespace ts { let constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { let typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, /*context */ undefined, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } } return result; @@ -9836,6 +9852,7 @@ namespace ts { checkTypeAssignableTo( returnType, expectedReturnType, + /*context */ undefined, node, headMessage, errorInfo); @@ -10257,7 +10274,7 @@ namespace ts { // For a binding pattern, validate the initializer and exit if (isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), /*context */ undefined, node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -10267,7 +10284,7 @@ namespace ts { if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, /*context */ undefined, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -10279,7 +10296,7 @@ namespace ts { error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, /*context */ undefined, node, /*headMessage*/ undefined); } } if (node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.PropertySignature) { @@ -10415,7 +10432,7 @@ namespace ts { // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableTo(iteratedType, leftType, /*context */ undefined, varExpr, /*headMessage*/ undefined); } } } @@ -10515,7 +10532,7 @@ namespace ts { // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + checkTypeAssignableTo(iterable, createIterableType(elementType), /*context */ undefined, errorNode); } return elementType || anyType; @@ -10759,7 +10776,7 @@ namespace ts { } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, returnType, /*context */ undefined, node.expression, /*headMessage*/ undefined); } } } @@ -10802,7 +10819,7 @@ namespace ts { let caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(caseType, expressionType, /*context */ undefined, caseClause.expression, /*headMessage*/ undefined); } } forEach(clause.statements, checkSourceElement); @@ -11043,8 +11060,8 @@ namespace ts { } } } - checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, + checkTypeAssignableTo(type, baseType, SyntaxKind.ExtendsKeyword, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), SyntaxKind.ExtendsKeyword, node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -11072,7 +11089,7 @@ namespace ts { if (t !== unknownType) { let declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { - checkTypeAssignableTo(type, t, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(type, t, /*context */ undefined, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface); @@ -11255,7 +11272,7 @@ namespace ts { // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { forEach(getBaseTypes(type), baseType => { - checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); + checkTypeAssignableTo(type, baseType, /*context */ undefined, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); }); checkIndexConstraints(type); } @@ -11308,7 +11325,7 @@ namespace ts { // If it is a constant value (not undefined), it is syntactically constrained to be a number. // Also, we do not need to check this for ambients because there is already // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpression(initializer), enumType, /*context */ undefined, initializer, /*headMessage*/ undefined); } } else if (enumIsConst) { From 408538fd43a72976f96a4af3d9c7affb30792eb8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 25 Jun 2015 13:31:14 -0700 Subject: [PATCH 154/250] Remove unreferenced errors --- .../diagnosticInformationMap.generated.ts | 14 ----- src/compiler/diagnosticMessages.json | 56 ------------------- 2 files changed, 70 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 8ccc9d890e26d..5ca747e4b629e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -20,22 +20,16 @@ module ts { An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -94,7 +88,6 @@ module ts { case_or_default_expected: { code: 1130, category: DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -111,9 +104,6 @@ module ts { Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -124,7 +114,6 @@ module ts { Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -140,7 +129,6 @@ module ts { Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, @@ -187,7 +175,6 @@ module ts { Module_0_has_no_exported_member_1: { code: 2305, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -508,7 +495,6 @@ module ts { File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fb246955f73ed..4610f699a16fa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -67,22 +67,6 @@ "category": "Error", "code": 1023 }, - "A class or interface declaration can only have one 'extends' clause.": { - "category": "Error", - "code": 1024 - }, - "An 'extends' clause must precede an 'implements' clause.": { - "category": "Error", - "code": 1025 - }, - "A class can only extend a single class.": { - "category": "Error", - "code": 1026 - }, - "A class declaration can only have one 'implements' clause.": { - "category": "Error", - "code": 1027 - }, "Accessibility modifier already seen.": { "category": "Error", "code": 1028 @@ -99,10 +83,6 @@ "category": "Error", "code": 1031 }, - "An interface declaration cannot have an 'implements' clause.": { - "category": "Error", - "code": 1032 - }, "'super' must be followed by an argument list or member access.": { "category": "Error", "code": 1034 @@ -127,10 +107,6 @@ "category": "Error", "code": 1044 }, - "A 'declare' modifier cannot be used with an interface declaration.": { - "category": "Error", - "code": 1045 - }, "A 'declare' modifier is required for a top level declaration in a .d.ts file.": { "category": "Error", "code": 1046 @@ -363,10 +339,6 @@ "category": "Error", "code": 1132 }, - "Type reference expected.": { - "category": "Error", - "code": 1133 - }, "Variable declaration expected.": { "category": "Error", "code": 1134 @@ -431,18 +403,6 @@ "category": "Error", "code": 1150 }, - "'var', 'let' or 'const' expected.": { - "category": "Error", - "code": 1152 - }, - "'let' declarations are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1153 - }, - "'const' declarations are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1154 - }, "'const' declarations must be initialized": { "category": "Error", "code": 1155 @@ -483,10 +443,6 @@ "category": "Error", "code": 1166 }, - "Computed property names are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1167 - }, "A computed property name in a method overload must directly refer to a built-in symbol.": { "category": "Error", "code": 1168 @@ -547,10 +503,6 @@ "category": "Error", "code": 1182 }, - "Destructuring declarations are not allowed in ambient contexts.": { - "category": "Error", - "code": 1183 - }, "An implementation cannot be declared in ambient contexts.": { "category": "Error", "code": 1184 @@ -736,10 +688,6 @@ "category": "Error", "code": 2307 }, - "A module cannot have more than one export assignment.": { - "category": "Error", - "code": 2308 - }, "An export assignment cannot be used in a module with other exported elements.": { "category": "Error", "code": 2309 @@ -2022,10 +1970,6 @@ "category": "Message", "code": 6056 }, - "Preserve new-lines when emitting code.": { - "category": "Message", - "code": 6057 - }, "Specifies the root directory of input files. Use to control the output directory structure with --outDir.": { "category": "Message", "code": 6058 From b4b2a41bc079c9b25ae833d77102e747206a7dcc Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 25 Jun 2015 13:34:42 -0700 Subject: [PATCH 155/250] Error check script --- scripts/errorCheck.ts | 83 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 scripts/errorCheck.ts diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts new file mode 100644 index 0000000000000..d2eb5a9632e65 --- /dev/null +++ b/scripts/errorCheck.ts @@ -0,0 +1,83 @@ +declare var require: any; +let fs = require('fs'); +let async = require('async'); +let glob = require('glob'); + +fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { + let messages = JSON.parse(data); + if (err) throw err; + let keys = Object.keys(messages); + console.log('Loaded ' + keys.length + ' errors'); + + for(let k of keys) { + messages[k]['seen'] = false; + } + + let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; + + let baseDir = 'tests/baselines/reference/'; + fs.readdir(baseDir, (err, files) => { + files = files.filter(f => f.indexOf('.errors.txt') > 0); + console.log('Read ' + files.length + ' baselines'); + let tasks: Array<(callback: () => void) => void> = []; + files.forEach(f => tasks.push(done => { + fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { + if (err) throw err; + + let g: string[]; + while(g = errRegex.exec(baseline)) { + var errCode = +g[1]; + let msg = keys.filter(k => messages[k].code === errCode)[0]; + messages[msg]['seen'] = true; + } + + done(); + }); + })); + + async.parallelLimit(tasks, 25, done => { + console.log('== List of errors not present in baselines =='); + let count = 0; + for(let k of keys) { + if(messages[k]['seen'] !== true) { + console.log(k); + count++; + } + } + console.log(count + ' of ' + keys.length + ' errors are not in baselines'); + }); + }); +}); + +fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => { + let errorRegexp = /\s(\w+): \{ code/g; + let errorNames: string[] = []; + let errMatch: string[]; + while(errMatch = errorRegexp.exec(data)) { + errorNames.push(errMatch[1]); + } + + let allSrc: string = ''; + glob('./src/**/*.ts', {}, (err, files) => { + console.log('Reading ' + files.length + ' source files'); + files.forEach(file => { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) return; + + let src = fs.readFileSync(file, 'utf-8'); + allSrc = allSrc + src; + }); + + console.log('Consumed ' + allSrc.length + ' characters of source'); + + let count = 0; + console.log('== List of errors not used in source ==') + errorNames.forEach(errName => { + if(allSrc.indexOf(errName) < 0) { + console.log(errName); + count++; + } + }); + console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); + }); +}); + From aa59753fe4103778ea5514da48f89cf84336eed1 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 25 Jun 2015 14:02:30 -0700 Subject: [PATCH 156/250] CR feedback --- scripts/errorCheck.ts | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts index d2eb5a9632e65..77892cb8f0ccb 100644 --- a/scripts/errorCheck.ts +++ b/scripts/errorCheck.ts @@ -4,12 +4,15 @@ let async = require('async'); let glob = require('glob'); fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { - let messages = JSON.parse(data); - if (err) throw err; + if (err) { + throw err; + } + + let messages = JSON.parse(data); let keys = Object.keys(messages); console.log('Loaded ' + keys.length + ' errors'); - for(let k of keys) { + for (let k of keys) { messages[k]['seen'] = false; } @@ -18,14 +21,13 @@ fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { let baseDir = 'tests/baselines/reference/'; fs.readdir(baseDir, (err, files) => { files = files.filter(f => f.indexOf('.errors.txt') > 0); - console.log('Read ' + files.length + ' baselines'); let tasks: Array<(callback: () => void) => void> = []; files.forEach(f => tasks.push(done => { fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { if (err) throw err; let g: string[]; - while(g = errRegex.exec(baseline)) { + while (g = errRegex.exec(baseline)) { var errCode = +g[1]; let msg = keys.filter(k => messages[k].code === errCode)[0]; messages[msg]['seen'] = true; @@ -38,8 +40,8 @@ fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { async.parallelLimit(tasks, 25, done => { console.log('== List of errors not present in baselines =='); let count = 0; - for(let k of keys) { - if(messages[k]['seen'] !== true) { + for (let k of keys) { + if (messages[k]['seen'] !== true) { console.log(k); count++; } @@ -53,30 +55,32 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, let errorRegexp = /\s(\w+): \{ code/g; let errorNames: string[] = []; let errMatch: string[]; - while(errMatch = errorRegexp.exec(data)) { + while (errMatch = errorRegexp.exec(data)) { errorNames.push(errMatch[1]); } let allSrc: string = ''; glob('./src/**/*.ts', {}, (err, files) => { console.log('Reading ' + files.length + ' source files'); - files.forEach(file => { - if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) return; + for(let file of files) { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { + continue; + } let src = fs.readFileSync(file, 'utf-8'); allSrc = allSrc + src; - }); + } console.log('Consumed ' + allSrc.length + ' characters of source'); let count = 0; console.log('== List of errors not used in source ==') - errorNames.forEach(errName => { - if(allSrc.indexOf(errName) < 0) { + for(let errName of errorNames) { + if (allSrc.indexOf(errName) < 0) { console.log(errName); count++; } - }); + } console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); }); }); From f9de30c72849eeea67a6b6dea1912a327526f1f6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 25 Jun 2015 17:38:11 -0700 Subject: [PATCH 157/250] Fix assert with declaration emit for export specifier for a global --- src/compiler/checker.ts | 6 +++-- ...s6ExportClauseWithoutModuleSpecifier.types | 4 +-- ...ortClauseWithoutModuleSpecifierInEs5.types | 4 +-- .../reference/exportSpecifierForAGlobal.js | 25 +++++++++++++++++++ .../exportSpecifierForAGlobal.symbols | 20 +++++++++++++++ .../reference/exportSpecifierForAGlobal.types | 20 +++++++++++++++ .../reference/exportsAndImports3-amd.symbols | 12 ++++----- .../reference/exportsAndImports3.symbols | 12 ++++----- .../compiler/exportSpecifierForAGlobal.ts | 12 +++++++++ 9 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 tests/baselines/reference/exportSpecifierForAGlobal.js create mode 100644 tests/baselines/reference/exportSpecifierForAGlobal.symbols create mode 100644 tests/baselines/reference/exportSpecifierForAGlobal.types create mode 100644 tests/cases/compiler/exportSpecifierForAGlobal.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efee668a24bd4..8b59d1a2d3777 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1165,7 +1165,9 @@ namespace ts { // Check if symbol is any of the alias return forEachValue(symbols, symbolFromSymbolTable => { - if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & SymbolFlags.Alias + && symbolFromSymbolTable.name !== "export=" + && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { if (!useOnlyExternalAliasing || // We can use any type of alias to get the name // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) { @@ -1207,7 +1209,7 @@ namespace ts { } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types index 9d87ec9925dee..6b621f4c777b9 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -31,8 +31,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof m +>instantiatedModule : typeof m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 9d87ec9925dee..6b621f4c777b9 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -31,8 +31,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof m +>instantiatedModule : typeof m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.js b/tests/baselines/reference/exportSpecifierForAGlobal.js new file mode 100644 index 0000000000000..6b4343a299bb3 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/exportSpecifierForAGlobal.ts] //// + +//// [a.d.ts] + +declare class X { } + +//// [b.ts] +export {X}; +export function f() { + var x: X; + return x; +} + + +//// [b.js] +function f() { + var x; + return x; +} +exports.f = f; + + +//// [b.d.ts] +export { X }; +export declare function f(): X; diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.symbols b/tests/baselines/reference/exportSpecifierForAGlobal.symbols new file mode 100644 index 0000000000000..b38fc7be2703e --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.d.ts === + +declare class X { } +>X : Symbol(X, Decl(a.d.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +export {X}; +>X : Symbol(X, Decl(b.ts, 0, 8)) + +export function f() { +>f : Symbol(f, Decl(b.ts, 0, 11)) + + var x: X; +>x : Symbol(x, Decl(b.ts, 2, 7)) +>X : Symbol(X, Decl(a.d.ts, 0, 0)) + + return x; +>x : Symbol(x, Decl(b.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.types b/tests/baselines/reference/exportSpecifierForAGlobal.types new file mode 100644 index 0000000000000..e3d728ad0d0c1 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.d.ts === + +declare class X { } +>X : X + +=== tests/cases/compiler/b.ts === +export {X}; +>X : typeof X + +export function f() { +>f : () => X + + var x: X; +>x : X +>X : X + + return x; +>x : X +} + diff --git a/tests/baselines/reference/exportsAndImports3-amd.symbols b/tests/baselines/reference/exportsAndImports3-amd.symbols index 4ab418a9bef4b..a46d7df2a68a4 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.symbols +++ b/tests/baselines/reference/exportsAndImports3-amd.symbols @@ -16,17 +16,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 6, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 7, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 8, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 8, 9)) +>A : Symbol(E.A, Decl(t1.ts, 7, 15)) +>B : Symbol(E.B, Decl(t1.ts, 8, 6)) +>C : Symbol(E.C, Decl(t1.ts, 8, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 9, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 10, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 11, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 11, 9)) +>A : Symbol(D.A, Decl(t1.ts, 10, 21)) +>B : Symbol(D.B, Decl(t1.ts, 11, 6)) +>C : Symbol(D.C, Decl(t1.ts, 11, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 12, 1)) diff --git a/tests/baselines/reference/exportsAndImports3.symbols b/tests/baselines/reference/exportsAndImports3.symbols index 4ab418a9bef4b..a46d7df2a68a4 100644 --- a/tests/baselines/reference/exportsAndImports3.symbols +++ b/tests/baselines/reference/exportsAndImports3.symbols @@ -16,17 +16,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 6, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 7, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 8, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 8, 9)) +>A : Symbol(E.A, Decl(t1.ts, 7, 15)) +>B : Symbol(E.B, Decl(t1.ts, 8, 6)) +>C : Symbol(E.C, Decl(t1.ts, 8, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 9, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 10, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 11, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 11, 9)) +>A : Symbol(D.A, Decl(t1.ts, 10, 21)) +>B : Symbol(D.B, Decl(t1.ts, 11, 6)) +>C : Symbol(D.C, Decl(t1.ts, 11, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 12, 1)) diff --git a/tests/cases/compiler/exportSpecifierForAGlobal.ts b/tests/cases/compiler/exportSpecifierForAGlobal.ts new file mode 100644 index 0000000000000..c24ec0b086f88 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierForAGlobal.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @module: commonjs + +// @filename: a.d.ts +declare class X { } + +// @filename: b.ts +export {X}; +export function f() { + var x: X; + return x; +} From c3af662e324e34d29794f30a81d7e12b8b0a645d Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 25 Jun 2015 18:39:29 -0700 Subject: [PATCH 158/250] Change var -> let and use destructuring --- src/services/services.ts | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e11fb32c73bab..e3d9480e062b2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1797,7 +1797,7 @@ namespace ts { let outputText: string; // Create a compilerHost object to allow the compiler to read and write files - var compilerHost: CompilerHost = { + let compilerHost: CompilerHost = { getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); @@ -1810,7 +1810,7 @@ namespace ts { getNewLine: () => newLine }; - var program = createProgram([inputFileName], options, compilerHost); + let program = createProgram([inputFileName], options, compilerHost); addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); @@ -3084,7 +3084,7 @@ namespace ts { * accurately aggregate locals from the closest containing scope. */ function getScopeNode(initialToken: Node, position: number, sourceFile: SourceFile) { - var scope = initialToken; + let scope = initialToken; while (scope && !positionBelongsToNode(scope, position, sourceFile)) { scope = scope.parent; } @@ -3485,10 +3485,10 @@ namespace ts { function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] { let start = new Date().getTime(); - var entries: CompletionEntry[] = []; + let entries: CompletionEntry[] = []; if (symbols) { - var nameToSymbol: Map = {}; + let nameToSymbol: Map = {}; for (let symbol of symbols) { let entry = createCompletionEntry(symbol, location); if (entry) { @@ -3522,13 +3522,13 @@ namespace ts { let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined); if (symbol) { - let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); + let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); return { name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation + kind: symbolKind, + displayParts, + documentation }; } } @@ -4203,7 +4203,7 @@ namespace ts { } if (type.flags & TypeFlags.Union) { - var result: DefinitionInfo[] = []; + let result: DefinitionInfo[] = []; forEach((type).types, t => { if (t.symbol) { addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); @@ -4303,7 +4303,7 @@ namespace ts { function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] { let fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); + let highlightSpans = getHighlightSpans(node); if (!highlightSpans || highlightSpans.length === 0) { return undefined; } @@ -4881,17 +4881,17 @@ namespace ts { } function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + let referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName: string, position: number): ReferencedSymbol[]{ - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return filter(referencedSymbols, rs => !!rs.definition); @@ -5190,7 +5190,7 @@ namespace ts { } }); - var definition: DefinitionInfo = { + let definition: DefinitionInfo = { containerKind: "", containerName: "", fileName: targetLabel.getSourceFile().fileName, @@ -5286,10 +5286,10 @@ namespace ts { if (referenceSymbol) { let referenceSymbolDeclaration = referenceSymbol.valueDeclaration; let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + let relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); if (relatedSymbol) { - var referencedSymbol = getReferencedSymbol(relatedSymbol); + let referencedSymbol = getReferencedSymbol(relatedSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); } /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment @@ -5299,7 +5299,7 @@ namespace ts { * position of property accessing, the referenceEntry of such position will be handled in the first case. */ else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + let referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } @@ -5309,8 +5309,8 @@ namespace ts { return; function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { - var symbolId = getSymbolId(symbol); - var index = symbolToIndex[symbolId]; + let symbolId = getSymbolId(symbol); + let index = symbolToIndex[symbolId]; if (index === undefined) { index = result.length; symbolToIndex[symbolId] = index; @@ -5397,7 +5397,7 @@ namespace ts { } }); - var definition = getDefinition(searchSpaceNode.symbol); + let definition = getDefinition(searchSpaceNode.symbol); return [{ definition, references }]; } @@ -5592,7 +5592,7 @@ namespace ts { // If the reference symbol is an alias, check if what it is aliasing is one of the search // symbols. if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { - var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); + let aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; } @@ -6908,7 +6908,7 @@ namespace ts { } function convertClassifications(classifications: Classifications, text: string): ClassificationResult { - var entries: ClassificationInfo[] = []; + let entries: ClassificationInfo[] = []; let dense = classifications.spans; let lastEnd = 0; From 529fcfd4c94fe8165479925544ab870832fe2948 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 25 Jun 2015 18:44:30 -0700 Subject: [PATCH 159/250] Assignment compatibility fix / contextual intersection types --- src/compiler/checker.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 109ad1cf29f27..32e00af577d10 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3160,8 +3160,8 @@ namespace ts { return emptyArray; } - // If the given type is an object type and that type has a property by the given name, return - // the symbol for that property. Otherwise return undefined. + // If the given type is an object type and that type has a property by the given name, + // return the symbol for that property.Otherwise return undefined. function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { let resolved = resolveStructuredTypeMembers(type); @@ -4464,7 +4464,7 @@ namespace ts { let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; // identity relation does not use apparent type let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + if (sourceOrApparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; @@ -4595,7 +4595,7 @@ namespace ts { // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function objectTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (overflow) { return Ternary.False; } @@ -4670,7 +4670,7 @@ namespace ts { return result; } - function propertiesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } @@ -4753,7 +4753,10 @@ namespace ts { return result; } - function propertiesIdenticalTo(source: ObjectType, target: ObjectType): Ternary { + function propertiesIdenticalTo(source: Type, target: Type): Ternary { + if (!(source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType)) { + return Ternary.False; + } let sourceProperties = getPropertiesOfObjectType(source); let targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -4774,7 +4777,7 @@ namespace ts { return result; } - function signaturesRelatedTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): Ternary { + function signaturesRelatedTo(source: Type, target: Type, kind: SignatureKind, reportErrors: boolean): Ternary { if (relation === identityRelation) { return signaturesIdenticalTo(source, target, kind); } @@ -4900,7 +4903,7 @@ namespace ts { return result & isRelatedTo(s, t, reportErrors); } - function signaturesIdenticalTo(source: ObjectType, target: ObjectType, kind: SignatureKind): Ternary { + function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { let sourceSignatures = getSignaturesOfType(source, kind); let targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { @@ -4917,7 +4920,7 @@ namespace ts { return result; } - function stringIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function stringIndexTypesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.String, source, target); } @@ -4942,7 +4945,7 @@ namespace ts { return Ternary.True; } - function numberIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function numberIndexTypesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.Number, source, target); } @@ -4975,7 +4978,7 @@ namespace ts { return Ternary.True; } - function indexTypesIdenticalTo(indexKind: IndexKind, source: ObjectType, target: ObjectType): Ternary { + function indexTypesIdenticalTo(indexKind: IndexKind, source: Type, target: Type): Ternary { let targetType = getIndexTypeOfType(target, indexKind); let sourceType = getIndexTypeOfType(source, indexKind); if (!sourceType && !targetType) { @@ -6335,7 +6338,7 @@ namespace ts { function getTypeOfPropertyOfContextualType(type: Type, name: string) { return applyToContextualType(type, t => { - let prop = getPropertyOfObjectType(t, name); + let prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } From c623e6cc642d37c355423ad3365bb67494bedb42 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 25 Jun 2015 18:45:03 -0700 Subject: [PATCH 160/250] Adding a few more tests --- .../reference/contextualIntersectionType.js | 14 ++++++ .../contextualIntersectionType.symbols | 23 ++++++++++ .../contextualIntersectionType.types | 27 +++++++++++ .../intersectionTypeAssignment.errors.txt | 45 +++++++++++++++++++ .../reference/intersectionTypeAssignment.js | 35 +++++++++++++++ .../contextualIntersectionType.ts | 5 +++ .../intersectionTypeAssignment.ts | 17 +++++++ 7 files changed, 166 insertions(+) create mode 100644 tests/baselines/reference/contextualIntersectionType.js create mode 100644 tests/baselines/reference/contextualIntersectionType.symbols create mode 100644 tests/baselines/reference/contextualIntersectionType.types create mode 100644 tests/baselines/reference/intersectionTypeAssignment.errors.txt create mode 100644 tests/baselines/reference/intersectionTypeAssignment.js create mode 100644 tests/cases/conformance/types/intersection/contextualIntersectionType.ts create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts diff --git a/tests/baselines/reference/contextualIntersectionType.js b/tests/baselines/reference/contextualIntersectionType.js new file mode 100644 index 0000000000000..d61fc52fce750 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.js @@ -0,0 +1,14 @@ +//// [contextualIntersectionType.ts] +var x: { a: (s: string) => string } & { b: (n: number) => number }; +x = { + a: s => s, + b: n => n +}; + + +//// [contextualIntersectionType.js] +var x; +x = { + a: function (s) { return s; }, + b: function (n) { return n; } +}; diff --git a/tests/baselines/reference/contextualIntersectionType.symbols b/tests/baselines/reference/contextualIntersectionType.symbols new file mode 100644 index 0000000000000..cb7ac9f3d4120 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts === +var x: { a: (s: string) => string } & { b: (n: number) => number }; +>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3)) +>a : Symbol(a, Decl(contextualIntersectionType.ts, 0, 8)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 0, 13)) +>b : Symbol(b, Decl(contextualIntersectionType.ts, 0, 39)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 0, 44)) + +x = { +>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3)) + + a: s => s, +>a : Symbol(a, Decl(contextualIntersectionType.ts, 1, 5)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6)) + + b: n => n +>b : Symbol(b, Decl(contextualIntersectionType.ts, 2, 14)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6)) + +}; + diff --git a/tests/baselines/reference/contextualIntersectionType.types b/tests/baselines/reference/contextualIntersectionType.types new file mode 100644 index 0000000000000..4967979d73685 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts === +var x: { a: (s: string) => string } & { b: (n: number) => number }; +>x : { a: (s: string) => string; } & { b: (n: number) => number; } +>a : (s: string) => string +>s : string +>b : (n: number) => number +>n : number + +x = { +>x = { a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; } +>x : { a: (s: string) => string; } & { b: (n: number) => number; } +>{ a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; } + + a: s => s, +>a : (s: string) => string +>s => s : (s: string) => string +>s : string +>s : string + + b: n => n +>b : (n: number) => number +>n => n : (n: number) => number +>n : number +>n : number + +}; + diff --git a/tests/baselines/reference/intersectionTypeAssignment.errors.txt b/tests/baselines/reference/intersectionTypeAssignment.errors.txt new file mode 100644 index 0000000000000..11ea91d8f0e95 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeAssignment.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(8,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'. + Property 'b' is missing in type '{ a: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(9,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'. + Type '{ a: string; }' is not assignable to type '{ b: string; }'. + Property 'b' is missing in type '{ a: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(13,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'. + Property 'a' is missing in type '{ b: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(14,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'. + Type '{ b: string; }' is not assignable to type '{ a: string; }'. + Property 'a' is missing in type '{ b: string; }'. + + +==== tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts (4 errors) ==== + var a: { a: string }; + var b: { b: string }; + var x: { a: string, b: string }; + var y: { a: string } & { b: string }; + + a = x; + a = y; + x = a; // Error + ~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: string; }'. + y = a; // Error + ~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'. +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ b: string; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: string; }'. + + b = x; + b = y; + x = b; // Error + ~ +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Property 'a' is missing in type '{ b: string; }'. + y = b; // Error + ~ +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'. +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; }'. +!!! error TS2322: Property 'a' is missing in type '{ b: string; }'. + + x = y; + y = x; + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeAssignment.js b/tests/baselines/reference/intersectionTypeAssignment.js new file mode 100644 index 0000000000000..f1cddbf3b2a13 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeAssignment.js @@ -0,0 +1,35 @@ +//// [intersectionTypeAssignment.ts] +var a: { a: string }; +var b: { b: string }; +var x: { a: string, b: string }; +var y: { a: string } & { b: string }; + +a = x; +a = y; +x = a; // Error +y = a; // Error + +b = x; +b = y; +x = b; // Error +y = b; // Error + +x = y; +y = x; + + +//// [intersectionTypeAssignment.js] +var a; +var b; +var x; +var y; +a = x; +a = y; +x = a; // Error +y = a; // Error +b = x; +b = y; +x = b; // Error +y = b; // Error +x = y; +y = x; diff --git a/tests/cases/conformance/types/intersection/contextualIntersectionType.ts b/tests/cases/conformance/types/intersection/contextualIntersectionType.ts new file mode 100644 index 0000000000000..580827992ac7a --- /dev/null +++ b/tests/cases/conformance/types/intersection/contextualIntersectionType.ts @@ -0,0 +1,5 @@ +var x: { a: (s: string) => string } & { b: (n: number) => number }; +x = { + a: s => s, + b: n => n +}; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts b/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts new file mode 100644 index 0000000000000..00a299ea24421 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts @@ -0,0 +1,17 @@ +var a: { a: string }; +var b: { b: string }; +var x: { a: string, b: string }; +var y: { a: string } & { b: string }; + +a = x; +a = y; +x = a; // Error +y = a; // Error + +b = x; +b = y; +x = b; // Error +y = b; // Error + +x = y; +y = x; From 133a86a3773868178d0aa6c53981f8b68087d7a1 Mon Sep 17 00:00:00 2001 From: mihailik Date: Fri, 26 Jun 2015 09:22:55 +0100 Subject: [PATCH 161/250] Conflict with Object.prototype.watch in FireFox/Gecko In Gecko engine `commandLine.options.watch` evaluates to a truthy value (a function). Adding an extra check to work around. [Definition of CompilerOptions.watch in compiler/types](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/types.ts#L1860) ``` typescript export interface CompilerOptions { // . . . watch?: boolean; ``` [Object.prototype.watch on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch) > Warning: Generally you should avoid using watch() and unwatch() when possible. These two methods are > implemented only in Gecko, and they're intended primarily for debugging use. In addition, using watchpoints > has a serious negative impact on performance, which is especially true when used on global objects, such > as window. You can usually use setters and getters or proxies instead. See Browser compatibility for details. > Also, do not confuse Object.watch with Object.observe. --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2903c3a31f4ea..eada189d64284 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -191,7 +191,7 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.watch) { + if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { // FireFox has Object.prototype.watch if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From e7e020e958bb4e9ec7942227be32092624a4ee99 Mon Sep 17 00:00:00 2001 From: mihailik Date: Fri, 26 Jun 2015 14:38:25 +0100 Subject: [PATCH 162/250] PR feedback - comments and whitespace adjustments --- src/compiler/tsc.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index eada189d64284..1851e516abd72 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -191,7 +191,8 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { // FireFox has Object.prototype.watch + // Firefox has Object.prototype.watch + if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From b1a05b8d3ce6fb94ca8ea30a90ad5822e7efb421 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 26 Jun 2015 09:38:21 -0700 Subject: [PATCH 163/250] Improve commandline help for --jsx --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e635def21319e..35c5bc14c844d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -45,7 +45,7 @@ namespace ts { "react": JsxEmit.React }, paramType: Diagnostics.KIND, - description: Diagnostics.Specifies_how_to_transform_JSX_syntax_during_compilation, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react }, { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 674d683190408..04db6f2104819 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -541,7 +541,7 @@ namespace ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Specifies_how_to_transform_JSX_syntax_during_compilation: { code: 6080, category: DiagnosticCategory.Message, key: "Specifies how to transform JSX syntax during compilation." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 468f162ce3f78..f21150d9323dc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2156,7 +2156,7 @@ "category": "Error", "code": 6062 }, - "Specifies how to transform JSX syntax during compilation.": { + "Specify JSX code generation: 'preserve' or 'react'": { "category": "Message", "code": 6080 }, From 18588104dbd359e54eb4501988139554f58e56fc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 26 Jun 2015 09:47:58 -0700 Subject: [PATCH 164/250] Preserve order in intersection types --- src/compiler/checker.ts | 76 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 32e00af577d10..186e35ccfe3bc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1539,8 +1539,8 @@ namespace ts { else if (type.flags & TypeFlags.Tuple) { writeTupleType(type); } - else if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { - writeUnionOrIntersectionType(type, flags); + else if (type.flags & TypeFlags.UnionOrIntersection) { + writeUnionOrIntersectionType(type, flags); } else if (type.flags & TypeFlags.Anonymous) { writeAnonymousType(type, flags); @@ -3143,7 +3143,7 @@ namespace ts { resolveUnionTypeMembers(type); } else if (type.flags & TypeFlags.Intersection) { - resolveIntersectionTypeMembers(type); + resolveIntersectionTypeMembers(type); } else { resolveTypeReferenceMembers(type); @@ -3299,7 +3299,7 @@ namespace ts { return getPropertyOfObjectType(globalObjectType, name); } if (type.flags & TypeFlags.UnionOrIntersection) { - return getPropertyOfUnionOrIntersectionType(type, name); + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } @@ -3864,28 +3864,25 @@ namespace ts { return links.resolvedType; } - function addTypeToSortedSet(sortedSet: Type[], type: Type, typeKind: TypeFlags) { + function addTypeToSet(typeSet: Type[], type: Type, typeKind: TypeFlags) { if (type.flags & typeKind) { - addTypesToSortedSet(sortedSet, (type).types, typeKind); + addTypesToSet(typeSet, (type).types, typeKind); } - else { - let i = 0; - let id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes: Type[], types: Type[], typeKind: TypeFlags) { + function addTypesToSet(typeSet: Type[], types: Type[], typeKind: TypeFlags) { for (let type of types) { - addTypeToSortedSet(sortedTypes, type, typeKind); + addTypeToSet(typeSet, type, typeKind); } } + function compareTypeIds(type1: Type, type2: Type): number { + return type1.id - type2.id; + } + function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { for (let type of types) { if (candidate !== type && isTypeSubtypeOf(candidate, type)) { @@ -3932,26 +3929,27 @@ namespace ts { if (types.length === 0) { return emptyObjectType; } - let sortedTypes: Type[] = []; - addTypesToSortedSet(sortedTypes, types, TypeFlags.Union); + let typeSet: Type[] = []; + addTypesToSet(typeSet, types, TypeFlags.Union); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - let id = getTypeListId(sortedTypes); + let id = getTypeListId(typeSet); let type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -3986,20 +3984,22 @@ namespace ts { // We do not perform supertype reduction on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. + // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution + // for intersections of types with signatues can be deterministic. function getIntersectionType(types: Type[]): Type { - let sortedTypes: Type[] = []; - addTypesToSortedSet(sortedTypes, types, TypeFlags.Intersection); - if (containsTypeAny(sortedTypes)) { + let typeSet: Type[] = []; + addTypesToSet(typeSet, types, TypeFlags.Intersection); + if (containsTypeAny(typeSet)) { return anyType; } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - let id = getTypeListId(sortedTypes); + let id = getTypeListId(typeSet); let type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; } return type; } @@ -8128,7 +8128,7 @@ namespace ts { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { - let types = (type).types; + let types = (type).types; for (let current of types) { if (current.flags & kind) { return true; @@ -8145,7 +8145,7 @@ namespace ts { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { - let types = (type).types; + let types = (type).types; for (let current of types) { if (!(current.flags & kind)) { return false; From 90ffdf77c9b78db2792212eed21647644119a654 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 26 Jun 2015 09:48:36 -0700 Subject: [PATCH 165/250] Adding test --- .../reference/intersectionTypeOverloading.js | 26 ++++++++++++ .../intersectionTypeOverloading.symbols | 36 +++++++++++++++++ .../intersectionTypeOverloading.types | 40 +++++++++++++++++++ .../intersectionTypeOverloading.ts | 14 +++++++ 4 files changed, 116 insertions(+) create mode 100644 tests/baselines/reference/intersectionTypeOverloading.js create mode 100644 tests/baselines/reference/intersectionTypeOverloading.symbols create mode 100644 tests/baselines/reference/intersectionTypeOverloading.types create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts diff --git a/tests/baselines/reference/intersectionTypeOverloading.js b/tests/baselines/reference/intersectionTypeOverloading.js new file mode 100644 index 0000000000000..b7080e449b7df --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.js @@ -0,0 +1,26 @@ +//// [intersectionTypeOverloading.ts] +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +type G = (x: any) => any; + +var fg: F & G; +var gf: G & F; + +var x = fg("abc"); +var x: string; + +var y = gf("abc"); +var y: any; + + +//// [intersectionTypeOverloading.js] +// Check that order is preserved in intersection types for purposes of +// overload resolution +var fg; +var gf; +var x = fg("abc"); +var x; +var y = gf("abc"); +var y; diff --git a/tests/baselines/reference/intersectionTypeOverloading.symbols b/tests/baselines/reference/intersectionTypeOverloading.symbols new file mode 100644 index 0000000000000..c8503345041bd --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts === +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) +>s : Symbol(s, Decl(intersectionTypeOverloading.ts, 3, 10)) + +type G = (x: any) => any; +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 4, 10)) + +var fg: F & G; +>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3)) +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) + +var gf: G & F; +>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3)) +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) + +var x = fg("abc"); +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3)) +>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3)) + +var x: string; +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3)) + +var y = gf("abc"); +>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3)) +>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3)) + +var y: any; +>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3)) + diff --git a/tests/baselines/reference/intersectionTypeOverloading.types b/tests/baselines/reference/intersectionTypeOverloading.types new file mode 100644 index 0000000000000..c478b6a08cb74 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts === +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +>F : (s: string) => string +>s : string + +type G = (x: any) => any; +>G : (x: any) => any +>x : any + +var fg: F & G; +>fg : ((s: string) => string) & ((x: any) => any) +>F : (s: string) => string +>G : (x: any) => any + +var gf: G & F; +>gf : ((x: any) => any) & ((s: string) => string) +>G : (x: any) => any +>F : (s: string) => string + +var x = fg("abc"); +>x : string +>fg("abc") : string +>fg : ((s: string) => string) & ((x: any) => any) +>"abc" : string + +var x: string; +>x : string + +var y = gf("abc"); +>y : any +>gf("abc") : any +>gf : ((x: any) => any) & ((s: string) => string) +>"abc" : string + +var y: any; +>y : any + diff --git a/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts b/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts new file mode 100644 index 0000000000000..0a0d30d8dbb7b --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts @@ -0,0 +1,14 @@ +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +type G = (x: any) => any; + +var fg: F & G; +var gf: G & F; + +var x = fg("abc"); +var x: string; + +var y = gf("abc"); +var y: any; From 72050073bc9d6448dc4c7114b53c4e7fcb9b6ed5 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 26 Jun 2015 10:25:58 -0700 Subject: [PATCH 166/250] use double quotes --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 1851e516abd72..2a01774fbcaaf 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -192,7 +192,7 @@ namespace ts { } // Firefox has Object.prototype.watch - if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { + if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From 306de4d6816d6b365a1f7d4f2040d5f10ce30f2f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 26 Jun 2015 14:18:51 -0700 Subject: [PATCH 167/250] CR feedback --- src/compiler/checker.ts | 33 ++++---- src/compiler/emitter.ts | 60 +++++++------- src/compiler/parser.ts | 6 +- src/compiler/types.ts | 2 - src/compiler/utilities.ts | 5 ++ src/services/services.ts | 2 +- .../jsxEsprimaFbTestSuite.errors.txt | 81 +++++++++++++++++++ .../reference/jsxEsprimaFbTestSuite.js | 5 +- .../jsxInvalidEsprimaTestSuite.errors.txt | 9 ++- .../reference/jsxInvalidEsprimaTestSuite.js | 4 +- 10 files changed, 145 insertions(+), 62 deletions(-) create mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 101b8ceb23c1d..f3f87f05c0e45 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -165,7 +165,7 @@ namespace ts { } }; - let JsxNames = { + const JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", ElementClass: "ElementClass", @@ -5578,6 +5578,7 @@ namespace ts { case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxExpression: return forEachChild(node, isAssignedIn); } return false; @@ -6774,8 +6775,7 @@ namespace ts { return false; } else { - let firstChar = (tagName).text.charAt(0); - return firstChar.toLowerCase() === firstChar; + return isIntrinsicJsxName((tagName).text); } } @@ -6836,10 +6836,7 @@ namespace ts { /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. function getJsxIntrinsicElementsType() { if (!jsxIntrinsicElementsType) { - let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, undefined); - let intrinsicsSymbol = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.IntrinsicElements, SymbolFlags.Type); - let intrinsicsType = intrinsicsSymbol && getDeclaredTypeOfSymbol(intrinsicsSymbol); - jsxIntrinsicElementsType = intrinsicsType || unknownType; + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; } return jsxIntrinsicElementsType; } @@ -6977,18 +6974,23 @@ namespace ts { let attribProperties = attribPropType && getPropertiesOfType(attribPropType); if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type if (attribProperties.length === 0) { return ''; } + // Element Attributes has one property, so the element attributes type will be the type of the corresponding + // property of the class instance type else if (attribProperties.length === 1) { return attribProperties[0].name; } + // More than one property on ElementAttributesProperty is an error else { error(attribsPropTypeSym.declarations[0], Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); return undefined; } } else { + // No interface exists, so the element attributes type will be an implicit any return undefined; } } @@ -7044,7 +7046,7 @@ namespace ts { return links.resolvedJsxType = getIndexTypeOfSymbol(sym, IndexKind.String); } else { - // Resolution failed + // Resolution failed, so we don't know return links.resolvedJsxType = anyType; } } @@ -7063,16 +7065,12 @@ namespace ts { return prop || unknownSymbol; } + let jsxElementClassType: Type = undefined; function getJsxGlobalElementClassType(): Type { - let jsxNS = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - if (jsxNS) { - let sym = getSymbol(jsxNS.exports, JsxNames.ElementClass, SymbolFlags.Type); - let elemClassType = sym && getDeclaredTypeOfSymbol(sym); - return elemClassType; - } - else { - return undefined; + if(!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } + return jsxElementClassType; } /// Returns all the properties of the Jsx.IntrinsicElements interface @@ -7137,8 +7135,7 @@ namespace ts { return checkExpression(node.expression); } else { - /// is shorthand for - return booleanType; + return unknownType; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2764ae8e86af4..3b1a1609c3948 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1113,20 +1113,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name: Identifier|QualifiedName) { - if (name.kind === SyntaxKind.Identifier) { - var ch = (name).text.charAt(0); - if (ch.toUpperCase() === ch) { - emit(name); - } - else { - write('"'); - emit(name); - write('"'); - } - return ch.toUpperCase() !== ch; + if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((name).text)) { + write('"'); + emit(name); + write('"'); } else { - Debug.assert(name.kind === SyntaxKind.QualifiedName); emit(name); } } @@ -1234,12 +1226,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } // Don't emit empty strings - if (children[i].kind === SyntaxKind.JsxText && !shouldEmitJsxText(children[i])) { - continue; + if (children[i].kind === SyntaxKind.JsxText) { + let text = getTextToEmit(children[i]); + if(text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(', '); + emit(children[i]); } - write(', '); - emit(children[i]); } } @@ -5895,12 +5894,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function trimReactWhitespace(node: JsxText): string { - // Could be empty string, do not use !node.formattedReactText - if (node.formattedReactText !== undefined) { - return node.formattedReactText; - } - - let lines: string[] = []; + let result: string = undefined; let text = getTextOfNode(node); let firstNonWhitespace = 0; let lastNonWhitespace = -1; @@ -5910,9 +5904,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx for (let i = 0; i < text.length; i++) { let c = text.charCodeAt(i); - if (c === CharacterCodes.lineFeed || c === CharacterCodes.carriageReturn) { + if (isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - lines.push(text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); + let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + '" + \' \' + "' : '') + part; } firstNonWhitespace = -1; } @@ -5924,19 +5919,26 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } if (firstNonWhitespace !== -1) { - lines.push(text.substr(firstNonWhitespace)); + let part = text.substr(firstNonWhitespace); + result = (result ? result + '" + \' \' + "' : '') + part; } - return node.formattedReactText = lines.join('" + \' \' + "'); + return result; } - function shouldEmitJsxText(node: JsxText) { + function getTextToEmit(node: JsxText) { switch (compilerOptions.jsx) { case JsxEmit.React: - return trimReactWhitespace(node).length > 0; + let text = trimReactWhitespace(node); + if (text.length === 0) { + return undefined; + } + else { + return text; + } case JsxEmit.Preserve: default: - return true; + return getTextOfNode(node, true); } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index af2e6b9854780..84f0571915126 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -657,7 +657,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0; - sourceFile.languageVariant = fileExtensionIs(sourceFile.fileName, ".tsx") ? LanguageVariant.JSX : LanguageVariant.Standard; + sourceFile.languageVariant = isTsx(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard; return sourceFile; } @@ -1298,7 +1298,6 @@ namespace ts { case ParsingContext.HeritageClauses: return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken; case ParsingContext.JsxAttributes: - // REMOVE -> // For error recovery, include } here (otherwise an over-braced {expr}} will close the surrounding statement block and mess up the entire file). return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.SlashToken; case ParsingContext.JsxChildren: return token === SyntaxKind.LessThanToken && lookAhead(nextTokenIsSlash); @@ -3377,9 +3376,6 @@ namespace ts { node.name = parseIdentifierName(); if (parseOptional(SyntaxKind.EqualsToken)) { switch (token) { - case SyntaxKind.LessThanToken: - node.initializer = parseJsxElementOrSelfClosingElement(); - break; case SyntaxKind.StringLiteral: node.initializer = parseLiteralNode(); break; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7f45138bf7ddc..0b7605ef77f58 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -877,8 +877,6 @@ namespace ts { export interface JsxText extends Node { _jsxTextExpressionBrand: any; - /// Used by the emitter to avoid recomputation - formattedReactText?: string; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 29f91e8c502fa..b326d5256f0b3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1535,6 +1535,11 @@ namespace ts { } } + export function isIntrinsicJsxName(name: string) { + let ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + function get16BitUnicodeEscapeSequence(charCode: number): string { let hexCharCode = charCode.toString(16).toUpperCase(); let paddedHexCode = ("0000" + hexCharCode).slice(-4); diff --git a/src/services/services.ts b/src/services/services.ts index 7b9de36e33c8d..d2229bdbf9181 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2934,7 +2934,7 @@ namespace ts { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { - let tagSymbols = typeChecker.getJsxIntrinsicTagNames();; + let tagSymbols = typeChecker.getJsxIntrinsicTagNames(); if (tryGetGlobalSymbols()) { symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & SymbolFlags.Value))); } diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt new file mode 100644 index 0000000000000..5758db369600a --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,17): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,23): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,29): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,57): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,58): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,12): error TS1109: Expression expected. + + +==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (8 errors) ==== + declare var React: any; + declare var 日本語; + declare var AbC_def; + declare var LeftRight; + declare var x; + declare var a; + declare var props; + + ; + + //; Namespace unsuported + + // {value} ; Namespace unsuported + +
; + + ; + ; + + <日本語>; + + + bar + baz + ; + + : } />; + + {}; + + {/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + ~ +!!! error TS1005: '{' expected. + ~~~~~ +!!! error TS1005: '}' expected. + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + + ; + ~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + + ; + + (
) < x; + +
; + +
; + +
; + + ; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.js b/tests/baselines/reference/jsxEsprimaFbTestSuite.js index 2050c39972c13..1e22826f44068 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.js +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.js @@ -71,8 +71,9 @@ baz ;
@test content
;

7x invalid-js-identifier
; - right=monkeys /> gorillas/>; -; +} right={monkeys /> gorillas / > }/> + < a.b > ; +a.b > ; ; (
) < x;
; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index e63809913f224..3e2a10e993154 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -65,12 +65,13 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,29): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002: Expected corresponding JSX closing tag for 'a'. -==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (70 errors) ==== +==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (71 errors) ==== declare var React: any; ; @@ -238,8 +239,10 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 ~ !!! error TS1005: '{' expected. ; + ~ +!!! error TS1005: '{' expected. ~ -!!! error TS1003: Identifier expected. +!!! error TS1109: Expression expected. }; ; ~~~ diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index a53cf33410dbf..13808cc29e0ed 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -76,6 +76,6 @@ var x =
one
/* intervening comment */ /* intervening comment */
>; >; ; -/>}>; +; }; - .../*hai*/asdf/>;; + .../*hai*/asdf/>;; From ce6f39edca289fe0a6b246fbce87010d0e4f7529 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 26 Jun 2015 14:21:29 -0700 Subject: [PATCH 168/250] Move token scan to inside `if` --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 84f0571915126..b5cba38f39f35 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2850,8 +2850,8 @@ namespace ts { if (sourceFile.languageVariant === LanguageVariant.JSX) { let isArrowFunctionInJsx = lookAhead(() => { let third = nextToken(); - let fourth = nextToken(); if (third === SyntaxKind.ExtendsKeyword) { + let fourth = nextToken(); switch (fourth) { case SyntaxKind.EqualsToken: case SyntaxKind.GreaterThanToken: From 83163697864611d81c74f98115e4f03b5641865c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 29 Jun 2015 09:46:41 -0400 Subject: [PATCH 169/250] Added tests. --- .../renameLocationsForClassExpression01.ts | 34 +++++++++++++++++++ .../renameLocationsForFunctionExpression01.ts | 10 +++--- .../renameLocationsForFunctionExpression02.ts | 18 ++++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 tests/cases/fourslash/renameLocationsForClassExpression01.ts create mode 100644 tests/cases/fourslash/renameLocationsForFunctionExpression02.ts diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts new file mode 100644 index 0000000000000..a1174d503ede7 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -0,0 +1,34 @@ +/// + +////class Foo { +////} +//// +////var x = class /**/Foo { +//// doIt() { +//// return Foo; +//// } +//// +//// static doItStatically() { +//// return Foo; +//// } +////} +//// +////var y = class { +//// getSomeName() { +//// return Foo +//// } +////} + + +// TODO (yuit): Fix up this test when class expressions are supported. +// Just uncomment the below, remove the marker, and add the +// appropriate ranges in the test itself. +goTo.marker(); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); + +////let ranges = test.ranges() +////for (let range of ranges) { +//// goTo.position(range.start); +//// +//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +////} \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts index b2f54853c7b51..e884783d96032 100644 --- a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts @@ -1,12 +1,12 @@ /// -////var x = function /*1*/[|f|](g: any, h: any) { -//// /*2*/[|f|](/*3*/[|f|], g); +////var x = function [|f|](g: any, h: any) { +//// [|f|]([|f|], g); ////} -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); } \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts new file mode 100644 index 0000000000000..8186611cb6463 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts @@ -0,0 +1,18 @@ +/// + +////function f() { +//// +////} +////var x = function [|f|](g: any, h: any) { +//// +//// let helper = function f(): any { f(); } +//// +//// let foo = () => [|f|]([|f|], g); +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file From 4143d1df7fc36410cd9323200765bc27a3f065b5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 29 Jun 2015 10:29:23 -0400 Subject: [PATCH 170/250] Addressed CR feedback. --- src/services/services.ts | 9 ++++++--- src/services/utilities.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 21537f0fa1481..b0bf52291c07b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4965,7 +4965,8 @@ namespace ts { // Compute the meaning from the location and the symbol it references let searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for, we need to normalize it as external module names will have quotes + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. let declaredName = getDeclaredName(typeChecker, symbol, node); // Try to get the smallest valid scope that we can limit our search to; @@ -5019,7 +5020,7 @@ namespace ts { }); } - function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]) { + function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever under the cursor. if (isImportOrExportSpecifierName(location)) { @@ -5036,8 +5037,10 @@ namespace ts { /** * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. * - * Returns undefined if the scope cannot be determined, often implying that + * @returns undefined if the scope cannot be determined, implying that * a reference to a symbol can occur anywhere. */ function getSymbolScope(symbol: Symbol): Node { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a6834e1230d7d..0fd945caa7d3b 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -653,7 +653,7 @@ namespace ts { }); } - export function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node) { + export function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever is under the cursor. if (isImportOrExportSpecifierName(location)) { From cdc8c3b5fb10ae6cb9fa43045b4717b9b8593ad4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 29 Jun 2015 11:09:40 -0400 Subject: [PATCH 171/250] Use full display name in tests. This is a modified revert of 33693e8 --- tests/cases/fourslash/renameForDefaultExport04.ts | 3 ++- tests/cases/fourslash/renameForDefaultExport05.ts | 3 ++- tests/cases/fourslash/renameForDefaultExport06.ts | 3 ++- tests/cases/fourslash/renameForDefaultExport07.ts | 3 ++- tests/cases/fourslash/renameForDefaultExport08.ts | 3 ++- tests/cases/fourslash/renameForDefaultExport09.ts | 1 + 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/cases/fourslash/renameForDefaultExport04.ts b/tests/cases/fourslash/renameForDefaultExport04.ts index 8c4e2733e33e1..ba40374e262ea 100644 --- a/tests/cases/fourslash/renameForDefaultExport04.ts +++ b/tests/cases/fourslash/renameForDefaultExport04.ts @@ -1,5 +1,6 @@ /// +// @Filename: foo.ts ////export default class /**/[|DefaultExportedClass|] { ////} /////* @@ -11,4 +12,4 @@ ////var y = new DefaultExportedClass; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport05.ts b/tests/cases/fourslash/renameForDefaultExport05.ts index f6c87d936dae5..099f878bda1bb 100644 --- a/tests/cases/fourslash/renameForDefaultExport05.ts +++ b/tests/cases/fourslash/renameForDefaultExport05.ts @@ -1,5 +1,6 @@ /// +// @Filename: foo.ts ////export default class DefaultExportedClass { ////} /////* @@ -11,4 +12,4 @@ ////var y = new DefaultExportedClass; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport06.ts b/tests/cases/fourslash/renameForDefaultExport06.ts index 083fd29054a66..3ec067b7029ed 100644 --- a/tests/cases/fourslash/renameForDefaultExport06.ts +++ b/tests/cases/fourslash/renameForDefaultExport06.ts @@ -1,5 +1,6 @@ /// +// @Filename: foo.ts ////export default class DefaultExportedClass { ////} /////* @@ -11,4 +12,4 @@ ////var y = new /**/[|DefaultExportedClass|]; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport07.ts b/tests/cases/fourslash/renameForDefaultExport07.ts index 2c718a1202bc0..b65f348f2a067 100644 --- a/tests/cases/fourslash/renameForDefaultExport07.ts +++ b/tests/cases/fourslash/renameForDefaultExport07.ts @@ -1,5 +1,6 @@ /// +// @Filename: foo.ts ////export default function /**/[|DefaultExportedFunction|]() { //// return DefaultExportedFunction ////} @@ -12,4 +13,4 @@ ////var y = DefaultExportedFunction(); goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedFunction"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport08.ts b/tests/cases/fourslash/renameForDefaultExport08.ts index 29064180d58fb..9b3f23db2c1ac 100644 --- a/tests/cases/fourslash/renameForDefaultExport08.ts +++ b/tests/cases/fourslash/renameForDefaultExport08.ts @@ -1,5 +1,6 @@ /// +// @Filename: foo.ts ////export default function DefaultExportedFunction() { //// return /**/[|DefaultExportedFunction|] ////} @@ -12,4 +13,4 @@ ////var y = DefaultExportedFunction(); goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedFunction"); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport09.ts b/tests/cases/fourslash/renameForDefaultExport09.ts index 568eb18a84ef8..bba2e57f49ea6 100644 --- a/tests/cases/fourslash/renameForDefaultExport09.ts +++ b/tests/cases/fourslash/renameForDefaultExport09.ts @@ -1,5 +1,6 @@ /// +// @Filename: foo.ts ////function /**/[|f|]() { //// return 100; ////} From 042f1fc4a8ca9fa51c52480bb8f97025f689b913 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 09:07:12 -0700 Subject: [PATCH 172/250] Update for style :tophat: --- src/compiler/checker.ts | 8 +++--- src/compiler/emitter.ts | 60 ++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f3f87f05c0e45..019fd8faf36b7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6764,7 +6764,7 @@ namespace ts { */ function isUnhyphenatedJsxName(name: string) { // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers - return name.indexOf('-') < 0; + return name.indexOf("-") < 0; } /** @@ -6961,7 +6961,7 @@ namespace ts { /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), - /// or '' if it has 0 properties (which means all + /// or '' if it has 0 properties (which means every /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX @@ -6976,7 +6976,7 @@ namespace ts { if (attribProperties) { // Element Attributes has zero properties, so the element attributes type will be the class instance type if (attribProperties.length === 0) { - return ''; + return ""; } // Element Attributes has one property, so the element attributes type will be the type of the corresponding // property of the class instance type @@ -7016,7 +7016,7 @@ namespace ts { // There is no type ElementAttributesProperty, return 'any' return links.resolvedJsxType = anyType; } - else if (propsName === '') { + else if (propsName === "") { // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead return links.resolvedJsxType = elemInstanceType; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3b1a1609c3948..4e6bc5f687d88 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1140,80 +1140,80 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { /// Emit an name/value pair for an attribute (e.g. "x: 3") function emitJsxAttribute(node: JsxAttribute) { emitAttributeName(node.name); - write(': '); + write(": "); if (node.initializer) { emit(node.initializer); } else { - write('true'); + write("true"); } } function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write('React.createElement('); + write("React.createElement("); emitTagName(openingNode.tagName); - write(', '); + write(", "); // Attribute list if (openingNode.attributes.length === 0) { - // When there are no attributes, React wants 'null' - write('null'); + // When there are no attributes, React wants "null" + write("null"); } else { // Either emit one big object literal (no spread attribs), or // a call to React.__spread let attrs = openingNode.attributes; if (attrs.some(attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { - write('React.__spread('); + write("React.__spread("); let haveOpenedObjectLiteral = false; for (let i = 0; i < attrs.length; i++) { if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { // If this is the first argument, we need to emit a {} as the first argument if (i === 0) { - write('{}, '); + write("{}, "); } if (haveOpenedObjectLiteral) { - write('}'); + write("}"); haveOpenedObjectLiteral = false; } if (i > 0) { - write(', '); + write(", "); } emit((attrs[i]).expression); } else { Debug.assert(attrs[i].kind === SyntaxKind.JsxAttribute); if (haveOpenedObjectLiteral) { - write(', '); + write(", "); } else { haveOpenedObjectLiteral = true; if (i > 0) { - write(', '); + write(", "); } - write('{'); + write("{"); } emitJsxAttribute(attrs[i]); } } - if (haveOpenedObjectLiteral) write('}'); + if (haveOpenedObjectLiteral) write("}"); - write(')'); // closing paren to React.__spread( + write(")"); // closing paren to React.__spread( } else { // One object literal with all the attributes in them - write('{'); + write("{"); for (var i = 0; i < attrs.length; i++) { if (i > 0) { - write(', '); + write(", "); } emitJsxAttribute(attrs[i]); } - write('}'); + write("}"); } } @@ -1235,7 +1235,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } else { - write(', '); + write(", "); emit(children[i]); } @@ -1243,7 +1243,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } // Closing paren - write(')'); // closes 'React.createElement(' + write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } @@ -1259,20 +1259,20 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { function emitJsxAttribute(node: JsxAttribute) { emit(node.name); - write('='); + write("="); emit(node.initializer); } function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { - write('{...'); + write("{..."); emit(node.expression); - write('}'); + write("}"); } function emitAttributes(attribs: NodeArray) { for (let i = 0, n = attribs.length; i < n; i++) { if (i > 0) { - write(' '); + write(" "); } if (attribs[i].kind === SyntaxKind.JsxSpreadAttribute) { @@ -1286,26 +1286,26 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitJsxOpeningOrSelfClosingElement(node: JsxOpeningElement|JsxSelfClosingElement) { - write('<'); + write("<"); emit(node.tagName); if (node.attributes.length > 0 || (node.kind === SyntaxKind.JsxSelfClosingElement)) { - write(' '); + write(" "); } emitAttributes(node.attributes); if (node.kind === SyntaxKind.JsxSelfClosingElement) { - write('/>'); + write("/>"); } else { - write('>'); + write(">"); } } function emitJsxClosingElement(node: JsxClosingElement) { - write(''); + write(">"); } function emitJsxElement(node: JsxElement) { From 1d09c6e9c1416fbcd01905bc5f8ed5f8fe26677f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 09:37:40 -0700 Subject: [PATCH 173/250] Don't use ES5 array APIs --- src/compiler/emitter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 451f32cc36b3d..32123c0a21f77 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -71,7 +71,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, host.getSourceFiles().some(shouldEmitJsx) ? ".jsx" : ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -1170,7 +1170,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // Either emit one big object literal (no spread attribs), or // a call to React.__spread let attrs = openingNode.attributes; - if (attrs.some(attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { + if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { write("React.__spread("); let haveOpenedObjectLiteral = false; From 3402f3556c3ceb12be8506116e15d65e5a761928 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 10:39:52 -0700 Subject: [PATCH 174/250] Missed a file in merge; use Tristate.True in arrow fn check --- scripts/errorCheck.ts | 87 ++++++++++++++++++++++++++++++++++++++++++ src/compiler/parser.ts | 2 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 scripts/errorCheck.ts diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts new file mode 100644 index 0000000000000..77892cb8f0ccb --- /dev/null +++ b/scripts/errorCheck.ts @@ -0,0 +1,87 @@ +declare var require: any; +let fs = require('fs'); +let async = require('async'); +let glob = require('glob'); + +fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { + if (err) { + throw err; + } + + let messages = JSON.parse(data); + let keys = Object.keys(messages); + console.log('Loaded ' + keys.length + ' errors'); + + for (let k of keys) { + messages[k]['seen'] = false; + } + + let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; + + let baseDir = 'tests/baselines/reference/'; + fs.readdir(baseDir, (err, files) => { + files = files.filter(f => f.indexOf('.errors.txt') > 0); + let tasks: Array<(callback: () => void) => void> = []; + files.forEach(f => tasks.push(done => { + fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { + if (err) throw err; + + let g: string[]; + while (g = errRegex.exec(baseline)) { + var errCode = +g[1]; + let msg = keys.filter(k => messages[k].code === errCode)[0]; + messages[msg]['seen'] = true; + } + + done(); + }); + })); + + async.parallelLimit(tasks, 25, done => { + console.log('== List of errors not present in baselines =='); + let count = 0; + for (let k of keys) { + if (messages[k]['seen'] !== true) { + console.log(k); + count++; + } + } + console.log(count + ' of ' + keys.length + ' errors are not in baselines'); + }); + }); +}); + +fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => { + let errorRegexp = /\s(\w+): \{ code/g; + let errorNames: string[] = []; + let errMatch: string[]; + while (errMatch = errorRegexp.exec(data)) { + errorNames.push(errMatch[1]); + } + + let allSrc: string = ''; + glob('./src/**/*.ts', {}, (err, files) => { + console.log('Reading ' + files.length + ' source files'); + for(let file of files) { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { + continue; + } + + let src = fs.readFileSync(file, 'utf-8'); + allSrc = allSrc + src; + } + + console.log('Consumed ' + allSrc.length + ' characters of source'); + + let count = 0; + console.log('== List of errors not used in source ==') + for(let errName of errorNames) { + if (allSrc.indexOf(errName) < 0) { + console.log(errName); + count++; + } + } + console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); + }); +}); + diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 866d7d9b2612b..b43345bcbf50a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2867,7 +2867,7 @@ namespace ts { }); if (isArrowFunctionInJsx) { - return Tristate.Unknown; + return Tristate.True; } return Tristate.False; From 430c2c8721113989ea7efa9bbe71ed96db6c0639 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 11:25:49 -0700 Subject: [PATCH 175/250] Correct flag JSX elements as being used for the purposes of module imports --- src/compiler/checker.ts | 9 +++ .../tsxExternalModuleEmit1.errors.txt | 35 +++++++++ .../reference/tsxExternalModuleEmit1.js | 71 +++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 tests/baselines/reference/tsxExternalModuleEmit1.errors.txt create mode 100644 tests/baselines/reference/tsxExternalModuleEmit1.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7f65ed7d50623..3e6ab5df5726c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7117,6 +7117,15 @@ namespace ts { let targetAttributesType = getJsxElementAttributesType(node); + if(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { + if(node.tagName.kind === SyntaxKind.Identifier) { + checkIdentifier(node.tagName); + } + else { + checkQualifiedName(node.tagName); + } + } + let nameTable: Map = {}; // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.errors.txt b/tests/baselines/reference/tsxExternalModuleEmit1.errors.txt new file mode 100644 index 0000000000000..7342aaa0f6ffd --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/jsx/button.tsx(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module 'react' { + class Component { } + } + +==== tests/cases/conformance/jsx/app.tsx (0 errors) ==== + import * as React from 'react'; + + // Should see var button_1 = require('./button') here + import { Button } from './button'; + + export class App extends React.Component { + + render() { + return ; + } + + } \ No newline at end of file diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js new file mode 100644 index 0000000000000..3e486eacef866 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +// Should see var button_1 = require('./button') here +import { Button } from './button'; + +export class App extends React.Component { + + render() { + return ; + } + +} + +//// [button.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Button = (function (_super) { + __extends(Button, _super); + function Button() { + _super.apply(this, arguments); + } + Button.prototype.render = function () { + return ; + }; + return Button; +})(React.Component); +exports.Button = Button; +//// [app.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +// Should see var button_1 = require('./button') here +var button_1 = require('./button'); +var App = (function (_super) { + __extends(App, _super); + function App() { + _super.apply(this, arguments); + } + App.prototype.render = function () { + return ; + }; + return App; +})(React.Component); +exports.App = App; From 8da353e169de5a9658049d4af9dce1570b7b4a21 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 11:39:10 -0700 Subject: [PATCH 176/250] Add spaces between if and ( --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3e6ab5df5726c..dbc49a9fd3fb5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7086,7 +7086,7 @@ namespace ts { let jsxElementClassType: Type = undefined; function getJsxGlobalElementClassType(): Type { - if(!jsxElementClassType) { + if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } return jsxElementClassType; @@ -7105,7 +7105,7 @@ namespace ts { } if (jsxElementType === undefined) { - if(compilerOptions.noImplicitAny) { + if (compilerOptions.noImplicitAny) { error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -7117,8 +7117,8 @@ namespace ts { let targetAttributesType = getJsxElementAttributesType(node); - if(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { - if(node.tagName.kind === SyntaxKind.Identifier) { + if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { + if (node.tagName.kind === SyntaxKind.Identifier) { checkIdentifier(node.tagName); } else { @@ -7138,7 +7138,7 @@ namespace ts { else { Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); let spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if(isTypeAny(spreadType)) { + if (isTypeAny(spreadType)) { sawSpreadedAny = true; } } @@ -12343,7 +12343,7 @@ namespace ts { } function checkTypePredicate(node: TypePredicateNode) { - if(!isInLegalTypePredicatePosition(node)) { + if (!isInLegalTypePredicatePosition(node)) { error(node, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); } } From 40d1719eb7527288799eea6c8424e66dcfa6b752 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 11:41:40 -0700 Subject: [PATCH 177/250] Add module setting + test files --- .../reference/tsxExternalModuleEmit1.symbols | 49 +++++++++++++++++ .../reference/tsxExternalModuleEmit1.types | 53 +++++++++++++++++++ .../jsx/tsxExternalModuleEmit1.tsx | 32 +++++++++++ 3 files changed, 134 insertions(+) create mode 100644 tests/baselines/reference/tsxExternalModuleEmit1.symbols create mode 100644 tests/baselines/reference/tsxExternalModuleEmit1.types create mode 100644 tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.symbols b/tests/baselines/reference/tsxExternalModuleEmit1.symbols new file mode 100644 index 0000000000000..5e8eb2fed4e55 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Symbol(Component, Decl(react.d.ts, 1, 24)) +>T : Symbol(T, Decl(react.d.ts, 2, 17)) +>U : Symbol(U, Decl(react.d.ts, 2, 19)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : Symbol(React, Decl(app.tsx, 0, 6)) + +// Should see var button_1 = require('./button') here +import { Button } from './button'; +>Button : Symbol(Button, Decl(app.tsx, 3, 8)) + +export class App extends React.Component { +>App : Symbol(App, Decl(app.tsx, 3, 34)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) +>React : Symbol(React, Decl(app.tsx, 0, 6)) +>Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) + + render() { +>render : Symbol(render, Decl(app.tsx, 5, 52)) + + return ; + } + +} diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.types b/tests/baselines/reference/tsxExternalModuleEmit1.types new file mode 100644 index 0000000000000..7e28c35dd13b7 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Component +>T : T +>U : U +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : typeof React + +// Should see var button_1 = require('./button') here +import { Button } from './button'; +>Button : typeof Button + +export class App extends React.Component { +>App : App +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component + + render() { +>render : () => any + + return ; +> : any +>button : any +>button : any + } + +} diff --git a/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx b/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx new file mode 100644 index 0000000000000..bb7f5c3f361c4 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx @@ -0,0 +1,32 @@ +//@jsx: preserve +//@module: commonjs + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +// Should see var button_1 = require('./button') here +import { Button } from './button'; + +export class App extends React.Component { + + render() { + return ; + } + +} \ No newline at end of file From 7b80001968fdcaf87fea0b50f17c1f8251b9f3db Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 12:03:13 -0700 Subject: [PATCH 178/250] Delete some files --- .../reference/jsxEsprimaFbTestSuite.symbols | 92 ---------- .../reference/jsxEsprimaFbTestSuite.types | 160 ------------------ .../reference/tsxElementResolution16.symbols | 18 -- .../reference/tsxElementResolution16.types | 20 --- .../tsxExternalModuleEmit1.errors.txt | 35 ---- 5 files changed, 325 deletions(-) delete mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.symbols delete mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.types delete mode 100644 tests/baselines/reference/tsxElementResolution16.symbols delete mode 100644 tests/baselines/reference/tsxElementResolution16.types delete mode 100644 tests/baselines/reference/tsxExternalModuleEmit1.errors.txt diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols deleted file mode 100644 index 570bf89f0a4c2..0000000000000 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols +++ /dev/null @@ -1,92 +0,0 @@ -=== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx === -declare var React: any; ->React : Symbol(React, Decl(jsxEsprimaFbTestSuite.tsx, 0, 11)) - -declare var 日本語; ->日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) - -declare var AbC_def; ->AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) - -declare var LeftRight; ->LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) - -declare var x; ->x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) - -declare var a; ->a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11)) - -declare var props; ->props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11)) - -; - -//; Namespace unsuported - -// {value} ; Namespace unsuported - -; ->b : Symbol(unknown) ->c : Symbol(unknown) ->d : Symbol(unknown) ->e : Symbol(unknown) ->f : Symbol(unknown) ->g : Symbol(unknown) ->h : Symbol(unknown) - -; ->b : Symbol(unknown) - -; - -<日本語>; - -AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) - - test="&&"> ->test : Symbol(unknown) - -bar -baz -; - - : } />; ->b : Symbol(unknown) ->x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) - -{}; - -{/* this is a comment */}; - -
@test content
; - -

7x invalid-js-identifier
; - - right=monkeys /> gorillas />; ->LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) ->left : Symbol(unknown) ->right : Symbol(unknown) - -; ->b : Symbol(unknown) - -; ->c : Symbol(unknown) - -(
) < x; ->x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) - -
; - -
; ->post : Symbol(unknown) - -
; ->pre : Symbol(unknown) ->pre2 : Symbol(unknown) - - ; - diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.types b/tests/baselines/reference/jsxEsprimaFbTestSuite.types deleted file mode 100644 index f32d62fd03f66..0000000000000 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.types +++ /dev/null @@ -1,160 +0,0 @@ -=== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx === -declare var React: any; ->React : any - -declare var 日本語; ->日本語 : any - -declare var AbC_def; ->AbC_def : any - -declare var LeftRight; ->LeftRight : any - -declare var x; ->x : any - -declare var a; ->a : any - -declare var props; ->props : any - -; -> : any ->a : any - -//; Namespace unsuported - -// {value} ; Namespace unsuported - -; -> : any ->a : any ->b : any ->c : any ->d : any ->e : any ->f : any ->g : any ->h : any - -; -> : any ->a : any ->b : any - - : any ->a : any - -/>; - -<日本語>; -><日本語> : any ->日本語 : any ->日本語 : any - -barbaz : any ->AbC_def : any - - test="&&"> ->test : any - -bar -baz -; ->AbC_def : any - - : } />; -> : } /> : any ->a : any ->b : any ->x ? : : any ->x : any -> : any ->c : any -> : any ->d : any - -{}; ->{} : any ->a : any ->a : any - -{/* this is a comment */}; ->{/* this is a comment */} : any ->a : any ->a : any - -
@test content
; ->
@test content
: any ->div : any ->div : any - -

7x invalid-js-identifier
; ->

7x invalid-js-identifier
: any ->div : any ->
: any ->br : any ->div : any - - right=monkeys /> gorillas />; -> right=monkeys /> gorillas /> : any ->LeftRight : any ->left : any -> : any ->a : any ->right : any ->monkeys /> gorillas : any ->b : any ->b : any - -; -> : any ->a : any ->b : any ->a : any ->b : any - -; -> : any ->a : any ->b : any ->c : any ->a : any ->b : any ->c : any - -(
) < x; ->(
) < x : boolean ->(
) : any ->
: any ->div : any ->x : any - -
; ->
: any ->div : any ->props : any - -
; ->
: any ->div : any ->props : any ->post : any - -
; ->
: any ->div : any ->pre : any ->pre2 : any ->props : any ->div : any - - ; ->
: any ->a : any ->a : any - diff --git a/tests/baselines/reference/tsxElementResolution16.symbols b/tests/baselines/reference/tsxElementResolution16.symbols deleted file mode 100644 index e01f19b991f48..0000000000000 --- a/tests/baselines/reference/tsxElementResolution16.symbols +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/conformance/jsx/tsxElementResolution16.tsx === -declare module JSX { ->JSX : Symbol(JSX, Decl(tsxElementResolution16.tsx, 0, 0)) -} - -interface Obj1 { ->Obj1 : Symbol(Obj1, Decl(tsxElementResolution16.tsx, 1, 1)) - - new(n: string): {}; ->n : Symbol(n, Decl(tsxElementResolution16.tsx, 4, 5)) -} -var obj1: Obj1; ->obj1 : Symbol(obj1, Decl(tsxElementResolution16.tsx, 6, 3)) ->Obj1 : Symbol(Obj1, Decl(tsxElementResolution16.tsx, 1, 1)) - -; // Error (JSX.Element is missing) ->x : Symbol(unknown) - diff --git a/tests/baselines/reference/tsxElementResolution16.types b/tests/baselines/reference/tsxElementResolution16.types deleted file mode 100644 index 3b8604e737d20..0000000000000 --- a/tests/baselines/reference/tsxElementResolution16.types +++ /dev/null @@ -1,20 +0,0 @@ -=== tests/cases/conformance/jsx/tsxElementResolution16.tsx === -declare module JSX { ->JSX : any -} - -interface Obj1 { ->Obj1 : Obj1 - - new(n: string): {}; ->n : string -} -var obj1: Obj1; ->obj1 : Obj1 ->Obj1 : Obj1 - -; // Error (JSX.Element is missing) -> : any ->obj1 : Obj1 ->x : any - diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.errors.txt b/tests/baselines/reference/tsxExternalModuleEmit1.errors.txt deleted file mode 100644 index 7342aaa0f6ffd..0000000000000 --- a/tests/baselines/reference/tsxExternalModuleEmit1.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -tests/cases/conformance/jsx/button.tsx(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. - - -==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== - - declare module 'react' { - class Component { } - } - -==== tests/cases/conformance/jsx/app.tsx (0 errors) ==== - import * as React from 'react'; - - // Should see var button_1 = require('./button') here - import { Button } from './button'; - - export class App extends React.Component { - - render() { - return ; - } - - } \ No newline at end of file From a183ba902016ad19929546593ffc85676e05ab90 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 29 Jun 2015 14:02:01 -0700 Subject: [PATCH 179/250] added flag as argument to checkTypeRelatedTo --- src/compiler/checker.ts | 81 +++++++++++++++++++++++++---------------- src/compiler/types.ts | 6 +++ 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efee668a24bd4..d9accf474dcf1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4263,11 +4263,11 @@ namespace ts { // TYPE CHECKING function isTypeIdenticalTo(source: Type, target: Type): boolean { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); + return checkTypeRelatedTo(source, target, identityRelation, RelationComparisonFlags.None, /*errorNode*/ undefined); } function compareTypes(source: Type, target: Type): Ternary { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; + return checkTypeRelatedTo(source, target, identityRelation, RelationComparisonFlags.None, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; } function isTypeSubtypeOf(source: Type, target: Type): boolean { @@ -4275,15 +4275,15 @@ namespace ts { } function isTypeAssignableTo(source: Type, target: Type): boolean { - return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); + return checkTypeAssignableTo(source, target, RelationComparisonFlags.None, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + return checkTypeRelatedTo(source, target, subtypeRelation, RelationComparisonFlags.None, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source: Type, target: Type, relationFlags: RelationComparisonFlags, errorNode?: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + return checkTypeRelatedTo(source, target, assignableRelation, relationFlags, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source: Signature, target: Signature): boolean { @@ -4292,13 +4292,30 @@ namespace ts { return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param relationFlags Additional information affecting whether the relation holds. Currently used only for distinguishing + * between a type comparison when extending classes from other comparisons of the constructor types. + * + * Caution: checks triggered by these flags should NOT affect the result re + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + + */ function checkTypeRelatedTo( source: Type, target: Type, relation: Map, - errorNode: Node, + relationFlags: RelationComparisonFlags, + errorNode?: Node, headMessage?: DiagnosticMessage, - containingMessageChain?: DiagnosticMessageChain): boolean { + containingMessageChain?: DiagnosticMessageChain + ): boolean { let errorInfo: DiagnosticMessageChain; let sourceStack: ObjectType[]; @@ -7212,6 +7229,7 @@ namespace ts { typeArgumentsAreAssignable = checkTypeAssignableTo( typeArgument, constraint, + RelationComparisonFlags.None, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); @@ -7243,7 +7261,7 @@ namespace ts { // Use argument expression as error location when reporting errors let errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; let headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { + if (!checkTypeRelatedTo(argType, paramType, relation, RelationComparisonFlags.None, errorNode, headMessage)) { return false; } } @@ -8040,7 +8058,7 @@ namespace ts { if (produceDiagnostics && targetType !== unknownType) { let widenedType = getWidenedType(exprType); if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + checkTypeAssignableTo(exprType, targetType, RelationComparisonFlags.None, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } } return targetType; @@ -8274,7 +8292,7 @@ namespace ts { else { let exprType = checkExpression(node.body); if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), RelationComparisonFlags.None, node.body, /*headMessage*/ undefined); } checkFunctionAndClassExpressionBodies(node.body); } @@ -8582,7 +8600,7 @@ namespace ts { function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type { let targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableTo(sourceType, targetType, RelationComparisonFlags.None, target, /*headMessage*/ undefined); } return sourceType; } @@ -8757,7 +8775,7 @@ namespace ts { // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, RelationComparisonFlags.None, node.left, /*headMessage*/ undefined); } } } @@ -8808,10 +8826,10 @@ namespace ts { if (func.type) { let signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, RelationComparisonFlags.None, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(expressionType, signatureElementType, RelationComparisonFlags.None, node.expression, /*headMessage*/ undefined); } } } @@ -9119,7 +9137,7 @@ namespace ts { else { checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), - typePredicateNode.type); + RelationComparisonFlags.None, typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -9197,7 +9215,7 @@ namespace ts { // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, RelationComparisonFlags.None, node.type); } } } @@ -9399,7 +9417,7 @@ namespace ts { let constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { let typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, RelationComparisonFlags.None, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } } return result; @@ -9836,6 +9854,7 @@ namespace ts { checkTypeAssignableTo( returnType, expectedReturnType, + RelationComparisonFlags.None, node, headMessage, errorInfo); @@ -10257,7 +10276,7 @@ namespace ts { // For a binding pattern, validate the initializer and exit if (isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), RelationComparisonFlags.None, node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -10267,7 +10286,7 @@ namespace ts { if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, RelationComparisonFlags.None, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -10279,7 +10298,7 @@ namespace ts { error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, RelationComparisonFlags.None, node, /*headMessage*/ undefined); } } if (node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.PropertySignature) { @@ -10331,7 +10350,7 @@ namespace ts { function checkExpressionStatement(node: ExpressionStatement) { // Grammar checking - checkGrammarStatementInAmbientContext(node) + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); } @@ -10415,7 +10434,7 @@ namespace ts { // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableTo(iteratedType, leftType, RelationComparisonFlags.None, varExpr, /*headMessage*/ undefined); } } } @@ -10515,7 +10534,7 @@ namespace ts { // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + checkTypeAssignableTo(iterable, createIterableType(elementType), RelationComparisonFlags.None, errorNode); } return elementType || anyType; @@ -10759,7 +10778,7 @@ namespace ts { } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, returnType, RelationComparisonFlags.None, node.expression, /*headMessage*/ undefined); } } } @@ -10802,7 +10821,7 @@ namespace ts { let caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(caseType, expressionType, RelationComparisonFlags.None, caseClause.expression, /*headMessage*/ undefined); } } forEach(clause.statements, checkSourceElement); @@ -11043,8 +11062,8 @@ namespace ts { } } } - checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, + checkTypeAssignableTo(type, baseType, RelationComparisonFlags.None, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), RelationComparisonFlags.ExtendingClass, node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -11072,7 +11091,7 @@ namespace ts { if (t !== unknownType) { let declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { - checkTypeAssignableTo(type, t, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(type, t, RelationComparisonFlags.None, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface); @@ -11255,7 +11274,7 @@ namespace ts { // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { forEach(getBaseTypes(type), baseType => { - checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); + checkTypeAssignableTo(type, baseType, RelationComparisonFlags.None, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); }); checkIndexConstraints(type); } @@ -11308,7 +11327,7 @@ namespace ts { // If it is a constant value (not undefined), it is syntactically constrained to be a number. // Also, we do not need to check this for ambients because there is already // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpression(initializer), enumType, RelationComparisonFlags.None, initializer, /*headMessage*/ undefined); } } else if (enumIsConst) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f3f203d4e8652..e588e1b1dea5e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -403,6 +403,12 @@ namespace ts { FailedAndReported = 3 } + /* @internal */ + export const enum RelationComparisonFlags { + None = 0, + ExtendingClass = 0x00000001 + } + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; From 342ae9614e62efa0da77ef194f1539682d7fe7de Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Jun 2015 14:30:11 -0700 Subject: [PATCH 180/250] Fix tabbing --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dbc49a9fd3fb5..34c19c763de5d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7119,10 +7119,10 @@ namespace ts { if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { if (node.tagName.kind === SyntaxKind.Identifier) { - checkIdentifier(node.tagName); + checkIdentifier(node.tagName); } else { - checkQualifiedName(node.tagName); + checkQualifiedName(node.tagName); } } From ded24410e6dbd86e9854530c6ea9a0f39a2e7976 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 29 Jun 2015 14:39:09 -0700 Subject: [PATCH 181/250] fixed a conflict --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3b9da04a4271b..590eceeb3020e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6843,7 +6843,7 @@ namespace ts { } if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + checkTypeAssignableTo(exprType, correspondingPropType, RelationComparisonFlags.None, node); } nameTable[node.name.text] = true; @@ -6860,7 +6860,7 @@ namespace ts { let targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); - checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), RelationComparisonFlags.None, node, undefined, msg); } nameTable[prop.name] = true; @@ -6988,7 +6988,7 @@ namespace ts { // Issue an error if this return type isn't assignable to JSX.ElementClass let elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, RelationComparisonFlags.None, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } return returnType; From e47e5bcbcd5e662cb00bff95a4edf62a6c78ac7d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 29 Jun 2015 15:08:22 -0700 Subject: [PATCH 182/250] fixed a comment --- src/compiler/checker.ts | 3 ++- src/compiler/core.ts | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 590eceeb3020e..c3edfed4804c1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4329,7 +4329,7 @@ namespace ts { * @param relationFlags Additional information affecting whether the relation holds. Currently used only for distinguishing * between a type comparison when extending classes from other comparisons of the constructor types. * - * Caution: checks triggered by these flags should NOT affect the result re + * Caution: checks triggered by these flags should NOT affect the result cached. * @param errorNode The node upon which all errors will be reported, if defined. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. @@ -4388,6 +4388,7 @@ namespace ts { // Ternary.False if they are not related. function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { let result: Ternary; + let relationFlagCheckResult: Ternary; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; if (relation !== identityRelation) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7b35c5e0d6587..c3d2a00eba519 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2,17 +2,19 @@ /* @internal */ namespace ts { - // Ternary values are defined such that - // x & y is False if either x or y is False. - // x & y is Maybe if either x or y is Maybe, but neither x or y is False. - // x & y is True if both x and y are True. - // x | y is False if both x and y are False. - // x | y is Maybe if either x or y is Maybe, but neither x or y is True. - // x | y is True if either x or y is True. + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ export const enum Ternary { False = 0, Maybe = 1, - True = -1 + True = -1 } export function createFileMap(getCanonicalFileName: (fileName: string) => string): FileMap { From 12383af2259e96c0f8795d10e4681a34f7363046 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 29 Jun 2015 17:20:10 -0700 Subject: [PATCH 183/250] Responding to Jason --- src/compiler/checker.ts | 132 ++++++++---------- src/compiler/core.ts | 6 +- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 4 files changed, 66 insertions(+), 76 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b2b44f9888772..27e500bc3f82d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4615,9 +4615,6 @@ namespace ts { result &= stringIndexTypesRelatedTo(source, target, reportErrors); if (result) { result &= numberIndexTypesRelatedTo(source, target, reportErrors); - // if(relation == subtypeRelation && result) { - // result &= abstractnessRelatedTo(source, target, reportErrors); - // } } } } @@ -4639,17 +4636,6 @@ namespace ts { return result; } - function abstractnessRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { - if ( source.symbol && target.symbol && getDeclarationFlagsFromSymbol(source.symbol) & NodeFlags.Abstract && - !(getDeclarationFlagsFromSymbol(target.symbol) & NodeFlags.Abstract)) { - if (reportErrors) { - reportError(Diagnostics.Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type); - } - return Ternary.False; - } - return Ternary.True; - } - function propertiesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -7320,7 +7306,6 @@ namespace ts { return unknownType; } - // TODO: Why is this line here? getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -11609,16 +11594,18 @@ namespace ts { } checkClassLikeDeclaration(node); - forEach(node.members, node.flags & NodeFlags.Abstract ? - checkSourceElement : - element => { - checkSourceElement(element); + forEach(node.members, checkSourceElement); - // Classes containing abstract methods must be marked abstract - if (element.flags & NodeFlags.Abstract) { - error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); - } - }); + // forEach(node.members, node.flags & NodeFlags.Abstract ? + // checkSourceElement : + // element => { + // checkSourceElement(element); + + // // Classes containing abstract methods must be marked abstract + // if (element.flags & NodeFlags.Abstract) { + // error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); + // } + // }); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { @@ -11732,57 +11719,59 @@ namespace ts { Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived === base) { - // derived class inherits base without override/redeclaration + if (derived) { + if (derived === base) { + // derived class inherits base without override/redeclaration - let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - Debug.assert(derivedClassDecl !== undefined); + let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); + Debug.assert(derivedClassDecl !== undefined); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - if ((baseDeclarationFlags & NodeFlags.Abstract) && !(derivedClassDecl.flags & NodeFlags.Abstract)) { - error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, - typeToString(type), symbolToString(baseProperty), typeToString(baseType)); - } - } - else { - // derived overrides base. - let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { - // either base or derived property is private - not override, skip it - continue; + // It is an error to inherit an abstract member without implementing it or being declared abstract. + if ((baseDeclarationFlags & NodeFlags.Abstract) && !(derivedClassDecl.flags & NodeFlags.Abstract)) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } + else { + // derived overrides base. + let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { + // either base or derived property is private - not override, skip it + continue; + } - if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } + if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } - if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } + if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } - let errorMessage: DiagnosticMessage; - if (base.flags & SymbolFlags.Method) { - if (derived.flags & SymbolFlags.Accessor) { - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + let errorMessage: DiagnosticMessage; + if (base.flags & SymbolFlags.Method) { + if (derived.flags & SymbolFlags.Accessor) { + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + Debug.assert((derived.flags & SymbolFlags.Property) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & SymbolFlags.Property) { + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert((derived.flags & SymbolFlags.Property) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - } - else if (base.flags & SymbolFlags.Property) { - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } } } } @@ -13854,13 +13843,14 @@ namespace ts { if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) { return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & NodeFlags.Private) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } } - if (flags & NodeFlags.Static) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - if (flags & NodeFlags.Private) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); - } + flags |= NodeFlags.Abstract; break; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6ae06ba428fc1..ec4c777852b59 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -62,9 +62,9 @@ namespace ts { export interface StringSet extends Map { } /** - * Iterates through 'array' by index and performs the callback on each element of array - * until the callback returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array. + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. */ export function forEach(array: T[], callback: (element: T, index: number) => U): U { if (array) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index d5109e40d5610..b5da91f199d22 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -387,7 +387,7 @@ namespace ts { Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be `abstract` or not `abstract." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9bbd298c7cd12..82d900056d1b5 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1535,7 +1535,7 @@ "category": "Error", "code": 2511 }, - "Overload signatures must all be `abstract` or not `abstract.": { + "Overload signatures must all be abstract or not abstract.": { "category": "Error", "code": 2512 }, From c517a6341eebc2cec794e4b4fd46b541c90a73ed Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 30 Jun 2015 12:02:23 -0700 Subject: [PATCH 184/250] Accepting new baselines --- .../reference/jsxEsprimaFbTestSuite.symbols | 92 ---------- .../reference/jsxEsprimaFbTestSuite.types | 160 ------------------ .../reference/tsxElementResolution16.symbols | 18 -- .../reference/tsxElementResolution16.types | 20 --- 4 files changed, 290 deletions(-) delete mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.symbols delete mode 100644 tests/baselines/reference/jsxEsprimaFbTestSuite.types delete mode 100644 tests/baselines/reference/tsxElementResolution16.symbols delete mode 100644 tests/baselines/reference/tsxElementResolution16.types diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols deleted file mode 100644 index 570bf89f0a4c2..0000000000000 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols +++ /dev/null @@ -1,92 +0,0 @@ -=== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx === -declare var React: any; ->React : Symbol(React, Decl(jsxEsprimaFbTestSuite.tsx, 0, 11)) - -declare var 日本語; ->日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) - -declare var AbC_def; ->AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) - -declare var LeftRight; ->LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) - -declare var x; ->x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) - -declare var a; ->a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11)) - -declare var props; ->props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11)) - -; - -//; Namespace unsuported - -// {value} ; Namespace unsuported - -; ->b : Symbol(unknown) ->c : Symbol(unknown) ->d : Symbol(unknown) ->e : Symbol(unknown) ->f : Symbol(unknown) ->g : Symbol(unknown) ->h : Symbol(unknown) - -; ->b : Symbol(unknown) - -; - -<日本語>; - -AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) - - test="&&"> ->test : Symbol(unknown) - -bar -baz -; - - : } />; ->b : Symbol(unknown) ->x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) - -{}; - -{/* this is a comment */}; - -
@test content
; - -

7x invalid-js-identifier
; - - right=monkeys /> gorillas />; ->LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) ->left : Symbol(unknown) ->right : Symbol(unknown) - -; ->b : Symbol(unknown) - -; ->c : Symbol(unknown) - -(
) < x; ->x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11)) - -
; - -
; ->post : Symbol(unknown) - -
; ->pre : Symbol(unknown) ->pre2 : Symbol(unknown) - - ; - diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.types b/tests/baselines/reference/jsxEsprimaFbTestSuite.types deleted file mode 100644 index f32d62fd03f66..0000000000000 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.types +++ /dev/null @@ -1,160 +0,0 @@ -=== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx === -declare var React: any; ->React : any - -declare var 日本語; ->日本語 : any - -declare var AbC_def; ->AbC_def : any - -declare var LeftRight; ->LeftRight : any - -declare var x; ->x : any - -declare var a; ->a : any - -declare var props; ->props : any - -; -> : any ->a : any - -//; Namespace unsuported - -// {value} ; Namespace unsuported - -; -> : any ->a : any ->b : any ->c : any ->d : any ->e : any ->f : any ->g : any ->h : any - -; -> : any ->a : any ->b : any - - : any ->a : any - -/>; - -<日本語>; -><日本語> : any ->日本語 : any ->日本語 : any - -barbaz : any ->AbC_def : any - - test="&&"> ->test : any - -bar -baz -; ->AbC_def : any - - : } />; -> : } /> : any ->a : any ->b : any ->x ? : : any ->x : any -> : any ->c : any -> : any ->d : any - -{}; ->{} : any ->a : any ->a : any - -{/* this is a comment */}; ->{/* this is a comment */} : any ->a : any ->a : any - -
@test content
; ->
@test content
: any ->div : any ->div : any - -

7x invalid-js-identifier
; ->

7x invalid-js-identifier
: any ->div : any ->
: any ->br : any ->div : any - - right=monkeys /> gorillas />; -> right=monkeys /> gorillas /> : any ->LeftRight : any ->left : any -> : any ->a : any ->right : any ->monkeys /> gorillas : any ->b : any ->b : any - -; -> : any ->a : any ->b : any ->a : any ->b : any - -; -> : any ->a : any ->b : any ->c : any ->a : any ->b : any ->c : any - -(
) < x; ->(
) < x : boolean ->(
) : any ->
: any ->div : any ->x : any - -
; ->
: any ->div : any ->props : any - -
; ->
: any ->div : any ->props : any ->post : any - -
; ->
: any ->div : any ->pre : any ->pre2 : any ->props : any ->div : any - - ; ->
: any ->a : any ->a : any - diff --git a/tests/baselines/reference/tsxElementResolution16.symbols b/tests/baselines/reference/tsxElementResolution16.symbols deleted file mode 100644 index e01f19b991f48..0000000000000 --- a/tests/baselines/reference/tsxElementResolution16.symbols +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/conformance/jsx/tsxElementResolution16.tsx === -declare module JSX { ->JSX : Symbol(JSX, Decl(tsxElementResolution16.tsx, 0, 0)) -} - -interface Obj1 { ->Obj1 : Symbol(Obj1, Decl(tsxElementResolution16.tsx, 1, 1)) - - new(n: string): {}; ->n : Symbol(n, Decl(tsxElementResolution16.tsx, 4, 5)) -} -var obj1: Obj1; ->obj1 : Symbol(obj1, Decl(tsxElementResolution16.tsx, 6, 3)) ->Obj1 : Symbol(Obj1, Decl(tsxElementResolution16.tsx, 1, 1)) - -; // Error (JSX.Element is missing) ->x : Symbol(unknown) - diff --git a/tests/baselines/reference/tsxElementResolution16.types b/tests/baselines/reference/tsxElementResolution16.types deleted file mode 100644 index 3b8604e737d20..0000000000000 --- a/tests/baselines/reference/tsxElementResolution16.types +++ /dev/null @@ -1,20 +0,0 @@ -=== tests/cases/conformance/jsx/tsxElementResolution16.tsx === -declare module JSX { ->JSX : any -} - -interface Obj1 { ->Obj1 : Obj1 - - new(n: string): {}; ->n : string -} -var obj1: Obj1; ->obj1 : Obj1 ->Obj1 : Obj1 - -; // Error (JSX.Element is missing) -> : any ->obj1 : Obj1 ->x : any - From 6ae775b4ff43b075e158014aaf54dc0fdf7414fe Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 30 Jun 2015 12:23:21 -0700 Subject: [PATCH 185/250] Support intersection types as target in type inference --- src/compiler/checker.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d90275a4eb1f2..10f7b530330f2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5408,11 +5408,11 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & TypeFlags.Union) { - let targetTypes = (target).types; + else if (target.flags & TypeFlags.UnionOrIntersection) { + let targetTypes = (target).types; let typeParameterCount = 0; let typeParameter: TypeParameter; - // First infer to each type in union that isn't a type parameter + // First infer to each type in union or intersection that isn't a type parameter for (let t of targetTypes) { if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) { typeParameter = t; @@ -5422,8 +5422,9 @@ namespace ts { inferFromTypes(source, t); } } - // If union contains a single naked type parameter, make a secondary inference to that type parameter - if (typeParameterCount === 1) { + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter + if (target.flags & TypeFlags.Union && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; From fb1bf420b4ca1847330a0af894406c769322bf31 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 30 Jun 2015 12:41:03 -0700 Subject: [PATCH 186/250] Adding test for inference with intersection type as target --- .../intersectionTypeInference.errors.txt | 20 +++++++++++++++--- .../reference/intersectionTypeInference.js | 21 ++++++++++++++++++- .../intersection/intersectionTypeInference.ts | 16 +++++++++++++- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/tests/baselines/reference/intersectionTypeInference.errors.txt b/tests/baselines/reference/intersectionTypeInference.errors.txt index 33c24e111dcf8..af0b1b447bcaf 100644 --- a/tests/baselines/reference/intersectionTypeInference.errors.txt +++ b/tests/baselines/reference/intersectionTypeInference.errors.txt @@ -1,11 +1,10 @@ -tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): error TS2322: Type 'T' is not assignable to type 'T & U'. +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(5,5): error TS2322: Type 'T' is not assignable to type 'T & U'. Type 'T' is not assignable to type 'U'. -tests/cases/conformance/types/intersection/intersectionTypeInference.ts(7,5): error TS2322: Type 'U' is not assignable to type 'T & U'. +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): error TS2322: Type 'U' is not assignable to type 'T & U'. Type 'U' is not assignable to type 'T'. ==== tests/cases/conformance/types/intersection/intersectionTypeInference.ts (2 errors) ==== - function extend(obj1: T, obj2: U): T & U { var result: T & U; obj1 = result; @@ -24,4 +23,19 @@ tests/cases/conformance/types/intersection/intersectionTypeInference.ts(7,5): er var x = extend({ a: "hello" }, { b: 42 }); var s = x.a; var n = x.b; + + interface A { + a: T; + } + + interface B { + b: U; + } + + function foo(obj: A & B): T | U { + return undefined; + } + + var z = foo({ a: "hello", b: 42 }); + var z: string | number; \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeInference.js b/tests/baselines/reference/intersectionTypeInference.js index 0b95879a6c02a..8e7f1238c0707 100644 --- a/tests/baselines/reference/intersectionTypeInference.js +++ b/tests/baselines/reference/intersectionTypeInference.js @@ -1,5 +1,4 @@ //// [intersectionTypeInference.ts] - function extend(obj1: T, obj2: U): T & U { var result: T & U; obj1 = result; @@ -12,6 +11,21 @@ function extend(obj1: T, obj2: U): T & U { var x = extend({ a: "hello" }, { b: 42 }); var s = x.a; var n = x.b; + +interface A { + a: T; +} + +interface B { + b: U; +} + +function foo(obj: A & B): T | U { + return undefined; +} + +var z = foo({ a: "hello", b: 42 }); +var z: string | number; //// [intersectionTypeInference.js] @@ -26,3 +40,8 @@ function extend(obj1, obj2) { var x = extend({ a: "hello" }, { b: 42 }); var s = x.a; var n = x.b; +function foo(obj) { + return undefined; +} +var z = foo({ a: "hello", b: 42 }); +var z; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeInference.ts b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts index 3126ce09448b5..32a419ff03a55 100644 --- a/tests/cases/conformance/types/intersection/intersectionTypeInference.ts +++ b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts @@ -1,4 +1,3 @@ - function extend(obj1: T, obj2: U): T & U { var result: T & U; obj1 = result; @@ -11,3 +10,18 @@ function extend(obj1: T, obj2: U): T & U { var x = extend({ a: "hello" }, { b: 42 }); var s = x.a; var n = x.b; + +interface A { + a: T; +} + +interface B { + b: U; +} + +function foo(obj: A & B): T | U { + return undefined; +} + +var z = foo({ a: "hello", b: 42 }); +var z: string | number; From 18d6e73aa0d8724516be86bf9cf28d2f96261cf2 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 30 Jun 2015 14:33:13 -0700 Subject: [PATCH 187/250] Revert isRelatedFlags changes --- src/compiler/checker.ts | 221 ++++++++++++--------------- src/compiler/diagnosticMessages.json | 2 +- src/compiler/types.ts | 8 +- 3 files changed, 102 insertions(+), 129 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 27e500bc3f82d..0a46e279a7525 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2221,8 +2221,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -3822,8 +3822,8 @@ namespace ts { */ function createTypedPropertyDescriptorType(propertyType: Type): Type { let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -4291,27 +4291,27 @@ namespace ts { // TYPE CHECKING function isTypeIdenticalTo(source: Type, target: Type): boolean { - return checkTypeRelatedTo(source, target, identityRelation, RelationComparisonFlags.None, /*errorNode*/ undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source: Type, target: Type): Ternary { - return checkTypeRelatedTo(source, target, identityRelation, RelationComparisonFlags.None, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; } function isTypeSubtypeOf(source: Type, target: Type): boolean { - return checkTypeSubtypeOf(source, target, /*context*/ undefined, /*errorNode*/ undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source: Type, target: Type): boolean { - return checkTypeAssignableTo(source, target, RelationComparisonFlags.None, /*errorNode*/ undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { - return checkTypeRelatedTo(source, target, subtypeRelation, RelationComparisonFlags.None, errorNode, headMessage, containingMessageChain); + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source: Type, target: Type, relationFlags: RelationComparisonFlags, errorNode?: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { - return checkTypeRelatedTo(source, target, assignableRelation, relationFlags, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source: Signature, target: Signature): boolean { @@ -4326,24 +4326,17 @@ namespace ts { * @param target The right-hand-side of the relation. * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param relationFlags Additional information affecting whether the relation holds. Currently used only for distinguishing - * between a type comparison when extending classes from other comparisons of the constructor types. - * - * Caution: checks triggered by these flags should NOT affect the result cached. * @param errorNode The node upon which all errors will be reported, if defined. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. - */ function checkTypeRelatedTo( source: Type, target: Type, relation: Map, - relationFlags: RelationComparisonFlags, - errorNode?: Node, + errorNode: Node, headMessage?: DiagnosticMessage, - containingMessageChain?: DiagnosticMessageChain - ): boolean { + containingMessageChain?: DiagnosticMessageChain): boolean { let errorInfo: DiagnosticMessageChain; let sourceStack: ObjectType[]; @@ -4388,7 +4381,6 @@ namespace ts { // Ternary.False if they are not related. function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { let result: Ternary; - let relationFlagCheckResult: Ternary; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; if (relation !== identityRelation) { @@ -6089,20 +6081,20 @@ namespace ts { if (container && isClassLike(container.parent)) { 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; } } } @@ -6779,7 +6771,7 @@ namespace ts { checkJsxOpeningLikeElement(node.openingElement); // Check children - for(let child of node.children) { + for (let child of node.children) { switch (child.kind) { case SyntaxKind.JsxExpression: checkJsxExpression(child); @@ -6830,7 +6822,7 @@ namespace ts { else if (elementAttributesType && !isTypeAny(elementAttributesType)) { let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error + // If there's no corresponding property with this name, error if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); return unknownType; @@ -6847,7 +6839,7 @@ namespace ts { } if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, RelationComparisonFlags.None, node); + checkTypeAssignableTo(exprType, correspondingPropType, node); } nameTable[node.name.text] = true; @@ -6857,14 +6849,14 @@ namespace ts { function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { let type = checkExpression(node.expression); let props = getPropertiesOfType(type); - for(let prop of props) { + for (let prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { let targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); - checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), RelationComparisonFlags.None, node, undefined, msg); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); } nameTable[prop.name] = true; @@ -6937,7 +6929,7 @@ namespace ts { else { valueSymbol = checkQualifiedName(node.tagName).symbol; } - + if (valueSymbol !== unknownSymbol) { links.jsxFlags |= JsxFlags.ClassElement; } @@ -6992,7 +6984,7 @@ namespace ts { // Issue an error if this return type isn't assignable to JSX.ElementClass let elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, RelationComparisonFlags.None, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } return returnType; @@ -7107,7 +7099,7 @@ namespace ts { let jsxElementClassType: Type = undefined; function getJsxGlobalElementClassType(): Type { - if(!jsxElementClassType) { + if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } return jsxElementClassType; @@ -7126,7 +7118,7 @@ namespace ts { } if (jsxElementType === undefined) { - if(compilerOptions.noImplicitAny) { + if (compilerOptions.noImplicitAny) { error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -7150,7 +7142,7 @@ namespace ts { else { Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); let spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if(isTypeAny(spreadType)) { + if (isTypeAny(spreadType)) { sawSpreadedAny = true; } } @@ -7305,7 +7297,7 @@ namespace ts { } return unknownType; } - + getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -7570,7 +7562,7 @@ namespace ts { let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments let isDecorator: boolean; let spreadArgIndex = -1; - + if (node.kind === SyntaxKind.TaggedTemplateExpression) { let tagExpression = node; @@ -7751,18 +7743,17 @@ namespace ts { errorInfo = chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); typeArgumentHeadMessage = headMessage; } - + typeArgumentsAreAssignable = checkTypeAssignableTo( - typeArgument, - constraint, - RelationComparisonFlags.None, + typeArgument, + constraint, reportErrors ? typeArgNode : undefined, - typeArgumentHeadMessage, + typeArgumentHeadMessage, errorInfo); } } } - + return typeArgumentsAreAssignable; } @@ -7787,12 +7778,12 @@ namespace ts { // Use argument expression as error location when reporting errors let errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; let headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, RelationComparisonFlags.None, errorNode, headMessage)) { + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } } } - + return true; } @@ -7898,7 +7889,7 @@ namespace ts { // "static" or "constructor" side of the class) let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - + case SyntaxKind.Parameter: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. @@ -7908,7 +7899,7 @@ namespace ts { return getTypeOfSymbol(classSymbol); } - // fall-through + // fall-through case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -7919,7 +7910,7 @@ namespace ts { // declared "static"; otherwise, it is the "instance"-side type of the // parent of the member. return getParentTypeOfClassElement(node); - + default: Debug.fail("Unsupported decorator target."); return unknownType; @@ -7947,7 +7938,7 @@ namespace ts { case SyntaxKind.ClassDeclaration: Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - + case SyntaxKind.Parameter: node = node.parent; if (node.kind === SyntaxKind.Constructor) { @@ -7955,10 +7946,10 @@ namespace ts { return anyType; } - // For a non-constructor parameter decorator, the `propertyKey` will be either - // a string or a symbol, based on the name of the parameter's containing method. + // For a non-constructor parameter decorator, the `propertyKey` will be either + // a string or a symbol, based on the name of the parameter's containing method. - // fall-through + // fall-through case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -7974,7 +7965,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: return getStringLiteralType(element.name); - + case SyntaxKind.ComputedPropertyName: let nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) { @@ -7983,13 +7974,13 @@ namespace ts { else { return stringType; } - + default: Debug.fail("Unsupported property name."); return unknownType; } - + default: Debug.fail("Unsupported decorator target."); return unknownType; @@ -8026,7 +8017,7 @@ namespace ts { // for the type of the member. let propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); - + default: Debug.fail("Unsupported decorator target."); return unknownType; @@ -8079,7 +8070,7 @@ namespace ts { (argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression)) { return undefined; } - + return args[argIndex]; } @@ -8099,7 +8090,7 @@ namespace ts { return arg; } } - + function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[], headMessage?: DiagnosticMessage): Signature { let isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; let isDecorator = node.kind === SyntaxKind.Decorator; @@ -8227,7 +8218,7 @@ namespace ts { let diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - + if (headMessage) { diagnosticChainHead = chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -8253,7 +8244,7 @@ namespace ts { } return resolveErrorCall(node); - + function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { let errorInfo: DiagnosticMessageChain; errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); @@ -8484,13 +8475,13 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: return Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - + case SyntaxKind.Parameter: return Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - + case SyntaxKind.PropertyDeclaration: return Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - + case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: @@ -8507,12 +8498,12 @@ namespace ts { if (apparentType === unknownType) { return resolveErrorCall(node); } - + let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { return resolveUntypedCall(node); } - + let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { let errorInfo: DiagnosticMessageChain; @@ -8521,7 +8512,7 @@ namespace ts { diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); return resolveErrorCall(node); } - + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } @@ -8596,7 +8587,7 @@ namespace ts { if (produceDiagnostics && targetType !== unknownType) { let widenedType = getWidenedType(exprType); if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, RelationComparisonFlags.None, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } } return targetType; @@ -8763,6 +8754,7 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); + // Grammar checking let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { @@ -8829,7 +8821,7 @@ namespace ts { else { let exprType = checkExpression(node.body); if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), RelationComparisonFlags.None, node.body, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); } checkFunctionAndClassExpressionBodies(node.body); } @@ -9057,8 +9049,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -9137,7 +9129,7 @@ namespace ts { function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type { let targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, RelationComparisonFlags.None, target, /*headMessage*/ undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } @@ -9312,7 +9304,7 @@ namespace ts { // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, RelationComparisonFlags.None, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -9363,10 +9355,10 @@ namespace ts { if (func.type) { let signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, RelationComparisonFlags.None, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, RelationComparisonFlags.None, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -9683,7 +9675,7 @@ namespace ts { else { checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), - RelationComparisonFlags.None, typePredicateNode.type); + typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -9761,7 +9753,7 @@ namespace ts { // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, RelationComparisonFlags.None, node.type); + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } } @@ -9963,7 +9955,7 @@ namespace ts { let constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { let typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, RelationComparisonFlags.None, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } } return result; @@ -10179,7 +10171,7 @@ namespace ts { // the node in question is abstract. if (node.flags & NodeFlags.Abstract) { error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); - } + } else { error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); } @@ -10379,8 +10371,8 @@ namespace ts { if (returnType.flags & TypeFlags.Any) { return; } - - let expectedReturnType: Type; + + let expectedReturnType: Type; let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); let errorInfo: DiagnosticMessageChain; switch (node.parent.kind) { @@ -10397,7 +10389,7 @@ namespace ts { Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - + case SyntaxKind.PropertyDeclaration: expectedReturnType = voidType; errorInfo = chainDiagnosticMessages( @@ -10413,13 +10405,12 @@ namespace ts { expectedReturnType = getUnionType([descriptorType, voidType]); break; } - + checkTypeAssignableTo( - returnType, - expectedReturnType, - RelationComparisonFlags.None, - node, - headMessage, + returnType, + expectedReturnType, + node, + headMessage, errorInfo); } @@ -10839,7 +10830,7 @@ namespace ts { // For a binding pattern, validate the initializer and exit if (isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), RelationComparisonFlags.None, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -10849,7 +10840,7 @@ namespace ts { if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, RelationComparisonFlags.None, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -10861,7 +10852,7 @@ namespace ts { error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, RelationComparisonFlags.None, node, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } if (node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.PropertySignature) { @@ -10997,7 +10988,7 @@ namespace ts { // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, RelationComparisonFlags.None, varExpr, /*headMessage*/ undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -11097,7 +11088,7 @@ namespace ts { // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), RelationComparisonFlags.None, errorNode); + checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); } return elementType || anyType; @@ -11341,7 +11332,7 @@ namespace ts { } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, RelationComparisonFlags.None, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); } } } @@ -11384,7 +11375,7 @@ namespace ts { let caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, RelationComparisonFlags.None, caseClause.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } forEach(clause.statements, checkSourceElement); @@ -11593,19 +11584,7 @@ namespace ts { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); - forEach(node.members, checkSourceElement); - - // forEach(node.members, node.flags & NodeFlags.Abstract ? - // checkSourceElement : - // element => { - // checkSourceElement(element); - - // // Classes containing abstract methods must be marked abstract - // if (element.flags & NodeFlags.Abstract) { - // error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract); - // } - // }); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { @@ -11637,8 +11616,8 @@ namespace ts { } } } - checkTypeAssignableTo(type, baseType, RelationComparisonFlags.None, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), RelationComparisonFlags.ExtendingClass, node.name || node, + checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { @@ -11667,7 +11646,7 @@ namespace ts { if (t !== unknownType) { let declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { - checkTypeAssignableTo(type, t, RelationComparisonFlags.None, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(type, t, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface); @@ -11868,7 +11847,7 @@ namespace ts { // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { forEach(getBaseTypes(type), baseType => { - checkTypeAssignableTo(type, baseType, RelationComparisonFlags.None, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); + checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); }); checkIndexConstraints(type); } @@ -11921,7 +11900,7 @@ namespace ts { // If it is a constant value (not undefined), it is syntactically constrained to be a number. // Also, we do not need to check this for ambients because there is already // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, RelationComparisonFlags.None, initializer, /*headMessage*/ undefined); + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); } } else if (enumIsConst) { @@ -12794,7 +12773,7 @@ namespace ts { if ((location).name) { copySymbol(location.symbol, meaning); } - // Fall through + // Fall through case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: if (!(memberFlags & NodeFlags.Static)) { @@ -13106,7 +13085,7 @@ namespace ts { */ function getParentTypeOfClassElement(node: ClassElement) { let classSymbol = getSymbolOfNode(node.parent); - return node.flags & NodeFlags.Static + return node.flags & NodeFlags.Static ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -13200,7 +13179,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 82d900056d1b5..d0b29a893177b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -727,7 +727,7 @@ "category": "Error", "code": 1241 }, - "'abstract' modifier can only appear on a class or method declaration.": { + "'abstract' modifier can only appear on a class or method declaration.": { "category": "Error", "code": 1242 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b269bbd9d6826..b09adbf7cd023 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -357,7 +357,7 @@ namespace ts { Private = 0x00000020, // Property/Method Protected = 0x00000040, // Property/Method Static = 0x00000080, // Property/Method - Abstract = 0x00000100, + Abstract = 0x00000100, // Class/Method/Constructor Default = 0x00000200, // Function/Class (export default declaration) MultiLine = 0x00000400, // Multi-line array or object literal Synthetic = 0x00000800, // Synthetic node (for full fidelity) @@ -429,12 +429,6 @@ namespace ts { FailedAndReported = 3 } - /* @internal */ - export const enum RelationComparisonFlags { - None = 0, - ExtendingClass = 0x00000001 - } - export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; From 5864a66fbcc2af1d3fb4af6ad0d8ad047163dfba Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 30 Jun 2015 14:44:13 -0700 Subject: [PATCH 188/250] updated baselines on classAbstract tests --- tests/baselines/reference/APISample_linter.js | 146 +++++++++--------- .../classAbstractConstructor.errors.txt | 4 +- .../classAbstractDeclarations.d.errors.txt | 4 +- .../classAbstractInstantiations2.errors.txt | 13 +- ...bstractMethodWithImplementation.errors.txt | 4 +- ...classAbstractMixedWithModifiers.errors.txt | 16 +- .../classAbstractOverloads.errors.txt | 12 +- .../classAbstractProperties.errors.txt | 24 +-- ...ssAbstractUsingAbstractMethods2.errors.txt | 9 +- .../classAbstractWithInterface.errors.txt | 4 +- 10 files changed, 115 insertions(+), 121 deletions(-) diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 7cf6038cdb192..2eb3f924f704e 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1,67 +1,67 @@ //// [APISample_linter.ts] - -/* - * Note: This test is a public API sample. The sample sources can be found - at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter - * Please log a "breaking change" issue for any API breaking change affecting this issue - */ - -declare var process: any; -declare var console: any; -declare var readFileSync: any; - -import * as ts from "typescript"; - -export function delint(sourceFile: ts.SourceFile) { - delintNode(sourceFile); - - function delintNode(node: ts.Node) { - switch (node.kind) { - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: - if ((node).statement.kind !== ts.SyntaxKind.Block) { - report(node, "A looping statement's contents should be wrapped in a block body."); - } - break; - - case ts.SyntaxKind.IfStatement: - let ifStatement = (node); - if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { - report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); - } - if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && - ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { - report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); - } - break; - - case ts.SyntaxKind.BinaryExpression: - let op = (node).operatorToken.kind; - if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { - report(node, "Use '===' and '!=='.") - } - break; - } - - ts.forEachChild(node, delintNode); - } - - function report(node: ts.Node, message: string) { - let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); - console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`); - } -} - -const fileNames = process.argv.slice(2); -fileNames.forEach(fileName => { - // Parse a file - let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); - - // delint it - delint(sourceFile); + +/* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var process: any; +declare var console: any; +declare var readFileSync: any; + +import * as ts from "typescript"; + +export function delint(sourceFile: ts.SourceFile) { + delintNode(sourceFile); + + function delintNode(node: ts.Node) { + switch (node.kind) { + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + if ((node).statement.kind !== ts.SyntaxKind.Block) { + report(node, "A looping statement's contents should be wrapped in a block body."); + } + break; + + case ts.SyntaxKind.IfStatement: + let ifStatement = (node); + if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { + report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); + } + if (ifStatement.elseStatement && + ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && + ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { + report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); + } + break; + + case ts.SyntaxKind.BinaryExpression: + let op = (node).operatorToken.kind; + if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { + report(node, "Use '===' and '!=='.") + } + break; + } + + ts.forEachChild(node, delintNode); + } + + function report(node: ts.Node, message: string) { + let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); + console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`); + } +} + +const fileNames = process.argv.slice(2); +fileNames.forEach(fileName => { + // Parse a file + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + + // delint it + delint(sourceFile); }); //// [APISample_linter.js] @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 191 /* ForStatement */: - case 192 /* ForInStatement */: - case 190 /* WhileStatement */: - case 189 /* DoStatement */: - if (node.statement.kind !== 184 /* Block */) { + case 192 /* ForStatement */: + case 193 /* ForInStatement */: + case 191 /* WhileStatement */: + case 190 /* DoStatement */: + if (node.statement.kind !== 185 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 188 /* IfStatement */: + case 189 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 184 /* Block */) { + if (ifStatement.thenStatement.kind !== 185 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 184 /* Block */ && - ifStatement.elseStatement.kind !== 188 /* IfStatement */) { + ifStatement.elseStatement.kind !== 185 /* Block */ && + ifStatement.elseStatement.kind !== 189 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 173 /* BinaryExpression */: + case 174 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/classAbstractConstructor.errors.txt b/tests/baselines/reference/classAbstractConstructor.errors.txt index fbea6ef807f27..fee9f4cefee0d 100644 --- a/tests/baselines/reference/classAbstractConstructor.errors.txt +++ b/tests/baselines/reference/classAbstractConstructor.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ==== abstract class A { abstract constructor() {} ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt index 33beb6d296b17..20d5ca46933e2 100644 --- a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. @@ -9,7 +9,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst declare abstract class A { abstract constructor() {} ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. ~ !!! error TS1184: An implementation cannot be declared in ambient contexts. } diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index 1f64759f86d68..b3b01fd656d9d 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -3,12 +3,11 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be `abstract` or not `abstract. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(49,7): error TS2514: Classes containing abstract methods must be marked abstract. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1238: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ==== class A { // ... } @@ -66,13 +65,11 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. ~~~ -!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. +!!! error TS2512: Overload signatures must all be abstract or not abstract. } class H { // error -- not declared abstract - ~ -!!! error TS2514: Classes containing abstract methods must be marked abstract. abstract baz() : number; ~~~~~~~~ -!!! error TS1238: Abstract methods can only appear within an abstract class. +!!! error TS1244: Abstract methods can only appear within an abstract class. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt index 2649c83f4e765..412378e267d1a 100644 --- a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1240: Method 'foo' cannot have an implementation because it is marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== abstract class A { abstract foo() {} ~~~~~~~~~~~~~~~~~ -!!! error TS1240: Method 'foo' cannot have an implementation because it is marked abstract. +!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt index 4b0870e6bc5e0..121c173963253 100644 --- a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1237: 'static' modifier cannot be used with 'abstract' modifier. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1237: 'static' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts (6 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst protected abstract foo_c(); private abstract foo_d(); ~~~~~~~~ -!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. abstract public foo_bb(); ~~~~~~ @@ -24,13 +24,13 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst !!! error TS1029: 'protected' modifier must precede 'abstract' modifier. abstract private foo_dd(); ~~~~~~~ -!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. abstract static foo_d(); ~~~~~~ -!!! error TS1237: 'static' modifier cannot be used with 'abstract' modifier. +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. static abstract foo_e(); ~~~~~~~~ -!!! error TS1237: 'static' modifier cannot be used with 'abstract' modifier. +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverloads.errors.txt b/tests/baselines/reference/classAbstractOverloads.errors.txt index 74463ca7fc045..0a1c96bd30a5d 100644 --- a/tests/baselines/reference/classAbstractOverloads.errors.txt +++ b/tests/baselines/reference/classAbstractOverloads.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be `abstract` or not `abstract. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be `abstract` or not `abstract. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be `abstract` or not `abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or not abstract. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive. @@ -14,16 +14,16 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract bar(); bar(); ~~~ -!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. +!!! error TS2512: Overload signatures must all be abstract or not abstract. abstract bar(); abstract baz(); ~~~ -!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. +!!! error TS2512: Overload signatures must all be abstract or not abstract. baz(); abstract baz(); ~~~ -!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. +!!! error TS2512: Overload signatures must all be abstract or not abstract. baz() {} qux(); diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt index d3ee6308bc50f..223a3049825b8 100644 --- a/tests/baselines/reference/classAbstractProperties.errors.txt +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -1,34 +1,34 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (6 errors) ==== abstract class A { abstract x : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. public abstract y : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. protected abstract z : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. private abstract w : number; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. abstract m: () => void; ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. abstract foo_x() : number; public abstract foo_y() : number; protected abstract foo_z() : number; private abstract foo_w() : number; ~~~~~~~~ -!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier. +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt index 8a0e5735a2515..e01b233a4c1c0 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt @@ -1,16 +1,13 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(1,7): error TS2514: Classes containing abstract methods must be marked abstract. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(2,5): error TS1238: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(5,7): error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(21,7): error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts (4 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts (3 errors) ==== class A { - ~ -!!! error TS2514: Classes containing abstract methods must be marked abstract. abstract foo(); ~~~~~~~~ -!!! error TS1238: Abstract methods can only appear within an abstract class. +!!! error TS1244: Abstract methods can only appear within an abstract class. } class B extends A {} diff --git a/tests/baselines/reference/classAbstractWithInterface.errors.txt b/tests/baselines/reference/classAbstractWithInterface.errors.txt index 7dc4dcd87c4b4..fa0a3d089573d 100644 --- a/tests/baselines/reference/classAbstractWithInterface.errors.txt +++ b/tests/baselines/reference/classAbstractWithInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1236: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1242: 'abstract' modifier can only appear on a class or method declaration. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts (1 errors) ==== abstract interface I {} ~~~~~~~~ -!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration. \ No newline at end of file +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. \ No newline at end of file From 994b73f9cb703ced9ef255170b81adfe0a485a0b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 30 Jun 2015 15:19:51 -0700 Subject: [PATCH 189/250] fixed an erroneous assertion --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a46e279a7525..9a610a302f857 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11703,10 +11703,12 @@ namespace ts { // derived class inherits base without override/redeclaration let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - Debug.assert(derivedClassDecl !== undefined); + // Debug.assert(derivedClassDecl !== undefined); // It is an error to inherit an abstract member without implementing it or being declared abstract. - if ((baseDeclarationFlags & NodeFlags.Abstract) && !(derivedClassDecl.flags & NodeFlags.Abstract)) { + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } From feb7e1d10e079c25d238ca1395371d85f5ef3509 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 30 Jun 2015 16:13:09 -0700 Subject: [PATCH 190/250] Fixed generic abstract class inheritance and some comments --- src/compiler/checker.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9a610a302f857..5bf0488e6a838 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3190,9 +3190,11 @@ namespace ts { return type.flags & TypeFlags.Union ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, - // boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - // type itself. Note that the apparent type of a union type is the union type itself. + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ function getApparentType(type: Type): Type { if (type.flags & TypeFlags.Union) { type = getReducedTypeOfUnionType(type); @@ -8403,7 +8405,10 @@ namespace ts { } // If the expression is of abstract type, then it cannot be instantiated. - let valueDecl = expressionType.symbol && expressionType.symbol.valueDeclaration; + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); } @@ -10253,7 +10258,8 @@ namespace ts { } // Abstract methods can't have an implementation -- in particular, they don't need one. - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -11699,6 +11705,9 @@ namespace ts { Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration From 30d15a8d7c933f9468313e4b27d099735907680c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 30 Jun 2015 19:46:59 -0700 Subject: [PATCH 191/250] Addressing CR feedback --- src/compiler/checker.ts | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 10f7b530330f2..be823989b82da 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3910,25 +3910,23 @@ namespace ts { return links.resolvedType; } - function addTypeToSet(typeSet: Type[], type: Type, typeKind: TypeFlags) { - if (type.flags & typeKind) { - addTypesToSet(typeSet, (type).types, typeKind); + function addTypeToSet(typeSet: Type[], type: Type, typeSetKind: TypeFlags) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, (type).types, typeSetKind); } else if (!contains(typeSet, type)) { typeSet.push(type); } } - function addTypesToSet(typeSet: Type[], types: Type[], typeKind: TypeFlags) { + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet: Type[], types: Type[], typeSetKind: TypeFlags) { for (let type of types) { - addTypeToSet(typeSet, type, typeKind); + addTypeToSet(typeSet, type, typeSetKind); } } - function compareTypeIds(type1: Type, type2: Type): number { - return type1.id - type2.id; - } - function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { for (let type of types) { if (candidate !== type && isTypeSubtypeOf(candidate, type)) { @@ -3967,6 +3965,10 @@ namespace ts { } } + function compareTypeIds(type1: Type, type2: Type): number { + return type1.id - type2.id; + } + // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag // is true when creating a union type from a type node and when instantiating a union type. In both of those // cases subtype reduction has to be deferred to properly support recursive union types. For example, a @@ -4031,8 +4033,11 @@ namespace ts { // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution - // for intersections of types with signatues can be deterministic. + // for intersections of types with signatures can be deterministic. function getIntersectionType(types: Type[]): Type { + if (types.length === 0) { + return emptyObjectType; + } let typeSet: Type[] = []; addTypesToSet(typeSet, types, TypeFlags.Intersection); if (containsTypeAny(typeSet)) { @@ -4469,6 +4474,7 @@ namespace ts { } } else if (relation !== identityRelation) { + // Note that the "each" checks must precede the "some" checks to produce the correct results if (source.flags & TypeFlags.Union) { if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; @@ -4480,6 +4486,9 @@ namespace ts { } } else { + // A check of the form A | B = C & D can be satisfied either by having C be related to A | B, + // D be related to A | B, C & D be related to A, or C & D be related to B. Thus, we need to + // check both sides here. if (source.flags & TypeFlags.Intersection) { // If target is a union type the following check will report errors so we suppress them here if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { @@ -4508,8 +4517,11 @@ namespace ts { // it may hold in a structural comparison. // Report structural errors only if we haven't reported any errors yet let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // identity relation does not use apparent type + // Identity relation does not use apparent type let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. if (sourceOrApparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; @@ -5423,7 +5435,9 @@ namespace ts { } } // Next, if target is a union type containing a single naked type parameter, make a - // secondary inference to that type parameter + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. if (target.flags & TypeFlags.Union && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); From a1877ef336c23459f6326f0f3e488820dc3ab571 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 10:46:10 -0700 Subject: [PATCH 192/250] fexed comment and initialization --- src/compiler/checker.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5bf0488e6a838..5c5cc36f5ce0e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3734,12 +3734,12 @@ namespace ts { // We only support expressions that are simple qualified names. For other expressions this produces undefined. let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; + undefined; let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; let type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -4641,8 +4641,6 @@ namespace ts { let sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { - // sourceProp !== targetProp -- ie: source and target have distinct declarations with the same name - if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { if (reportErrors) { @@ -7216,7 +7214,7 @@ namespace ts { } if (flags & NodeFlags.Abstract) { - // A method cannot be accessed in a super call if the method is abstract. + // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. From f7ba7188f3d9b54126605e4ae88105db702cbdd2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 13:02:59 -0700 Subject: [PATCH 193/250] Add test case for completion when destructuring from a union type. --- .../completionListInObjectBindingPattern13.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/cases/fourslash/completionListInObjectBindingPattern13.ts diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts new file mode 100644 index 0000000000000..f91f9fcceedbd --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// x: number; +//// y: string; +//// z: boolean; +////} +//// +////interface J { +//// x: string; +//// y: string; +////} +//// +////let { /**/ }: I | J = { x: 10 }; + +goTo.marker(); +verify.completionListContains("x"); +verify.completionListContains("y"); +verify.not.completionListContains("z"); \ No newline at end of file From 4082a540e245c03aa20f21efce57f918a3dd615f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 13:25:51 -0700 Subject: [PATCH 194/250] Added checks for new identifier location in tests. --- .../cases/fourslash/completionListInObjectBindingPattern01.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern02.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern04.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern05.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern07.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern08.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern09.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern10.ts | 4 +++- .../cases/fourslash/completionListInObjectBindingPattern11.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern12.ts | 3 ++- .../cases/fourslash/completionListInObjectBindingPattern13.ts | 3 ++- 11 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts index 128e95b8ed3c7..99188457e6fd7 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts index 6d2b7a6b5164d..0cd86c8d1a655 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property2"); -verify.not.completionListContains("property1"); \ No newline at end of file +verify.not.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts index 92b202a1b37fb..e6057ec0fae54 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts index d17e11810dfab..d0876ed6a349e 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts @@ -9,4 +9,5 @@ ////var { property1/**/ } = foo; goTo.marker(); -verify.completionListContains("property1"); \ No newline at end of file +verify.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts index a3015346aa386..4db3fc383d4c4 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts @@ -15,4 +15,5 @@ goTo.marker(); verify.completionListContains("propertyOfI_1"); verify.completionListContains("propertyOfI_2"); -verify.not.completionListContains("property2"); \ No newline at end of file +verify.not.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts index 6d6be330b8328..b062ca702a27e 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts @@ -15,4 +15,5 @@ goTo.marker(); verify.completionListContains("propertyOfI_2"); verify.not.completionListContains("propertyOfI_1"); -verify.not.completionListContains("property2"); \ No newline at end of file +verify.not.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts index 2698e78667be4..61b31385b35ca 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts @@ -16,4 +16,5 @@ goTo.marker(); verify.completionListContains("property2"); verify.not.completionListContains("property1"); verify.not.completionListContains("propertyOfI_2"); -verify.not.completionListContains("propertyOfI_1"); \ No newline at end of file +verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts index fcc09d1ead446..836e12fd8a33b 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts @@ -17,7 +17,9 @@ verify.completionListContains("property2"); verify.not.completionListContains("property1"); verify.not.completionListContains("propertyOfI_2"); verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListAllowsNewIdentifier(); goTo.marker("2"); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts index 25d6651a03855..57a32578026ce 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts @@ -10,4 +10,5 @@ goTo.marker(""); verify.completionListContains("property2"); verify.not.completionListContains("property1"); -verify.not.completionListContains("prop1"); \ No newline at end of file +verify.not.completionListContains("prop1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts index f31206a21b6d7..59af2da38d22f 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts @@ -10,4 +10,5 @@ goTo.marker(""); verify.completionListContains("property2"); -verify.not.completionListContains("property1"); \ No newline at end of file +verify.not.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts index f91f9fcceedbd..8081d2ee23baf 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts @@ -16,4 +16,5 @@ goTo.marker(); verify.completionListContains("x"); verify.completionListContains("y"); -verify.not.completionListContains("z"); \ No newline at end of file +verify.not.completionListContains("z"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file From 4a2e67205f5328050ae5f661ccd4740566d8a6b3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 13:27:50 -0700 Subject: [PATCH 195/250] Don't show a builder in object binding pattern completions. --- src/services/services.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 018a11fc4bb3d..798370bd7ba17 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3010,18 +3010,24 @@ namespace ts { function tryGetGlobalSymbols(): boolean { let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (objectLikeContainer) { - // Object literal expression, look up possible property names from contextual type + // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; - isNewIdentifierLocation = true; let typeForObject: Type; let existingMembers: Declaration[]; if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = (objectLikeContainer).properties; } else { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); existingMembers = (objectLikeContainer).elements; } From 422a405c016787a582d43baf12936346004ea496 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 13:34:59 -0700 Subject: [PATCH 196/250] Documentative and conservative checking. --- src/services/services.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 798370bd7ba17..516ae1bbaed77 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3024,13 +3024,16 @@ namespace ts { typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = (objectLikeContainer).properties; } - else { + else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); existingMembers = (objectLikeContainer).elements; } + else { + Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } if (!typeForObject) { return false; From 4dd369fe120d7de1a9210a9037459e72bc37e67b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 13:37:41 -0700 Subject: [PATCH 197/250] moved initialization and changed a comment --- src/compiler/checker.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c5cc36f5ce0e..bf6f7658f0472 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7191,7 +7191,7 @@ namespace ts { */ function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { let flags = getDeclarationFlagsFromSymbol(prop); - let declaringClass: InterfaceType; + let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; if (left.kind === SyntaxKind.SuperKeyword) { let errorNode = (node).name ? @@ -7219,8 +7219,6 @@ namespace ts { // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - declaringClass = getDeclaredTypeOfSymbol(prop.parent); - error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } @@ -7236,7 +7234,6 @@ namespace ts { let enclosingClassDeclaration = getContainingClass(node); let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same if (flags & NodeFlags.Private) { @@ -8391,7 +8388,7 @@ namespace ts { let expressionType = checkExpression(node.expression); - // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or + // If expressionType's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate // signatures for overload resolution. The result type of the function call becomes @@ -8402,7 +8399,7 @@ namespace ts { return resolveErrorCall(node); } - // If the expression is of abstract type, then it cannot be instantiated. + // If the expression is a class of abstract type, then it cannot be instantiated. // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. @@ -8412,7 +8409,7 @@ namespace ts { } // TS 1.0 spec: 4.11 - // If ConstructExpr is of type Any, Args can be any argument + // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. if (isTypeAny(expressionType)) { if (node.typeArguments) { @@ -8430,7 +8427,7 @@ namespace ts { return resolveCall(node, constructSignatures, candidatesOutArray); } - // If ConstructExpr's apparent type is an object type with no construct signatures but + // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. @@ -13838,6 +13835,12 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } + else { + // mark the constructor abstract for static-side assignability restrictions. + + // (node).members.????; + + } flags |= NodeFlags.Abstract; break; From 1efff2857fa1c8fff2ac00443dc8fda8003c22a8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 14:45:53 -0700 Subject: [PATCH 198/250] fixed union-type determination, moved abstract implementation test, and reformatted a line --- src/compiler/checker.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 36981435828df..54bdbe4c4434b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7244,8 +7244,7 @@ namespace ts { let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; if (left.kind === SyntaxKind.SuperKeyword) { - let errorNode = (node).name ? - (node).name : + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (node).name : (node).right; // TS 1.0 spec (April 2014): 4.8.2 @@ -9978,6 +9977,12 @@ namespace ts { // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if(node.flags & NodeFlags.Abstract && node.body) { + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node: ConstructorDeclaration) { @@ -10381,12 +10386,6 @@ namespace ts { if (!bodyDeclaration) { bodyDeclaration = node; } - - // abstract functions cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (currentNodeFlags & NodeFlags.Abstract && node.kind === SyntaxKind.MethodDeclaration && !isConstructor) { - error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)) - } } else { hasOverloads = true; @@ -14251,8 +14250,9 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & NodeFlags.Abstract) { - if (modifier.kind === SyntaxKind.PrivateKeyword) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract")} + if (modifier.kind === SyntaxKind.PrivateKeyword) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } else { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } From c93bde693ba45bbc8fa1813a553657b0a1e30494 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 14:46:18 -0700 Subject: [PATCH 199/250] added tests --- .../classAbstractGeneric.ts | 25 +++++++++++++++++++ .../classAbstractMergedDeclaration.ts | 24 ++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts new file mode 100644 index 0000000000000..f69ea30d0d69d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts @@ -0,0 +1,25 @@ +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts new file mode 100644 index 0000000000000..160c0de298bb3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts @@ -0,0 +1,24 @@ +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; \ No newline at end of file From 139d0f46bc20170f8c4901650e3a0197a1bb285d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 14:46:30 -0700 Subject: [PATCH 200/250] updated baselines --- .../reference/classAbstractGeneric.errors.txt | 46 ++++++++++ .../reference/classAbstractGeneric.js | 84 +++++++++++++++++++ .../classAbstractMergedDeclaration.errors.txt | 66 +++++++++++++++ .../classAbstractMergedDeclaration.js | 73 ++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 tests/baselines/reference/classAbstractGeneric.errors.txt create mode 100644 tests/baselines/reference/classAbstractGeneric.js create mode 100644 tests/baselines/reference/classAbstractMergedDeclaration.errors.txt create mode 100644 tests/baselines/reference/classAbstractMergedDeclaration.js diff --git a/tests/baselines/reference/classAbstractGeneric.errors.txt b/tests/baselines/reference/classAbstractGeneric.errors.txt new file mode 100644 index 0000000000000..fb5a4c32a39d1 --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(14,7): error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(18,7): error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts (6 errors) ==== + abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); + } + + abstract class B extends A {} + + class C extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. + + class D extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. + + class E extends A { // error -- doesn't implement bar + ~ +!!! error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. + foo() { return this.t; } + } + + class F extends A { // error -- doesn't implement foo + ~ +!!! error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + bar(t : T) {} + } + + class G extends A { + foo() { return this.t; } + bar(t: T) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.js b/tests/baselines/reference/classAbstractGeneric.js new file mode 100644 index 0000000000000..5af7da1601a99 --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.js @@ -0,0 +1,84 @@ +//// [classAbstractGeneric.ts] +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} + +//// [classAbstractGeneric.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); // error -- inherits abstract methods +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(A); // error -- inherits abstract methods +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { return this.t; }; + return E; +})(A); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function (t) { }; + return F; +})(A); +var G = (function (_super) { + __extends(G, _super); + function G() { + _super.apply(this, arguments); + } + G.prototype.foo = function () { return this.t; }; + G.prototype.bar = function (t) { }; + return G; +})(A); diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt new file mode 100644 index 0000000000000..ca2cc3b8c2d08 --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt @@ -0,0 +1,66 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2300: Duplicate identifier 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2300: Duplicate identifier 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2300: Duplicate identifier 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2300: Duplicate identifier 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(17,16): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(19,1): error TS2511: Cannot create an instance of the abstract class 'CM'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(20,1): error TS2511: Cannot create an instance of the abstract class 'MC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(22,5): error TS2304: Cannot find name 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(23,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (13 errors) ==== + abstract class CM {} + module CM {} + + module MC {} + abstract class MC {} + + abstract class CI {} + ~~ +!!! error TS2300: Duplicate identifier 'CI'. + interface CI {} + ~~ +!!! error TS2300: Duplicate identifier 'CI'. + + interface IC {} + ~~ +!!! error TS2300: Duplicate identifier 'IC'. + abstract class IC {} + ~~ +!!! error TS2300: Duplicate identifier 'IC'. + + abstract class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + + class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + abstract class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + + new CM; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CM'. + new MC; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'MC'. + new CI; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CI'. + new IC; + ~~ +!!! error TS2304: Cannot find name 'IC'. + new CC1; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CC1'. + new CC2; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.js b/tests/baselines/reference/classAbstractMergedDeclaration.js new file mode 100644 index 0000000000000..1b4d6fea342f0 --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.js @@ -0,0 +1,73 @@ +//// [classAbstractMergedDeclaration.ts] +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; + +//// [classAbstractMergedDeclaration.js] +var CM = (function () { + function CM() { + } + return CM; +})(); +var MC = (function () { + function MC() { + } + return MC; +})(); +var CI = (function () { + function CI() { + } + return CI; +})(); +var IC = (function () { + function IC() { + } + return IC; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; From 27ebd5c74961fdb86582653d2648cc86becc09f9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 14:47:56 -0700 Subject: [PATCH 201/250] removed a prototype --- src/compiler/checker.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 54bdbe4c4434b..6110bcd413520 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14340,12 +14340,6 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - else { - // mark the constructor abstract for static-side assignability restrictions. - - // (node).members.????; - - } flags |= NodeFlags.Abstract; break; From f465d99492db1d328a42a9b93c1e955cdaa540b3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 1 Jul 2015 15:00:06 -0700 Subject: [PATCH 202/250] Fix attribute completion following JSX exprs --- src/services/services.ts | 69 ++++++++++++------- .../incrementalParsingInsertIntoMethod1.ts | 1 - ...yntacticClassificationsConflictMarkers1.ts | 2 +- tests/cases/fourslash/tsxCompletion3.ts | 13 ++++ 4 files changed, 60 insertions(+), 25 deletions(-) create mode 100644 tests/cases/fourslash/tsxCompletion3.ts diff --git a/src/services/services.ts b/src/services/services.ts index 018a11fc4bb3d..c193b53582b31 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3009,6 +3009,7 @@ namespace ts { function tryGetGlobalSymbols(): boolean { let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); + let jsxContainer = tryGetContainingJsxElement(contextToken); if (objectLikeContainer) { // Object literal expression, look up possible property names from contextual type isMemberCompletion = true; @@ -3059,30 +3060,22 @@ namespace ts { } return true; } - else if (getAncestor(contextToken, SyntaxKind.JsxElement) || getAncestor(contextToken, SyntaxKind.JsxSelfClosingElement)) { - // Go up until we hit either the element or expression - let jsxNode = contextToken; + else if(jsxContainer) { + let attrsType: Type; + if (jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) { + // Cursor is inside a JSX self-closing element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + } + else if(jsxContainer.kind === SyntaxKind.JsxOpeningElement) { + // Cursor is inside a JSX element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + } - while (jsxNode) { - if (jsxNode.kind === SyntaxKind.JsxExpression) { - // Defer to global completion if we're inside an {expression} - break; - } else if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement || jsxNode.kind === SyntaxKind.JsxElement) { - let attrsType: Type; - if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement) { - // Cursor is inside a JSX self-closing element - attrsType = typeChecker.getJsxElementAttributesType(jsxNode); - } - else { - Debug.assert(jsxNode.kind === SyntaxKind.JsxElement); - // Cursor is inside a JSX element - attrsType = typeChecker.getJsxElementAttributesType((jsxNode).openingElement); - } - symbols = typeChecker.getPropertiesOfType(attrsType); - isMemberCompletion = true; - return true; - } - jsxNode = jsxNode.parent; + if (attrsType) { + symbols = typeChecker.getPropertiesOfType(attrsType); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; } } @@ -3268,6 +3261,36 @@ namespace ts { return undefined; } + function tryGetContainingJsxElement(contextToken: Node): JsxOpeningLikeElement { + if (contextToken) { + let parent = contextToken.parent; + switch(contextToken.kind) { + case SyntaxKind.LessThanSlashToken: + case SyntaxKind.SlashToken: + case SyntaxKind.Identifier: + if(parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { + return parent; + } + break; + + case SyntaxKind.CloseBraceToken: + // The context token is the closing } of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + if(parent && + parent.kind === SyntaxKind.JsxExpression && + parent.parent && + parent.parent.kind === SyntaxKind.JsxAttribute) { + + return parent.parent.parent; + } + + break; + } + } + return undefined; + } + function isFunction(kind: SyntaxKind): boolean { switch (kind) { case SyntaxKind.FunctionExpression: diff --git a/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts b/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts index 930c0511ffbf3..b5deb361056ae 100644 --- a/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts +++ b/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts @@ -8,6 +8,5 @@ //// public foo3() { } ////} -debugger; goTo.marker("1"); edit.insert(" + 1"); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts index e381856c41e9d..7f26038c33e8c 100644 --- a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts +++ b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts @@ -7,7 +7,7 @@ //// v = 2; ////>>>>>>> Branch - a ////} -debugger; + var c = classification; verify.syntacticClassificationsAre( c.keyword("class"), c.className("C"), c.punctuation("{"), diff --git a/tests/cases/fourslash/tsxCompletion3.ts b/tests/cases/fourslash/tsxCompletion3.ts new file mode 100644 index 0000000000000..2d87d7ed05698 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion3.ts @@ -0,0 +1,13 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +////
; + +goTo.marker(); +verify.completionListContains('two'); From a0bd465a7d2df6cc68f1d689a0bb6431563b4def Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 15:31:14 -0700 Subject: [PATCH 203/250] Appeasing Jason --- src/compiler/checker.ts | 127 ++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6110bcd413520..c408b3efc28bc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -106,7 +106,7 @@ namespace ts { let globals: SymbolTable = {}; let globalESSymbolConstructorSymbol: Symbol; - + let getGlobalPromiseConstructorSymbol: () => Symbol; let globalObjectType: ObjectType; @@ -137,7 +137,7 @@ namespace ts { let getInstantiatedGlobalPromiseLikeType: () => ObjectType; let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; - + let tupleTypes: Map = {}; let unionTypes: Map = {}; let stringLiteralTypes: Map = {}; @@ -146,7 +146,7 @@ namespace ts { let emitParam = false; let emitAwaiter = false; let emitGenerator = false; - + let resolutionTargets: Object[] = []; let resolutionResults: boolean[] = []; @@ -3747,12 +3747,12 @@ namespace ts { // We only support expressions that are simple qualified names. For other expressions this produces undefined. let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; + undefined; let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; let type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -3817,7 +3817,7 @@ namespace ts { function getGlobalType(name: string, arity = 0): ObjectType { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } - + function tryGetGlobalType(name: string, arity = 0): ObjectType { return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity); } @@ -4036,7 +4036,7 @@ namespace ts { } return links.resolvedType; } - + function getTypeFromTypeNode(node: TypeNode): Type { switch (node.kind) { case SyntaxKind.AnyKeyword: @@ -5928,7 +5928,7 @@ namespace ts { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } } - + if (node.parserContextFlags & ParserContextFlags.Await) { getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; @@ -7244,7 +7244,8 @@ namespace ts { let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; if (left.kind === SyntaxKind.SuperKeyword) { - let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (node).name : + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? + (node).name : (node).right; // TS 1.0 spec (April 2014): 4.8.2 @@ -7343,7 +7344,7 @@ namespace ts { } return unknownType; } - + getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -8661,7 +8662,7 @@ namespace ts { links.type = instantiateType(getTypeOfSymbol(lastOrUndefined(context.parameters)), mapper); } } - + function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument let globalPromiseType = getGlobalPromiseType(); @@ -8670,7 +8671,7 @@ namespace ts { promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); } - + return emptyObjectType; } @@ -8679,11 +8680,11 @@ namespace ts { if (!func.body) { return unknownType; } - + let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = checkExpressionCached(func.body, contextualMapper); + type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -8716,13 +8717,13 @@ namespace ts { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; } - + return promiseType; } else { return voidType; } - } + } } // When yield/return statements are contextually typed we allow the return type to be a union type. // Otherwise we require the yield/return expressions to have a best common supertype. @@ -8745,7 +8746,7 @@ namespace ts { if (!contextualSignature) { reportErrorsFromWidening(func, type); } - + let widenedType = getWidenedType(type); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -8756,8 +8757,8 @@ namespace ts { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; } - - return promiseType; + + return promiseType; } else { return widenedType; @@ -8792,13 +8793,13 @@ namespace ts { forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { - let type = checkExpressionCached(expr, contextualMapper); + let type = checkExpressionCached(expr, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. - type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); } if (!contains(aggregatedTypes, type)) { @@ -8870,12 +8871,12 @@ namespace ts { if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } - + let isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; } - + let links = getNodeLinks(node); let type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so @@ -8912,7 +8913,7 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - + let isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -8923,7 +8924,7 @@ namespace ts { if (returnType && isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - + if (returnType && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } @@ -8957,7 +8958,7 @@ namespace ts { checkTypeAssignableTo(exprType, returnType, node.body); } } - + checkFunctionAndClassExpressionBodies(node.body); } } @@ -9079,7 +9080,7 @@ namespace ts { let operandType = checkExpression(node.expression); return checkAwaitedType(operandType, node); } - + function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { let operandType = checkExpression(node.operand); switch (node.operator) { @@ -9552,7 +9553,7 @@ namespace ts { node.contextualType = saveContextualType; return result; } - + function checkExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -9980,7 +9981,7 @@ namespace ts { // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if(node.flags & NodeFlags.Abstract && node.body) { + if (node.flags & NodeFlags.Abstract && node.body) { error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } } @@ -10412,8 +10413,8 @@ namespace ts { } // Abstract methods can't have an implementation -- in particular, they don't need one. - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -10530,13 +10531,13 @@ namespace ts { if (!message) { message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; } - + error(location, message); } - + return unknownType; } - + return type; } @@ -10559,11 +10560,11 @@ namespace ts { if (promise.flags & TypeFlags.Any) { return undefined; } - + if ((promise.flags & TypeFlags.Reference) && (promise).target === tryGetGlobalPromiseType()) { return (promise).typeArguments[0]; } - + let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { return undefined; @@ -10573,26 +10574,26 @@ namespace ts { if (thenFunction && (thenFunction.flags & TypeFlags.Any)) { return undefined; } - + let thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; if (thenSignatures.length === 0) { return undefined; } - + let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); if (onfulfilledParameterType.flags & TypeFlags.Any) { return undefined; } - + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); if (onfulfilledParameterSignatures.length === 0) { return undefined; } - + let valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); return valueParameterType; } - + function getTypeOfFirstParameterOfSignature(signature: Signature) { return getTypeAtPosition(signature, 0); } @@ -10607,17 +10608,17 @@ namespace ts { function getAwaitedType(type: Type) { return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } - + function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { return checkAwaitedTypeWorker(type); - + function checkAwaitedTypeWorker(type: Type): Type { if (type.flags & TypeFlags.Union) { let types: Type[] = []; for (let constituentType of (type).types) { types.push(checkAwaitedTypeWorker(constituentType)); } - + return getUnionType(types); } else { @@ -10677,11 +10678,11 @@ namespace ts { // if (location) { error( - location, - Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, + location, + Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); } - + return unknownType; } @@ -10690,7 +10691,7 @@ namespace ts { awaitedTypeStack.push(type.id); let awaitedType = checkAwaitedTypeWorker(promisedType); awaitedTypeStack.pop(); - return awaitedType; + return awaitedType; } } } @@ -10750,7 +10751,7 @@ namespace ts { // type as a value. As such, we will just return unknownType; return unknownType; } - + let promiseConstructor = getMergedSymbol(promiseType.symbol); if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); @@ -10942,7 +10943,7 @@ namespace ts { if (!compilerOptions.experimentalAsyncFunctions) { error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); } - + emitAwaiter = true; } @@ -10984,7 +10985,7 @@ namespace ts { if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } @@ -11317,7 +11318,7 @@ namespace ts { if (inBlockOrObjectLiteralExpression(node)) { if (isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } } else { @@ -11335,7 +11336,7 @@ namespace ts { node = node.parent; } - + return false; } @@ -12160,7 +12161,7 @@ namespace ts { // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + if (baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } @@ -13142,7 +13143,7 @@ namespace ts { forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - + if (emitExtends) { links.flags |= NodeCheckFlags.EmitExtends; } @@ -13154,11 +13155,11 @@ namespace ts { if (emitParam) { links.flags |= NodeCheckFlags.EmitParam; } - + if (emitAwaiter) { links.flags |= NodeCheckFlags.EmitAwaiter; } - + if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) { links.flags |= NodeCheckFlags.EmitGenerator; } @@ -13454,7 +13455,7 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // Fall through + // Fall through case SyntaxKind.NumericLiteral: // index access @@ -14129,21 +14130,21 @@ namespace ts { anyArrayType = createArrayType(anyType); } - + function createInstantiatedPromiseLikeType(): ObjectType { let promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyObjectType) { return createTypeReference(promiseLikeType, [anyType]); } - + return emptyObjectType; } - + function createThenableType() { // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - + let thenableType = createObjectType(TypeFlags.Anonymous); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); From 07142a4ec231d56b059d87405f153a6499de65a9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 15:37:42 -0700 Subject: [PATCH 204/250] Revert "Appeasing Jason" This reverts commit a0bd465a7d2df6cc68f1d689a0bb6431563b4def. --- src/compiler/checker.ts | 127 ++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c408b3efc28bc..6110bcd413520 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -106,7 +106,7 @@ namespace ts { let globals: SymbolTable = {}; let globalESSymbolConstructorSymbol: Symbol; - + let getGlobalPromiseConstructorSymbol: () => Symbol; let globalObjectType: ObjectType; @@ -137,7 +137,7 @@ namespace ts { let getInstantiatedGlobalPromiseLikeType: () => ObjectType; let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; - + let tupleTypes: Map = {}; let unionTypes: Map = {}; let stringLiteralTypes: Map = {}; @@ -146,7 +146,7 @@ namespace ts { let emitParam = false; let emitAwaiter = false; let emitGenerator = false; - + let resolutionTargets: Object[] = []; let resolutionResults: boolean[] = []; @@ -3747,12 +3747,12 @@ namespace ts { // We only support expressions that are simple qualified names. For other expressions this produces undefined. let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; + undefined; let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; let type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -3817,7 +3817,7 @@ namespace ts { function getGlobalType(name: string, arity = 0): ObjectType { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } - + function tryGetGlobalType(name: string, arity = 0): ObjectType { return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity); } @@ -4036,7 +4036,7 @@ namespace ts { } return links.resolvedType; } - + function getTypeFromTypeNode(node: TypeNode): Type { switch (node.kind) { case SyntaxKind.AnyKeyword: @@ -5928,7 +5928,7 @@ namespace ts { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } } - + if (node.parserContextFlags & ParserContextFlags.Await) { getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; @@ -7244,8 +7244,7 @@ namespace ts { let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; if (left.kind === SyntaxKind.SuperKeyword) { - let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? - (node).name : + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (node).name : (node).right; // TS 1.0 spec (April 2014): 4.8.2 @@ -7344,7 +7343,7 @@ namespace ts { } return unknownType; } - + getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -8662,7 +8661,7 @@ namespace ts { links.type = instantiateType(getTypeOfSymbol(lastOrUndefined(context.parameters)), mapper); } } - + function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument let globalPromiseType = getGlobalPromiseType(); @@ -8671,7 +8670,7 @@ namespace ts { promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); } - + return emptyObjectType; } @@ -8680,11 +8679,11 @@ namespace ts { if (!func.body) { return unknownType; } - + let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = checkExpressionCached(func.body, contextualMapper); + type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -8717,13 +8716,13 @@ namespace ts { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; } - + return promiseType; } else { return voidType; } - } + } } // When yield/return statements are contextually typed we allow the return type to be a union type. // Otherwise we require the yield/return expressions to have a best common supertype. @@ -8746,7 +8745,7 @@ namespace ts { if (!contextualSignature) { reportErrorsFromWidening(func, type); } - + let widenedType = getWidenedType(type); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -8757,8 +8756,8 @@ namespace ts { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; } - - return promiseType; + + return promiseType; } else { return widenedType; @@ -8793,13 +8792,13 @@ namespace ts { forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { - let type = checkExpressionCached(expr, contextualMapper); + let type = checkExpressionCached(expr, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. - type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); } if (!contains(aggregatedTypes, type)) { @@ -8871,12 +8870,12 @@ namespace ts { if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } - + let isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; } - + let links = getNodeLinks(node); let type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so @@ -8913,7 +8912,7 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - + let isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -8924,7 +8923,7 @@ namespace ts { if (returnType && isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - + if (returnType && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } @@ -8958,7 +8957,7 @@ namespace ts { checkTypeAssignableTo(exprType, returnType, node.body); } } - + checkFunctionAndClassExpressionBodies(node.body); } } @@ -9080,7 +9079,7 @@ namespace ts { let operandType = checkExpression(node.expression); return checkAwaitedType(operandType, node); } - + function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { let operandType = checkExpression(node.operand); switch (node.operator) { @@ -9553,7 +9552,7 @@ namespace ts { node.contextualType = saveContextualType; return result; } - + function checkExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -9981,7 +9980,7 @@ namespace ts { // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & NodeFlags.Abstract && node.body) { + if(node.flags & NodeFlags.Abstract && node.body) { error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } } @@ -10413,8 +10412,8 @@ namespace ts { } // Abstract methods can't have an implementation -- in particular, they don't need one. - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract)) { + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -10531,13 +10530,13 @@ namespace ts { if (!message) { message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; } - + error(location, message); } - + return unknownType; } - + return type; } @@ -10560,11 +10559,11 @@ namespace ts { if (promise.flags & TypeFlags.Any) { return undefined; } - + if ((promise.flags & TypeFlags.Reference) && (promise).target === tryGetGlobalPromiseType()) { return (promise).typeArguments[0]; } - + let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { return undefined; @@ -10574,26 +10573,26 @@ namespace ts { if (thenFunction && (thenFunction.flags & TypeFlags.Any)) { return undefined; } - + let thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; if (thenSignatures.length === 0) { return undefined; } - + let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); if (onfulfilledParameterType.flags & TypeFlags.Any) { return undefined; } - + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); if (onfulfilledParameterSignatures.length === 0) { return undefined; } - + let valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); return valueParameterType; } - + function getTypeOfFirstParameterOfSignature(signature: Signature) { return getTypeAtPosition(signature, 0); } @@ -10608,17 +10607,17 @@ namespace ts { function getAwaitedType(type: Type) { return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } - + function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { return checkAwaitedTypeWorker(type); - + function checkAwaitedTypeWorker(type: Type): Type { if (type.flags & TypeFlags.Union) { let types: Type[] = []; for (let constituentType of (type).types) { types.push(checkAwaitedTypeWorker(constituentType)); } - + return getUnionType(types); } else { @@ -10678,11 +10677,11 @@ namespace ts { // if (location) { error( - location, - Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, + location, + Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); } - + return unknownType; } @@ -10691,7 +10690,7 @@ namespace ts { awaitedTypeStack.push(type.id); let awaitedType = checkAwaitedTypeWorker(promisedType); awaitedTypeStack.pop(); - return awaitedType; + return awaitedType; } } } @@ -10751,7 +10750,7 @@ namespace ts { // type as a value. As such, we will just return unknownType; return unknownType; } - + let promiseConstructor = getMergedSymbol(promiseType.symbol); if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); @@ -10943,7 +10942,7 @@ namespace ts { if (!compilerOptions.experimentalAsyncFunctions) { error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); } - + emitAwaiter = true; } @@ -10985,7 +10984,7 @@ namespace ts { if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } @@ -11318,7 +11317,7 @@ namespace ts { if (inBlockOrObjectLiteralExpression(node)) { if (isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } } else { @@ -11336,7 +11335,7 @@ namespace ts { node = node.parent; } - + return false; } @@ -12161,7 +12160,7 @@ namespace ts { // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } @@ -13143,7 +13142,7 @@ namespace ts { forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - + if (emitExtends) { links.flags |= NodeCheckFlags.EmitExtends; } @@ -13155,11 +13154,11 @@ namespace ts { if (emitParam) { links.flags |= NodeCheckFlags.EmitParam; } - + if (emitAwaiter) { links.flags |= NodeCheckFlags.EmitAwaiter; } - + if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) { links.flags |= NodeCheckFlags.EmitGenerator; } @@ -13455,7 +13454,7 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // Fall through + // Fall through case SyntaxKind.NumericLiteral: // index access @@ -14130,21 +14129,21 @@ namespace ts { anyArrayType = createArrayType(anyType); } - + function createInstantiatedPromiseLikeType(): ObjectType { let promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyObjectType) { return createTypeReference(promiseLikeType, [anyType]); } - + return emptyObjectType; } - + function createThenableType() { // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - + let thenableType = createObjectType(TypeFlags.Anonymous); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); From f3b1321f56bebdc9175d7eaf408661f999fcdca1 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 15:39:06 -0700 Subject: [PATCH 205/250] Appeasing Jason lite --- 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 6110bcd413520..84cc67d3a0213 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7244,7 +7244,8 @@ namespace ts { let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; if (left.kind === SyntaxKind.SuperKeyword) { - let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (node).name : + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? + (node).name : (node).right; // TS 1.0 spec (April 2014): 4.8.2 From ef765e56dfa2a2668bb55b46405ecef11f6612f5 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 1 Jul 2015 16:04:29 -0700 Subject: [PATCH 206/250] Filter out would-be-duplicate names from JSX attribute completion --- src/services/services.ts | 39 ++++++++++++++++--------- tests/cases/fourslash/tsxCompletion3.ts | 1 + 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index c193b53582b31..395bd41ac9277 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3062,20 +3062,17 @@ namespace ts { } else if(jsxContainer) { let attrsType: Type; - if (jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) { - // Cursor is inside a JSX self-closing element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - } - else if(jsxContainer.kind === SyntaxKind.JsxOpeningElement) { - // Cursor is inside a JSX element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - } + if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + + if (attrsType) { + symbols = filterJsxAttributes((jsxContainer).attributes, typeChecker.getPropertiesOfType(attrsType)); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; + } - if (attrsType) { - symbols = typeChecker.getPropertiesOfType(attrsType); - isMemberCompletion = true; - isNewIdentifierLocation = false; - return true; } } @@ -3476,6 +3473,22 @@ namespace ts { } } + function filterJsxAttributes(attributes: NodeArray, symbols: Symbol[]): Symbol[] { + let seenNames: Map = {}; + for(let attr of attributes) { + if(attr.kind === SyntaxKind.JsxAttribute) { + seenNames[(attr).name.text] = true; + } + } + let result: Symbol[] = []; + for(let sym of symbols) { + if(!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } + function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { synchronizeHostData(); diff --git a/tests/cases/fourslash/tsxCompletion3.ts b/tests/cases/fourslash/tsxCompletion3.ts index 2d87d7ed05698..5ee712f7e967a 100644 --- a/tests/cases/fourslash/tsxCompletion3.ts +++ b/tests/cases/fourslash/tsxCompletion3.ts @@ -11,3 +11,4 @@ goTo.marker(); verify.completionListContains('two'); +verify.not.completionListContains('one'); From 6d0c7c9f6a80f020a8cde9f594855327ee154ce7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 16:14:46 -0700 Subject: [PATCH 207/250] removed a comment --- src/compiler/checker.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 84cc67d3a0213..d72e74f748eb6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12156,7 +12156,6 @@ namespace ts { // derived class inherits base without override/redeclaration let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - // Debug.assert(derivedClassDecl !== undefined); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), From 9bfdc289d90d30fb16e48c787666a7d12f9ab58d Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Wed, 1 Jul 2015 16:22:34 -0700 Subject: [PATCH 208/250] Fix issue #3216 --- src/lib/dom.generated.d.ts | 75 ++++++++++---------------------- src/lib/webworker.generated.d.ts | 6 +-- 2 files changed, 25 insertions(+), 56 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index e1f06f11009b2..84e959caef81f 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1092,16 +1092,11 @@ interface CanvasRenderingContext2D { clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; closePath(): void; - createImageData(imageDataOrSw: number, sh?: number): ImageData; - createImageData(imageDataOrSw: ImageData, sh?: number): ImageData; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: HTMLImageElement, repetition: string): CanvasPattern; - createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern; - createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -3370,8 +3365,7 @@ interface HTMLAreasCollection extends HTMLCollection { /** * Adds an element to the areas, controlRange, or options collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Removes an element from the collection. */ @@ -6119,8 +6113,7 @@ interface HTMLSelectElement extends HTMLElement { * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -10281,8 +10274,7 @@ interface Screen extends EventTarget { systemXDPI: number; systemYDPI: number; width: number; - msLockOrientation(orientations: string): boolean; - msLockOrientation(orientations: string[]): boolean; + msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -10354,8 +10346,7 @@ interface SourceBuffer extends EventTarget { updating: boolean; videoTracks: VideoTrackList; abort(): void; - appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: ArrayBufferView): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -10463,33 +10454,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; - deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: ArrayBufferView): any; - digest(algorithm: Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; - generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; } declare var SubtleCrypto: { @@ -10998,11 +10974,8 @@ interface WebGLRenderingContext { blendEquationSeparate(modeRGB: number, modeAlpha: number): void; blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, size: ArrayBufferView, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; clearColor(red: number, green: number, blue: number, alpha: number): void; @@ -11845,8 +11818,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -12650,8 +12622,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; } interface PositionCallback { (position: Position): void; @@ -12978,4 +12949,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 1ab2c7d418fa9..5c41869e487c1 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -571,8 +571,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -807,8 +806,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; } interface PositionCallback { (position: Position): void; From 06472035a4f045b437722e399065b81aa6e46d72 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 09:37:14 -0700 Subject: [PATCH 209/250] Prevent extra checks once abstract new-call detected --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d72e74f748eb6..b68dc3c2e6fc7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8456,6 +8456,7 @@ namespace ts { let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); } // TS 1.0 spec: 4.11 From 61a9a64619b5dcc2fea871b5cbbe4c55a5fcbdef Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 09:37:27 -0700 Subject: [PATCH 210/250] Added conformance test --- .../classAbstractKeyword/classAbstractInstantiations1.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts index c9ca4afb18d88..4daf27b53e44f 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -6,6 +6,7 @@ class B extends A {} abstract class C extends B {} new A; +new A(1); // should report 1 error new B; new C; From 233153149a6d974db3d35b31b64c9568bbdfd42d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 09:37:39 -0700 Subject: [PATCH 211/250] updated baselines --- .../reference/classAbstractInstantiations1.errors.txt | 8 ++++++-- tests/baselines/reference/classAbstractInstantiations1.js | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt index 0221ce07f959a..6171ef2efab66 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ==== abstract class A {} @@ -12,6 +13,9 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst new A; ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new A(1); // should report 1 error + ~~~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'A'. new B; new C; diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js index 39e6754292641..f3a0eecada9e9 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -7,6 +7,7 @@ class B extends A {} abstract class C extends B {} new A; +new A(1); // should report 1 error new B; new C; @@ -45,6 +46,7 @@ var C = (function (_super) { return C; })(B); new A; +new A(1); // should report 1 error new B; new C; var a; From c06e5eb8b493e377e44400aaa4307d00524ee4bf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 10:26:23 -0700 Subject: [PATCH 212/250] Update test --- .../classAbstractMergedDeclaration.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts index 160c0de298bb3..6e5686feb2562 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts @@ -16,9 +16,25 @@ class CC1 {} class CC2 {} abstract class CC2 {} +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + new CM; new MC; new CI; new IC; new CC1; -new CC2; \ No newline at end of file +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; \ No newline at end of file From 3af3177fe3bae91761611fa419aedaaf5842080e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 10:26:36 -0700 Subject: [PATCH 213/250] update baselines --- .../reference/augmentedTypesClass2.errors.txt | 8 +-- .../augmentedTypesInterface.errors.txt | 8 +-- .../classAbstractMergedDeclaration.errors.txt | 71 ++++++++++++++----- .../classAbstractMergedDeclaration.js | 22 +++++- .../classAndInterfaceWithSameName.errors.txt | 16 ++--- .../reference/clinterfaces.errors.txt | 32 ++++----- .../baselines/reference/declInput.errors.txt | 8 +-- ...ifiersAcrossContainerBoundaries.errors.txt | 8 +-- ...IdentifiersAcrossFileBoundaries.errors.txt | 16 ++--- .../interfaceDeclaration2.errors.txt | 8 +-- .../reference/mergedClassInterface.errors.txt | 16 ++--- .../reference/nameCollisions.errors.txt | 16 ++--- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 4 +- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 4 +- 14 files changed, 147 insertions(+), 90 deletions(-) diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index da963c59d94bd..278dca816fa30 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 44c47e70ab3df..690bf8b7a991c 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt index ca2cc3b8c2d08..b3a2dec5e9c52 100644 --- a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt +++ b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt @@ -1,19 +1,26 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2300: Duplicate identifier 'CI'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2300: Duplicate identifier 'CI'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2300: Duplicate identifier 'IC'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2300: Duplicate identifier 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(17,16): error TS2300: Duplicate identifier 'CC2'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(19,1): error TS2511: Cannot create an instance of the abstract class 'CM'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(20,1): error TS2511: Cannot create an instance of the abstract class 'MC'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'CI'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(22,5): error TS2304: Cannot find name 'IC'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(23,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(25,24): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(26,15): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(28,15): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(29,24): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(31,1): error TS2511: Cannot create an instance of the abstract class 'CM'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(32,1): error TS2511: Cannot create an instance of the abstract class 'MC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(33,1): error TS2511: Cannot create an instance of the abstract class 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(34,1): error TS2511: Cannot create an instance of the abstract class 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(35,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(37,1): error TS2511: Cannot create an instance of the abstract class 'DCI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(38,1): error TS2511: Cannot create an instance of the abstract class 'DIC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(39,1): error TS2511: Cannot create an instance of the abstract class 'DCC1'. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (13 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (20 errors) ==== abstract class CM {} module CM {} @@ -22,17 +29,17 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract class CI {} ~~ -!!! error TS2300: Duplicate identifier 'CI'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface CI {} ~~ -!!! error TS2300: Duplicate identifier 'CI'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface IC {} ~~ -!!! error TS2300: Duplicate identifier 'IC'. +!!! error TS2518: Only an ambient class can be merged with an interface. abstract class IC {} ~~ -!!! error TS2300: Duplicate identifier 'IC'. +!!! error TS2518: Only an ambient class can be merged with an interface. abstract class CC1 {} ~~~ @@ -48,6 +55,26 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~ !!! error TS2300: Duplicate identifier 'CC2'. + declare abstract class DCI {} + interface DCI {} + + interface DIC {} + declare abstract class DIC {} + + declare abstract class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + declare class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + + declare class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + declare abstract class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + new CM; ~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'CM'. @@ -58,9 +85,19 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'CI'. new IC; - ~~ -!!! error TS2304: Cannot find name 'IC'. + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'IC'. new CC1; ~~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'CC1'. - new CC2; \ No newline at end of file + new CC2; + new DCI; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCI'. + new DIC; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DIC'. + new DCC1; + ~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCC1'. + new DCC2; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.js b/tests/baselines/reference/classAbstractMergedDeclaration.js index 1b4d6fea342f0..f6a91f870d299 100644 --- a/tests/baselines/reference/classAbstractMergedDeclaration.js +++ b/tests/baselines/reference/classAbstractMergedDeclaration.js @@ -17,12 +17,28 @@ class CC1 {} class CC2 {} abstract class CC2 {} +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + new CM; new MC; new CI; new IC; new CC1; -new CC2; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; //// [classAbstractMergedDeclaration.js] var CM = (function () { @@ -71,3 +87,7 @@ new CI; new IC; new CC1; new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index b2b59c290093d..332024b74fdf0 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. @@ -31,7 +31,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName. interface D { // error ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index 8d48f29aed708..5960e6ae32b2e 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 76257de6ea9ba..179db3598abb3 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/declInput.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(1,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 67ee1d9cc371e..731e97482035a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index c98e0e9a8c63a..9867441f7700f 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file1.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/file1.ts(3,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. -tests/cases/compiler/file2.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/file2.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged @@ -15,10 +15,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. interface I { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. @@ -42,10 +42,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file2.ts (6 errors) ==== class I { } // error -- cannot merge interface with non-ambient class ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C1 { } // error -- cannot merge interface with non-ambient class ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 1d5807b9b1b8b..db525e6f21f25 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2511: Only an ambien interface I2 { } ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt index 37bd595c0b736..5b23b046db75c 100644 --- a/tests/baselines/reference/mergedClassInterface.errors.txt +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== @@ -17,19 +17,19 @@ tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2511: class C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C5 { x1: number; diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 2aba1c43f86d3..5c32d4640705f 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2511: Only an ambient cla class cli { } ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index a51eb18d98efc..69d686c31561a 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -7,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index d41c3d0cdbf03..02ccd7f2413f8 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -7,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { From e8a1f16e623cfabe593a765cf5f147ea94fb7e44 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 12:20:20 -0700 Subject: [PATCH 214/250] Added tests for index signature completion builders. --- .../completionListInIndexSignature01.ts | 20 +++++++++++++++++++ .../completionListInIndexSignature02.ts | 19 ++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/cases/fourslash/completionListInIndexSignature01.ts create mode 100644 tests/cases/fourslash/completionListInIndexSignature02.ts diff --git a/tests/cases/fourslash/completionListInIndexSignature01.ts b/tests/cases/fourslash/completionListInIndexSignature01.ts new file mode 100644 index 0000000000000..2db28505b3ee2 --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature01.ts @@ -0,0 +1,20 @@ +/// + +////interface I { +//// [/*1*/]: T; +//// [/*2*/]: T; +////} +//// +////class C { +//// [/*3*/]: string; +//// [str/*4*/: string]: number; +////} +//// +////type T = { +//// [x/*5*/yz: number]: boolean; +//// [/*6*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.completionListAllowsNewIdentifier(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInIndexSignature02.ts b/tests/cases/fourslash/completionListInIndexSignature02.ts new file mode 100644 index 0000000000000..d3b65dc775986 --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature02.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [x: /*1*/]: T; +//// [: /*2*/]: T +////} +//// +////class C { +//// [a: /*3*/]: string; +//// [str: string/*4*/]: number; +////} +//// +////type T = { +//// [xyz: /*5*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.not.completionListAllowsNewIdentifier(); +} \ No newline at end of file From 7abe8a155021df917f50509303c989ad2f264a55 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 12:22:07 -0700 Subject: [PATCH 215/250] Add builder in computed properties and index signatures. --- src/services/services.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index b3eb58bdcb3e8..159b1b817b1fb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3062,7 +3062,7 @@ namespace ts { } return true; } - else if(jsxContainer) { + else if (jsxContainer) { let attrsType: Type; if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { // Cursor is inside a JSX self-closing element or opening element @@ -3162,7 +3162,7 @@ namespace ts { switch (previousToken.kind) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.CallExpression // func( a, | - || containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ || containingNodeKind === SyntaxKind.NewExpression // new C(a, | || containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, | || containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, | @@ -3173,10 +3173,12 @@ namespace ts { || containingNodeKind === SyntaxKind.Constructor // constructor( | || containingNodeKind === SyntaxKind.NewExpression // new C(a| || containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a| - || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case SyntaxKind.OpenBracketToken: - return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ | + return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ | + || containingNodeKind === SyntaxKind.IndexSignature // [ | : string ] + || containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */ case SyntaxKind.ModuleKeyword: // module | case SyntaxKind.NamespaceKeyword: // namespace | From e4ebf1fe4c5996d399c91429caa4217ddf55675c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 2 Jul 2015 12:57:34 -0700 Subject: [PATCH 216/250] Change default node pos/end to -1 --- src/compiler/core.ts | 4 ++-- src/compiler/utilities.ts | 4 +--- src/services/services.ts | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ec4c777852b59..823349eda9173 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -764,8 +764,8 @@ namespace ts { } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined, }; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f48e5306dcead..e66e1925519ed 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -144,7 +144,7 @@ namespace ts { return true; } - return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken; + return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken; } export function nodeIsPresent(node: Node) { @@ -1428,8 +1428,6 @@ namespace ts { export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { let node = createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } diff --git a/src/services/services.ts b/src/services/services.ts index 159b1b817b1fb..3efecd6857215 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7387,8 +7387,8 @@ namespace ts { } let proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject(); proto.kind = kind; - proto.pos = 0; - proto.end = 0; + proto.pos = -1; + proto.end = -1; proto.flags = 0; proto.parent = undefined; Node.prototype = proto; From 738415d65cd4e6ef22f9ccb3940d30097bbdc00e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 15:17:26 -0700 Subject: [PATCH 217/250] Changed tabs to spaces and reformatted file --- scripts/errorCheck.ts | 132 +++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts index 77892cb8f0ccb..36489c5f3123a 100644 --- a/scripts/errorCheck.ts +++ b/scripts/errorCheck.ts @@ -4,84 +4,84 @@ let async = require('async'); let glob = require('glob'); fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { - if (err) { - throw err; - } - - let messages = JSON.parse(data); - let keys = Object.keys(messages); - console.log('Loaded ' + keys.length + ' errors'); + if (err) { + throw err; + } - for (let k of keys) { - messages[k]['seen'] = false; - } + let messages = JSON.parse(data); + let keys = Object.keys(messages); + console.log('Loaded ' + keys.length + ' errors'); - let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; + for (let k of keys) { + messages[k]['seen'] = false; + } - let baseDir = 'tests/baselines/reference/'; - fs.readdir(baseDir, (err, files) => { - files = files.filter(f => f.indexOf('.errors.txt') > 0); - let tasks: Array<(callback: () => void) => void> = []; - files.forEach(f => tasks.push(done => { - fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { - if (err) throw err; + let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; - let g: string[]; - while (g = errRegex.exec(baseline)) { - var errCode = +g[1]; - let msg = keys.filter(k => messages[k].code === errCode)[0]; - messages[msg]['seen'] = true; - } + let baseDir = 'tests/baselines/reference/'; + fs.readdir(baseDir, (err, files) => { + files = files.filter(f => f.indexOf('.errors.txt') > 0); + let tasks: Array<(callback: () => void) => void> = []; + files.forEach(f => tasks.push(done => { + fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { + if (err) throw err; - done(); - }); - })); + let g: string[]; + while (g = errRegex.exec(baseline)) { + var errCode = +g[1]; + let msg = keys.filter(k => messages[k].code === errCode)[0]; + messages[msg]['seen'] = true; + } - async.parallelLimit(tasks, 25, done => { - console.log('== List of errors not present in baselines =='); - let count = 0; - for (let k of keys) { - if (messages[k]['seen'] !== true) { - console.log(k); - count++; - } - } - console.log(count + ' of ' + keys.length + ' errors are not in baselines'); - }); - }); + done(); + }); + })); + + async.parallelLimit(tasks, 25, done => { + console.log('== List of errors not present in baselines =='); + let count = 0; + for (let k of keys) { + if (messages[k]['seen'] !== true) { + console.log(k); + count++; + } + } + console.log(count + ' of ' + keys.length + ' errors are not in baselines'); + }); + }); }); fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => { - let errorRegexp = /\s(\w+): \{ code/g; - let errorNames: string[] = []; - let errMatch: string[]; - while (errMatch = errorRegexp.exec(data)) { - errorNames.push(errMatch[1]); - } + let errorRegexp = /\s(\w+): \{ code/g; + let errorNames: string[] = []; + let errMatch: string[]; + while (errMatch = errorRegexp.exec(data)) { + errorNames.push(errMatch[1]); + } - let allSrc: string = ''; - glob('./src/**/*.ts', {}, (err, files) => { - console.log('Reading ' + files.length + ' source files'); - for(let file of files) { - if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { - continue; - } + let allSrc: string = ''; + glob('./src/**/*.ts', {}, (err, files) => { + console.log('Reading ' + files.length + ' source files'); + for (let file of files) { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { + continue; + } - let src = fs.readFileSync(file, 'utf-8'); - allSrc = allSrc + src; - } + let src = fs.readFileSync(file, 'utf-8'); + allSrc = allSrc + src; + } - console.log('Consumed ' + allSrc.length + ' characters of source'); + console.log('Consumed ' + allSrc.length + ' characters of source'); - let count = 0; - console.log('== List of errors not used in source ==') - for(let errName of errorNames) { - if (allSrc.indexOf(errName) < 0) { - console.log(errName); - count++; - } - } - console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); - }); + let count = 0; + console.log('== List of errors not used in source ==') + for (let errName of errorNames) { + if (allSrc.indexOf(errName) < 0) { + console.log(errName); + count++; + } + } + console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); + }); }); From 1085e39b9a489f82b65c8dfff0e303abdf9e27d8 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 2 Jul 2015 15:20:57 -0700 Subject: [PATCH 218/250] Always take the apparent type when you retrieve a contextual type --- src/compiler/checker.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3d8ac1bc1b52..65545efbcd245 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6442,6 +6442,11 @@ namespace ts { // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node: Expression): Type { + let type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + + function getContextualTypeWorker(node: Expression): Type { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; From 98de6117f1cab5861bece38ece96b7e3b56abb5a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 2 Jul 2015 15:21:09 -0700 Subject: [PATCH 219/250] Accept baselines --- ...ndAdditionAssignmentLHSCanBeAssigned.types | 2 +- ...ualTypeWithUnionTypeCallSignatures.symbols | 2 ++ ...xtualTypeWithUnionTypeCallSignatures.types | 12 ++++---- .../functionConstraintSatisfaction3.types | 28 +++++++++---------- .../genericCallWithTupleType.errors.txt | 8 +++--- .../reference/noErrorsInCallback.errors.txt | 8 +++--- .../typeParameterFixingWithConstraints.types | 10 +++---- ...wrappedAndRecursiveConstraints4.errors.txt | 4 +-- 8 files changed, 38 insertions(+), 36 deletions(-) diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types index e40422450b44f..92835611c6dcc 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types @@ -98,7 +98,7 @@ x2 += E.a; x2 += {}; >x2 += {} : string >x2 : string ->{} : {} +>{} : { [x: number]: undefined; } x2 += null; >x2 += null : string diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols index 172336603ab2e..3e23a7812f5b3 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols @@ -82,5 +82,7 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1)) >IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) +>a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types index 02dfecf5c0845..8e1915d47549d 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types @@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >x4 : IWithCallSignatures | IWithCallSignatures4 >IWithCallSignatures : IWithCallSignatures >IWithCallSignatures4 : IWithCallSignatures4 ->a => /*here a should be any*/ a.toString() : (a: any) => any ->a : any ->a.toString() : any ->a.toString : any ->a : any ->toString : any +>a => /*here a should be any*/ a.toString() : (a: number) => string +>a : number +>a.toString() : string +>a.toString : (radix?: number) => string +>a : number +>toString : (radix?: number) => string diff --git a/tests/baselines/reference/functionConstraintSatisfaction3.types b/tests/baselines/reference/functionConstraintSatisfaction3.types index 04963c36519c1..c58e62f69955b 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction3.types +++ b/tests/baselines/reference/functionConstraintSatisfaction3.types @@ -37,12 +37,12 @@ var c: { (): string; (x): string }; >x : any var r1 = foo((x) => x); ->r1 : (x: any) => any ->foo((x) => x) : (x: any) => any +>r1 : (x: string) => string +>foo((x) => x) : (x: string) => string >foo : string>(x: T) => T ->(x) => x : (x: any) => any ->x : any ->x : any +>(x) => x : (x: string) => string +>x : string +>x : string var r2 = foo((x: string) => x); >r2 : (x: string) => string @@ -53,12 +53,12 @@ var r2 = foo((x: string) => x); >x : string var r3 = foo(function (x) { return x }); ->r3 : (x: any) => any ->foo(function (x) { return x }) : (x: any) => any +>r3 : (x: string) => string +>foo(function (x) { return x }) : (x: string) => string >foo : string>(x: T) => T ->function (x) { return x } : (x: any) => any ->x : any ->x : any +>function (x) { return x } : (x: string) => string +>x : string +>x : string var r4 = foo(function (x: string) { return x }); >r4 : (x: string) => string @@ -130,8 +130,8 @@ var c2: { (x: T): T; (x: T, y: T): T }; >T : T var r9 = foo(function (x: U) { return x; }); ->r9 : (x: U) => U ->foo(function (x: U) { return x; }) : (x: U) => U +>r9 : (x: string) => string +>foo(function (x: U) { return x; }) : (x: string) => string >foo : string>(x: T) => T >function (x: U) { return x; } : (x: U) => U >U : U @@ -140,8 +140,8 @@ var r9 = foo(function (x: U) { return x; }); >x : U var r10 = foo((x: U) => x); ->r10 : (x: U) => U ->foo((x: U) => x) : (x: U) => U +>r10 : (x: string) => string +>foo((x: U) => x) : (x: string) => string >foo : string>(x: T) => T >(x: U) => x : (x: U) => U >U : U diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index bcf580320e53e..d03f8d5e68a31 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -9,9 +9,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{ [x: number]: undefined; }' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. @@ -55,9 +55,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup !!! error TS2322: Type 'number' is not assignable to type 'string'. i1.tuple1 = [{}, {}]; ~~~~~~~~~ -!!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. +!!! error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. !!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{ [x: number]: undefined; }' is not assignable to type 'string'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/noErrorsInCallback.errors.txt b/tests/baselines/reference/noErrorsInCallback.errors.txt index f0bfe00199eb0..90fdbbd77a55f 100644 --- a/tests/baselines/reference/noErrorsInCallback.errors.txt +++ b/tests/baselines/reference/noErrorsInCallback.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. -tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/noErrorsInCallback.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type } var one = new Bar({}); // Error ~~ -!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. [].forEach(() => { var two = new Bar({}); // No error? ~~ -!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. }); \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterFixingWithConstraints.types b/tests/baselines/reference/typeParameterFixingWithConstraints.types index 64876952852b0..22d294f9d2edb 100644 --- a/tests/baselines/reference/typeParameterFixingWithConstraints.types +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.types @@ -31,17 +31,17 @@ var foo: IFoo; >IFoo : IFoo foo.foo({ bar: null }, bar => null, bar => null); ->foo.foo({ bar: null }, bar => null, bar => null) : IBar +>foo.foo({ bar: null }, bar => null, bar => null) : { [x: string]: any; bar: any; } >foo.foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >foo : IFoo >foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >{ bar: null } : { [x: string]: null; bar: null; } >bar : null >null : null ->bar => null : (bar: IBar) => any ->bar : IBar +>bar => null : (bar: { [x: string]: any; bar: any; }) => any +>bar : { [x: string]: any; bar: any; } >null : null ->bar => null : (bar: IBar) => any ->bar : IBar +>bar => null : (bar: { [x: string]: any; bar: any; }) => any +>bar : { [x: string]: any; bar: any; } >null : null diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt index 47e8e6ff4f295..60602351b465c 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ==== @@ -16,4 +16,4 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file From 652995181e41ca5b4347fdbd8f5377c2b944da6f Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 2 Jul 2015 15:21:43 -0700 Subject: [PATCH 220/250] Add tests for inferential typing --- .../inferentialTypingUsingApparentType1.js | 12 +++ ...nferentialTypingUsingApparentType1.symbols | 20 +++++ .../inferentialTypingUsingApparentType1.types | 22 ++++++ .../inferentialTypingUsingApparentType2.js | 12 +++ ...nferentialTypingUsingApparentType2.symbols | 22 ++++++ .../inferentialTypingUsingApparentType2.types | 24 ++++++ .../inferentialTypingUsingApparentType3.js | 56 ++++++++++++++ ...nferentialTypingUsingApparentType3.symbols | 69 +++++++++++++++++ .../inferentialTypingUsingApparentType3.types | 75 +++++++++++++++++++ .../inferentialTypingUsingApparentType1.ts | 5 ++ .../inferentialTypingUsingApparentType2.ts | 5 ++ .../inferentialTypingUsingApparentType3.ts | 26 +++++++ 12 files changed, 348 insertions(+) create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType1.js create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType1.symbols create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType1.types create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType2.js create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType2.symbols create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType2.types create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType3.js create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType3.symbols create mode 100644 tests/baselines/reference/inferentialTypingUsingApparentType3.types create mode 100644 tests/cases/compiler/inferentialTypingUsingApparentType1.ts create mode 100644 tests/cases/compiler/inferentialTypingUsingApparentType2.ts create mode 100644 tests/cases/compiler/inferentialTypingUsingApparentType3.ts diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.js b/tests/baselines/reference/inferentialTypingUsingApparentType1.js new file mode 100644 index 0000000000000..02161a98695a9 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.js @@ -0,0 +1,12 @@ +//// [inferentialTypingUsingApparentType1.ts] +function foo number>(x: T): T { + return undefined; +} + +foo(x => x.length); + +//// [inferentialTypingUsingApparentType1.js] +function foo(x) { + return undefined; +} +foo(function (x) { return x.length; }); diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols new file mode 100644 index 0000000000000..4babc614183de --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType1.ts === +function foo number>(x: T): T { +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType1.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) +>p : Symbol(p, Decl(inferentialTypingUsingApparentType1.ts, 0, 24)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 0, 46)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo(x => x.length); +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType1.ts, 0, 0)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 4, 4)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 4, 4)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.types b/tests/baselines/reference/inferentialTypingUsingApparentType1.types new file mode 100644 index 0000000000000..b56f3670ddcc9 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType1.ts === +function foo number>(x: T): T { +>foo : number>(x: T) => T +>T : T +>p : string +>x : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo(x => x.length); +>foo(x => x.length) : (x: string) => number +>foo : number>(x: T) => T +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.js b/tests/baselines/reference/inferentialTypingUsingApparentType2.js new file mode 100644 index 0000000000000..7cb7e49cd62fe --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.js @@ -0,0 +1,12 @@ +//// [inferentialTypingUsingApparentType2.ts] +function foo(x: T): T { + return undefined; +} + +foo({ m(x) { return x.length } }); + +//// [inferentialTypingUsingApparentType2.js] +function foo(x) { + return undefined; +} +foo({ m: function (x) { return x.length; } }); diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols new file mode 100644 index 0000000000000..3c47eb4c6977b --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType2.ts === +function foo(x: T): T { +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType2.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) +>m : Symbol(m, Decl(inferentialTypingUsingApparentType2.ts, 0, 24)) +>p : Symbol(p, Decl(inferentialTypingUsingApparentType2.ts, 0, 27)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 0, 49)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo({ m(x) { return x.length } }); +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType2.ts, 0, 0)) +>m : Symbol(m, Decl(inferentialTypingUsingApparentType2.ts, 4, 5)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 4, 8)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 4, 8)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.types b/tests/baselines/reference/inferentialTypingUsingApparentType2.types new file mode 100644 index 0000000000000..597f5885f5ae1 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType2.ts === +function foo(x: T): T { +>foo : (x: T) => T +>T : T +>m : (p: string) => number +>p : string +>x : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo({ m(x) { return x.length } }); +>foo({ m(x) { return x.length } }) : { } +>foo : (x: T) => T +>{ m(x) { return x.length } } : { m(x: string): number; } +>m : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.js b/tests/baselines/reference/inferentialTypingUsingApparentType3.js new file mode 100644 index 0000000000000..819ca05098dce --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.js @@ -0,0 +1,56 @@ +//// [inferentialTypingUsingApparentType3.ts] +interface Field { + clean(input: T): T +} + +class CharField implements Field { + clean(input: string) { + return "Yup"; + } +} + +class NumberField implements Field { + clean(input: number) { + return 123; + } +} + +class ObjectField }> { + constructor(public fields: T) { } +} + +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); + +person.fields.id; + +//// [inferentialTypingUsingApparentType3.js] +var CharField = (function () { + function CharField() { + } + CharField.prototype.clean = function (input) { + return "Yup"; + }; + return CharField; +})(); +var NumberField = (function () { + function NumberField() { + } + NumberField.prototype.clean = function (input) { + return 123; + }; + return NumberField; +})(); +var ObjectField = (function () { + function ObjectField(fields) { + this.fields = fields; + } + return ObjectField; +})(); +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); +person.fields.id; diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols new file mode 100644 index 0000000000000..ac3058e8649ec --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType3.ts === +interface Field { +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) + + clean(input: T): T +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 0, 20)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 1, 10)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) +} + +class CharField implements Field { +>CharField : Symbol(CharField, Decl(inferentialTypingUsingApparentType3.ts, 2, 1)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + clean(input: string) { +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 4, 42)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 5, 10)) + + return "Yup"; + } +} + +class NumberField implements Field { +>NumberField : Symbol(NumberField, Decl(inferentialTypingUsingApparentType3.ts, 8, 1)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + clean(input: number) { +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 10, 44)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 11, 10)) + + return 123; + } +} + +class ObjectField }> { +>ObjectField : Symbol(ObjectField, Decl(inferentialTypingUsingApparentType3.ts, 14, 1)) +>A : Symbol(A, Decl(inferentialTypingUsingApparentType3.ts, 16, 18)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 16, 20)) +>name : Symbol(name, Decl(inferentialTypingUsingApparentType3.ts, 16, 34)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + constructor(public fields: T) { } +>fields : Symbol(fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 16, 20)) +} + +var person = new ObjectField({ +>person : Symbol(person, Decl(inferentialTypingUsingApparentType3.ts, 20, 3)) +>ObjectField : Symbol(ObjectField, Decl(inferentialTypingUsingApparentType3.ts, 14, 1)) + + id: new NumberField(), +>id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) +>NumberField : Symbol(NumberField, Decl(inferentialTypingUsingApparentType3.ts, 8, 1)) + + name: new CharField() +>name : Symbol(name, Decl(inferentialTypingUsingApparentType3.ts, 21, 26)) +>CharField : Symbol(CharField, Decl(inferentialTypingUsingApparentType3.ts, 2, 1)) + +}); + +person.fields.id; +>person.fields.id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) +>person.fields : Symbol(ObjectField.fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>person : Symbol(person, Decl(inferentialTypingUsingApparentType3.ts, 20, 3)) +>fields : Symbol(ObjectField.fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.types b/tests/baselines/reference/inferentialTypingUsingApparentType3.types new file mode 100644 index 0000000000000..7d0da8f4b06c0 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.types @@ -0,0 +1,75 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType3.ts === +interface Field { +>Field : Field +>T : T + + clean(input: T): T +>clean : (input: T) => T +>input : T +>T : T +>T : T +} + +class CharField implements Field { +>CharField : CharField +>Field : Field + + clean(input: string) { +>clean : (input: string) => string +>input : string + + return "Yup"; +>"Yup" : string + } +} + +class NumberField implements Field { +>NumberField : NumberField +>Field : Field + + clean(input: number) { +>clean : (input: number) => number +>input : number + + return 123; +>123 : number + } +} + +class ObjectField }> { +>ObjectField : ObjectField +>A : A +>T : T +>name : string +>Field : Field + + constructor(public fields: T) { } +>fields : T +>T : T +} + +var person = new ObjectField({ +>person : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>new ObjectField({ id: new NumberField(), name: new CharField()}) : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>ObjectField : typeof ObjectField +>{ id: new NumberField(), name: new CharField()} : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } + + id: new NumberField(), +>id : NumberField +>new NumberField() : NumberField +>NumberField : typeof NumberField + + name: new CharField() +>name : CharField +>new CharField() : CharField +>CharField : typeof CharField + +}); + +person.fields.id; +>person.fields.id : NumberField +>person.fields : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } +>person : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>fields : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } +>id : NumberField + diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType1.ts b/tests/cases/compiler/inferentialTypingUsingApparentType1.ts new file mode 100644 index 0000000000000..98920cf693f62 --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType1.ts @@ -0,0 +1,5 @@ +function foo number>(x: T): T { + return undefined; +} + +foo(x => x.length); \ No newline at end of file diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType2.ts b/tests/cases/compiler/inferentialTypingUsingApparentType2.ts new file mode 100644 index 0000000000000..8290b14927d1a --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType2.ts @@ -0,0 +1,5 @@ +function foo(x: T): T { + return undefined; +} + +foo({ m(x) { return x.length } }); \ No newline at end of file diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType3.ts b/tests/cases/compiler/inferentialTypingUsingApparentType3.ts new file mode 100644 index 0000000000000..d1734b0d100cf --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType3.ts @@ -0,0 +1,26 @@ +interface Field { + clean(input: T): T +} + +class CharField implements Field { + clean(input: string) { + return "Yup"; + } +} + +class NumberField implements Field { + clean(input: number) { + return 123; + } +} + +class ObjectField }> { + constructor(public fields: T) { } +} + +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); + +person.fields.id; \ No newline at end of file From a61ec94501ccabae192415067101c58f4d916c5c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 16:04:34 -0700 Subject: [PATCH 221/250] Remove unnecessary check. --- src/services/services.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 159b1b817b1fb..80fde22c73bb9 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3359,7 +3359,6 @@ namespace ts { case SyntaxKind.DotDotDotToken: return containingNodeKind === SyntaxKind.Parameter || - containingNodeKind === SyntaxKind.Constructor || (previousToken.parent && previousToken.parent.parent && previousToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [...z| From 0fcc63e33e5a8d1f9d63e28d3de5e356c0e3f7e4 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 2 Jul 2015 16:13:38 -0700 Subject: [PATCH 222/250] Disallow modifiers on rest parameters --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c257f6c702e05..f2f39b7495c26 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1979,8 +1979,8 @@ namespace ts { function parseParameter(): ParameterDeclaration { let node = createNode(SyntaxKind.Parameter); node.decorators = parseDecorators(); - node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] From 35db9f68f426e452322c05619ad92ae45c6f626b Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 2 Jul 2015 16:13:47 -0700 Subject: [PATCH 223/250] Add tests --- .../reference/restParamModifier.errors.txt | 21 +++++++++++++++++++ .../baselines/reference/restParamModifier.js | 12 +++++++++++ .../reference/restParamModifier2.errors.txt | 9 ++++++++ .../baselines/reference/restParamModifier2.js | 15 +++++++++++++ tests/cases/compiler/restParamModifier.ts | 3 +++ tests/cases/compiler/restParamModifier2.ts | 3 +++ 6 files changed, 63 insertions(+) create mode 100644 tests/baselines/reference/restParamModifier.errors.txt create mode 100644 tests/baselines/reference/restParamModifier.js create mode 100644 tests/baselines/reference/restParamModifier2.errors.txt create mode 100644 tests/baselines/reference/restParamModifier2.js create mode 100644 tests/cases/compiler/restParamModifier.ts create mode 100644 tests/cases/compiler/restParamModifier2.ts diff --git a/tests/baselines/reference/restParamModifier.errors.txt b/tests/baselines/reference/restParamModifier.errors.txt new file mode 100644 index 0000000000000..87c73fcdc711f --- /dev/null +++ b/tests/baselines/reference/restParamModifier.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/restParamModifier.ts(2,17): error TS2370: A rest parameter must be of an array type. +tests/cases/compiler/restParamModifier.ts(2,27): error TS1005: '=' expected. +tests/cases/compiler/restParamModifier.ts(2,27): error TS2304: Cannot find name 'rest'. +tests/cases/compiler/restParamModifier.ts(2,31): error TS1005: ',' expected. +tests/cases/compiler/restParamModifier.ts(2,39): error TS1005: '=' expected. + + +==== tests/cases/compiler/restParamModifier.ts (5 errors) ==== + class C { + constructor(...public rest: string[]) {} + ~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'rest'. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier.js b/tests/baselines/reference/restParamModifier.js new file mode 100644 index 0000000000000..9a780321dc987 --- /dev/null +++ b/tests/baselines/reference/restParamModifier.js @@ -0,0 +1,12 @@ +//// [restParamModifier.ts] +class C { + constructor(...public rest: string[]) {} +} + +//// [restParamModifier.js] +var C = (function () { + function C(public, string) { + if (string === void 0) { string = []; } + } + return C; +})(); diff --git a/tests/baselines/reference/restParamModifier2.errors.txt b/tests/baselines/reference/restParamModifier2.errors.txt new file mode 100644 index 0000000000000..773592fa9bfdd --- /dev/null +++ b/tests/baselines/reference/restParamModifier2.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/restParamModifier2.ts(2,24): error TS1005: ',' expected. + + +==== tests/cases/compiler/restParamModifier2.ts (1 errors) ==== + class C { + constructor(public ...rest: string[]) {} + ~~~ +!!! error TS1005: ',' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier2.js b/tests/baselines/reference/restParamModifier2.js new file mode 100644 index 0000000000000..c588c945ce4b5 --- /dev/null +++ b/tests/baselines/reference/restParamModifier2.js @@ -0,0 +1,15 @@ +//// [restParamModifier2.ts] +class C { + constructor(public ...rest: string[]) {} +} + +//// [restParamModifier2.js] +var C = (function () { + function C(public) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + return C; +})(); diff --git a/tests/cases/compiler/restParamModifier.ts b/tests/cases/compiler/restParamModifier.ts new file mode 100644 index 0000000000000..220b7d36d5e33 --- /dev/null +++ b/tests/cases/compiler/restParamModifier.ts @@ -0,0 +1,3 @@ +class C { + constructor(...public rest: string[]) {} +} \ No newline at end of file diff --git a/tests/cases/compiler/restParamModifier2.ts b/tests/cases/compiler/restParamModifier2.ts new file mode 100644 index 0000000000000..e007bc56d7c1e --- /dev/null +++ b/tests/cases/compiler/restParamModifier2.ts @@ -0,0 +1,3 @@ +class C { + constructor(public ...rest: string[]) {} +} \ No newline at end of file From 4a53096171c9ad64b2517558718df9db72b002ed Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 16:14:06 -0700 Subject: [PATCH 224/250] Added test. --- .../cases/fourslash/completionListAfterSpreadOperator01.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/cases/fourslash/completionListAfterSpreadOperator01.ts diff --git a/tests/cases/fourslash/completionListAfterSpreadOperator01.ts b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts new file mode 100644 index 0000000000000..48a50124daf3d --- /dev/null +++ b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts @@ -0,0 +1,7 @@ +/// + +////let v = [1,2,3,4]; +////let x = [.../**/ + +goTo.marker(); +verify.completionListContains("v"); \ No newline at end of file From 935071f1c53bf042a62a7f9a5b4b0e6e853fc653 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 16:21:09 -0700 Subject: [PATCH 225/250] Don't show completion with dots not part of property accesses and qualified names. --- src/services/services.ts | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 80fde22c73bb9..71f92d0c4c87d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2902,23 +2902,30 @@ namespace ts { let jsx = options.jsx !== JsxEmit.None; let target = options.target; - // Find the node where completion is requested on, in the case of a completion after - // a dot, it is the member access expression other wise, it is a request for all - // visible symbols in the scope, and the node is the current location. + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. let node = currentToken; let isRightOfDot = false; let isRightOfOpenTag = false; let location = getTouchingPropertyName(sourceFile, position); - if(contextToken) { - let kind = contextToken.kind; - if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (contextToken.parent).expression; - isRightOfDot = true; - } - else if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { - node = (contextToken.parent).left; - isRightOfDot = true; + if (contextToken) { + let { parent, kind } = contextToken; + if (kind === SyntaxKind.DotToken) { + if (parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; + isRightOfDot = true; + } + else if (parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } } else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { isRightOfOpenTag = true; From d89c1d6586b79de7b0a8470b1b4f205cc4627e37 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 17:08:03 -0700 Subject: [PATCH 226/250] Fixed/added test. --- .../fourslash/completionListBuilderLocations_Modules.ts | 3 +-- tests/cases/fourslash/memberListAfterDoubleDot.ts | 6 ++++++ tests/cases/fourslash/memberListAfterSingleDot.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/memberListAfterDoubleDot.ts diff --git a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts index eac7085ab6668..8a136d0125c2a 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts @@ -8,6 +8,5 @@ test.markers().forEach((m) => { goTo.position(m.position, m.fileName); - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); + verify.completionListIsEmpty(); }); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterDoubleDot.ts b/tests/cases/fourslash/memberListAfterDoubleDot.ts new file mode 100644 index 0000000000000..21a1ad913eaaf --- /dev/null +++ b/tests/cases/fourslash/memberListAfterDoubleDot.ts @@ -0,0 +1,6 @@ +/// + +////../**/ + +goTo.marker(); +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterSingleDot.ts b/tests/cases/fourslash/memberListAfterSingleDot.ts index 0bc5107f2c1bb..62edf3b8c9ed4 100644 --- a/tests/cases/fourslash/memberListAfterSingleDot.ts +++ b/tests/cases/fourslash/memberListAfterSingleDot.ts @@ -3,4 +3,4 @@ ////./**/ goTo.marker(); -verify.not.memberListIsEmpty(); \ No newline at end of file +verify.memberListIsEmpty(); \ No newline at end of file From 144a635bc54bf90515c55fccccac2bb62b949270 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Jul 2015 11:20:44 -0700 Subject: [PATCH 227/250] Changing comment per CR feedback --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index be823989b82da..1e57cba0077d5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4486,9 +4486,9 @@ namespace ts { } } else { - // A check of the form A | B = C & D can be satisfied either by having C be related to A | B, - // D be related to A | B, C & D be related to A, or C & D be related to B. Thus, we need to - // check both sides here. + // It is necessary to try "each" checks on both sides because there may be nested "some" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). if (source.flags & TypeFlags.Intersection) { // If target is a union type the following check will report errors so we suppress them here if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { From 3fe0d3defe974a72382f22917486247644dea20e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 11:30:43 -0700 Subject: [PATCH 228/250] Updated test. --- .../fourslash/completionListBuilderLocations_Modules.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts index 8a136d0125c2a..0552e540a7e8c 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts @@ -5,8 +5,8 @@ ////module A./*moduleName2*/ +goTo.marker("moduleName1"); +verify.not.completionListIsEmpty(); -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); \ No newline at end of file +goTo.marker("moduleName2"); +verify.completionListIsEmpty(); From 48c48417a6d1b6ab4ef383fa30e3097514b9b680 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 6 Jul 2015 11:42:06 -0700 Subject: [PATCH 229/250] Properly parse keyword-like identifiers in JSX --- src/compiler/parser.ts | 9 +++++++-- .../tsxAttributeResolution1.errors.txt | 17 +++++++++++------ .../reference/tsxAttributeResolution1.js | 11 +++++++---- .../conformance/jsx/tsxAttributeResolution1.tsx | 6 ++++-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f2f39b7495c26..64aace445cfe7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1245,6 +1245,11 @@ namespace ts { return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function isHeritageClauseExtendsOrImplementsKeyword(): boolean { if (token === SyntaxKind.ImplementsKeyword || token === SyntaxKind.ExtendsKeyword) { @@ -3163,7 +3168,7 @@ namespace ts { if (sourceFile.languageVariant !== LanguageVariant.JSX) { return parseTypeAssertion(); } - if(lookAhead(nextTokenIsIdentifier)) { + if(lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(); } // Fall through @@ -3381,7 +3386,7 @@ namespace ts { function parseJsxElementName(): EntityName { scanJsxIdentifier(); - let elementName: EntityName = parseIdentifier(); + let elementName: EntityName = parseIdentifierName(); while (parseOptional(SyntaxKind.DotToken)) { scanJsxIdentifier(); let node = createNode(SyntaxKind.QualifiedName, elementName.pos); diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt index 54666f46abac9..7503c5f5969ad 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -1,17 +1,19 @@ -tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(22,8): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(26,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(27,8): error TS2339: Property 'var' does not exist on type 'Attribs1'. tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (6 errors) ==== +==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (7 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; + var: { var: string }; } } interface Attribs1 { @@ -40,8 +42,9 @@ tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Typ ; // Error, "32" is not number ~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. - // TODO attribute 'var' should be parseable - // ; // Error, no 'var' property + ; // Error, no 'var' property + ~~~ +!!! error TS2339: Property 'var' does not exist on type 'Attribs1'. ; // Error, missing reqd ~~~~~~~~~ @@ -50,4 +53,6 @@ tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Typ ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. + // Should be OK + ; \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution1.js b/tests/baselines/reference/tsxAttributeResolution1.js index 011ac8034e2ce..1e1efb7ea22e3 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.js +++ b/tests/baselines/reference/tsxAttributeResolution1.js @@ -4,6 +4,7 @@ declare module JSX { interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; + var: { var: string }; } } interface Attribs1 { @@ -24,12 +25,13 @@ interface Attribs1 { ; // Error, no property "y" ; // Error, no property "y" ; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property +; // Error, no 'var' property ; // Error, missing reqd ; // Error, reqd is not string +// Should be OK +; //// [tsxAttributeResolution1.jsx] @@ -44,7 +46,8 @@ interface Attribs1 { ; // Error, no property "y" ; // Error, no property "y" ; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property +; // Error, no 'var' property ; // Error, missing reqd ; // Error, reqd is not string +// Should be OK +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx index edb203655efa8..eff3f3a8f435a 100644 --- a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx @@ -5,6 +5,7 @@ declare module JSX { interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; + var: { var: string }; } } interface Attribs1 { @@ -25,9 +26,10 @@ interface Attribs1 { ; // Error, no property "y" ; // Error, no property "y" ; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property +; // Error, no 'var' property ; // Error, missing reqd ; // Error, reqd is not string +// Should be OK +; From a7983a4f3e676cd75a971dc3d69e99f36f103b7c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 12:40:05 -0700 Subject: [PATCH 230/250] Added test for JSX spread properties. --- tests/cases/fourslash/tsxCompletion4.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/cases/fourslash/tsxCompletion4.ts diff --git a/tests/cases/fourslash/tsxCompletion4.ts b/tests/cases/fourslash/tsxCompletion4.ts new file mode 100644 index 0000000000000..6a66c4a898ff6 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion4.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare namespace JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +//// let bag = { x: 100, y: 200 }; +////
Date: Mon, 6 Jul 2015 13:00:10 -0700 Subject: [PATCH 231/250] previousToken -> contextToken --- src/services/services.ts | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 71f92d0c4c87d..ac55e888c036c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3142,11 +3142,11 @@ namespace ts { return scope; } - function isCompletionListBlocker(previousToken: Node): boolean { + function isCompletionListBlocker(contextToken: Node): boolean { let start = new Date().getTime(); - let result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isRightOfIllegalDot(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } @@ -3225,12 +3225,12 @@ namespace ts { return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean { - if (previousToken.kind === SyntaxKind.StringLiteral - || previousToken.kind === SyntaxKind.RegularExpressionLiteral - || isTemplateLiteralKind(previousToken.kind)) { - let start = previousToken.getStart(); - let end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken: Node): boolean { + if (contextToken.kind === SyntaxKind.StringLiteral + || contextToken.kind === SyntaxKind.RegularExpressionLiteral + || isTemplateLiteralKind(contextToken.kind)) { + let start = contextToken.getStart(); + let end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -3241,8 +3241,8 @@ namespace ts { } if (position === end) { - return !!(previousToken).isUnterminated || - previousToken.kind === SyntaxKind.RegularExpressionLiteral; + return !!(contextToken).isUnterminated || + contextToken.kind === SyntaxKind.RegularExpressionLiteral; } } @@ -3316,10 +3316,10 @@ namespace ts { return false; } - function isIdentifierDefinitionLocation(previousToken: Node): boolean { - if (previousToken) { - let containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { + function isIdentifierDefinitionLocation(contextToken: Node): boolean { + if (contextToken) { + let containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.VariableDeclaration || containingNodeKind === SyntaxKind.VariableDeclarationList || @@ -3351,9 +3351,9 @@ namespace ts { case SyntaxKind.SemicolonToken: return containingNodeKind === SyntaxKind.PropertySignature && - previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === SyntaxKind.InterfaceDeclaration || // interface a { f; | - previousToken.parent.parent.kind === SyntaxKind.TypeLiteral); // let x : { a; | + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === SyntaxKind.InterfaceDeclaration || // interface a { f; | + contextToken.parent.parent.kind === SyntaxKind.TypeLiteral); // let x : { a; | case SyntaxKind.LessThanToken: return containingNodeKind === SyntaxKind.ClassDeclaration || // class A< | @@ -3366,8 +3366,8 @@ namespace ts { case SyntaxKind.DotDotDotToken: return containingNodeKind === SyntaxKind.Parameter || - (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [...z| + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [...z| case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: @@ -3390,7 +3390,7 @@ namespace ts { } // Previous token may have been a keyword that was converted to an identifier. - switch (previousToken.getText()) { + switch (contextToken.getText()) { case "class": case "interface": case "enum": @@ -3407,9 +3407,9 @@ namespace ts { return false; } - function isRightOfIllegalDot(previousToken: Node): boolean { - if (previousToken && previousToken.kind === SyntaxKind.NumericLiteral) { - let text = previousToken.getFullText(); + function isRightOfIllegalDot(contextToken: Node): boolean { + if (contextToken && contextToken.kind === SyntaxKind.NumericLiteral) { + let text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } From cacc366809294e6f6552688d9637c031944394b5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 13:27:00 -0700 Subject: [PATCH 232/250] Avoid unnecessary contextToken checking, addressed CR feedback. --- src/services/services.ts | 184 +++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 95 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index ac55e888c036c..3d92bd5b476e0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2892,16 +2892,6 @@ namespace ts { log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); } - // Check if this is a valid completion location - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - - let options = program.getCompilerOptions(); - let jsx = options.jsx !== JsxEmit.None; - let target = options.target; - // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node // or attributes of a JSX tag. @@ -2911,6 +2901,12 @@ namespace ts { let location = getTouchingPropertyName(sourceFile, position); if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + let { parent, kind } = contextToken; if (kind === SyntaxKind.DotToken) { if (parent.kind === SyntaxKind.PropertyAccessExpression) { @@ -3146,7 +3142,7 @@ namespace ts { let start = new Date().getTime(); let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isIdentifierDefinitionLocation(contextToken) || - isRightOfIllegalDot(contextToken); + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } @@ -3241,8 +3237,8 @@ namespace ts { } if (position === end) { - return !!(contextToken).isUnterminated || - contextToken.kind === SyntaxKind.RegularExpressionLiteral; + return !!(contextToken).isUnterminated + || contextToken.kind === SyntaxKind.RegularExpressionLiteral; } } @@ -3317,98 +3313,96 @@ namespace ts { } function isIdentifierDefinitionLocation(contextToken: Node): boolean { - if (contextToken) { - let containingNodeKind = contextToken.parent.kind; - switch (contextToken.kind) { - case SyntaxKind.CommaToken: - return containingNodeKind === SyntaxKind.VariableDeclaration || - containingNodeKind === SyntaxKind.VariableDeclarationList || - containingNodeKind === SyntaxKind.VariableStatement || - containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | - isFunction(containingNodeKind) || - containingNodeKind === SyntaxKind.ClassDeclaration || // class A Date: Mon, 6 Jul 2015 14:04:42 -0700 Subject: [PATCH 233/250] Throttle how often we call into the host side to check for cancellation. --- src/services/services.ts | 1 - src/services/shims.ts | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 19dd52887214c..1e98e29d4cfa9 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1618,7 +1618,6 @@ namespace ts { export class OperationCanceledException { } export class CancellationTokenObject { - public static None: CancellationTokenObject = new CancellationTokenObject(null) constructor(private cancellationToken: CancellationToken) { diff --git a/src/services/shims.ts b/src/services/shims.ts index 2e8b3eb774d59..22c0d3f6065fc 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -327,7 +327,8 @@ namespace ts { } public getCancellationToken(): CancellationToken { - return this.shimHost.getCancellationToken(); + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); } public getCurrentDirectory(): string { @@ -346,6 +347,29 @@ namespace ts { } } + /** A cancellation that throttles calls to the host */ + class ThrottledCancellationToken implements CancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + + constructor(private hostCancellationToken: CancellationToken) { + } + + public isCancellationRequested(): boolean { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + } + export class CoreServicesShimHostAdapter implements ParseConfigHost { constructor(private shimHost: CoreServicesShimHost) { From 370372e043dacde018f0689c1f4b836116e4260d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 6 Jul 2015 14:25:18 -0700 Subject: [PATCH 234/250] Remove shim cancellation test. --- ...cellationWhenfindingAllRefsOnDefinition.ts | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts diff --git a/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts b/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts deleted file mode 100644 index 09f580bb96540..0000000000000 --- a/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -//@Filename: findAllRefsOnDefinition-import.ts -////export class Test{ -//// -//// constructor(){ -//// -//// } -//// -//// public /*1*/start(){ -//// return this; -//// } -//// -//// public stop(){ -//// return this; -//// } -////} - -//@Filename: findAllRefsOnDefinition.ts -////import Second = require("findAllRefsOnDefinition-import"); -//// -////var second = new Second.Test() -////second.start(); -////second.stop(); - -goTo.file("findAllRefsOnDefinition-import.ts"); -goTo.marker("1"); - -verify.referencesCountIs(2); - -cancellation.setCancelled(); -goTo.marker("1"); -verifyOperationIsCancelled(() => verify.referencesCountIs(0) ); - -// verify that internal state is still correct -cancellation.resetCancelled(); -goTo.marker("1"); -verify.referencesCountIs(2); From 276e7989aa414a7b6fdc50df21fe10fb15eb1d88 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 14:47:39 -0700 Subject: [PATCH 235/250] Use a more accurate test name. --- ...{completionForExports.ts => completionListInImportClause01.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/cases/fourslash/{completionForExports.ts => completionListInImportClause01.ts} (100%) diff --git a/tests/cases/fourslash/completionForExports.ts b/tests/cases/fourslash/completionListInImportClause01.ts similarity index 100% rename from tests/cases/fourslash/completionForExports.ts rename to tests/cases/fourslash/completionListInImportClause01.ts From 03444a4d349c1d1b3b46cffa55ea096f479c1324 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 15:02:18 -0700 Subject: [PATCH 236/250] Verify builders. --- .../completionListInImportClause01.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/cases/fourslash/completionListInImportClause01.ts b/tests/cases/fourslash/completionListInImportClause01.ts index 57c0f75efc16d..cf053868dd636 100644 --- a/tests/cases/fourslash/completionListInImportClause01.ts +++ b/tests/cases/fourslash/completionListInImportClause01.ts @@ -11,22 +11,29 @@ ////import {foo,/*4*/ from "m1" ////import {bar as /*5*/, /*6*/ from "m1" ////import {foo, bar, baz as b,/*7*/} from "m1" -function verifyCompletionAtMarker(marker: string, ...completions: string[]) { +function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { goTo.marker(marker); if (completions.length) { - for (var i = 0; i < completions.length; ++i) { + for (let i = 0; i < completions.length; ++i) { verify.completionListContains(completions[i]); } } else { verify.completionListIsEmpty(); } + + if (showBuilder) { + verify.completionListAllowsNewIdentifier(); + } + else { + verify.not.completionListAllowsNewIdentifier(); + } } -verifyCompletionAtMarker("1", "foo", "bar", "baz"); -verifyCompletionAtMarker("2", "foo", "bar", "baz"); -verifyCompletionAtMarker("3", "foo", "bar", "baz"); -verifyCompletionAtMarker("4", "bar", "baz"); -verifyCompletionAtMarker("5"); -verifyCompletionAtMarker("6", "foo", "baz"); -verifyCompletionAtMarker("7"); \ No newline at end of file +verifyCompletionAtMarker("1", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("2", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("3", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("4", /*showBuilder*/ false, "bar", "baz"); +verifyCompletionAtMarker("5", /*showBuilder*/ true); +verifyCompletionAtMarker("6", /*showBuilder*/ false, "foo", "baz"); +verifyCompletionAtMarker("7", /*showBuilder*/ false); \ No newline at end of file From 52581678d4f8341d0c83c2ae6991fab82edc75b6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 15:05:47 -0700 Subject: [PATCH 237/250] Refactor completion code for object literals/bindings and import clauses. --- src/services/services.ts | 114 ++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e401182fb1112..6f7d233244eae 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3010,59 +3010,21 @@ namespace ts { } function tryGetGlobalSymbols(): boolean { - let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); - let jsxContainer = tryGetContainingJsxElement(contextToken); - if (objectLikeContainer) { - // Object literal expression, look up possible property names from contextual type - isMemberCompletion = true; - isNewIdentifierLocation = true; + let objectLikeContainer: ObjectLiteralExpression | BindingPattern; + let importClause: ImportClause; + let jsxContainer: JsxOpeningLikeElement; - let typeForObject: Type; - let existingMembers: Declaration[]; - - if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = (objectLikeContainer).properties; - } - else { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = (objectLikeContainer).elements; - } - - if (!typeForObject) { - return false; - } - - let typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); - } - return true; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { - // cursor is in import clause - // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); - Debug.assert(importDeclaration !== undefined); - - let exports: Symbol[]; - if (importDeclaration.moduleSpecifier) { - let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - } - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; - } - return true; + if (importClause = getAncestor(contextToken, SyntaxKind.ImportClause)) { + // cursor is in an import clause + // try to show exported member for imported module + return tryGetImportClauseCompletionSymbols(importClause); } - else if (jsxContainer) { + + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { let attrsType: Type; if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { // Cursor is inside a JSX self-closing element or opening element @@ -3144,7 +3106,7 @@ namespace ts { return result; } - function showCompletionsInImportsClause(node: Node): boolean { + function shouldShowCompletionsInImportsClause(node: Node): boolean { if (node) { // import {| // import {a,| @@ -3242,6 +3204,58 @@ namespace ts { return false; } + function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | BindingPattern): boolean { + // Object literal expression, look up possible property names from contextual type + isMemberCompletion = true; + isNewIdentifierLocation = true; + + let typeForObject: Type; + let existingMembers: Declaration[]; + + if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = (objectLikeContainer).properties; + } + else { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = (objectLikeContainer).elements; + } + + if (!typeForObject) { + return false; + } + + let typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + + function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean { + // cursor is in import clause + // try to show exported member for imported module + isMemberCompletion = true; + isNewIdentifierLocation = true; + if (shouldShowCompletionsInImportsClause(contextToken)) { + let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); + Debug.assert(importDeclaration !== undefined); + + let exports: Symbol[]; + if (importDeclaration.moduleSpecifier) { + let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + } + + //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); + symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + } + return true; + } + /** * Returns the immediate owning object literal or binding pattern of a context token, * on the condition that one exists and that the context implies completion should be given. From 4906f41f94cc7112a675699fc77c9b8ff085460a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 15:12:16 -0700 Subject: [PATCH 238/250] Remove builder from import clauses. --- src/services/services.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 6f7d233244eae..5f2d171448277 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3236,9 +3236,10 @@ namespace ts { function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean { // cursor is in import clause // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); Debug.assert(importDeclaration !== undefined); @@ -3253,6 +3254,11 @@ namespace ts { //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + return true; } From 40a6300e02de76eebc4ab35ae4c113dd23185555 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 15:15:04 -0700 Subject: [PATCH 239/250] Added original test case. --- .../completionListInImportClause02.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/cases/fourslash/completionListInImportClause02.ts diff --git a/tests/cases/fourslash/completionListInImportClause02.ts b/tests/cases/fourslash/completionListInImportClause02.ts new file mode 100644 index 0000000000000..570dd452a7ff7 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause02.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: m1.ts +////export var foo: number = 1; +////export function bar() { return 10; } +////export function baz() { return 10; } + +////declare module "M1" { +//// export var V; +////} +//// +////declare module "M2" { +//// import { /**/ } from "M1" +////} + +goTo.marker(); +verify.completionListContains("V"); +verify.not.completionListAllowsNewIdentifier(); From 3a26cd21f99771258f257d183bdfc389e780614c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 6 Jul 2015 15:31:22 -0700 Subject: [PATCH 240/250] Adding comments. --- src/compiler/checker.ts | 12 +++++++++++- src/compiler/program.ts | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 308fe38de715d..3ef2c6ada2a91 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22,6 +22,17 @@ namespace ts { } export function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + let cancellationToken: CancellationToken; + let Symbol = objectAllocator.getSymbolConstructor(); let Type = objectAllocator.getTypeConstructor(); let Signature = objectAllocator.getSignatureConstructor(); @@ -13321,7 +13332,6 @@ namespace ts { } } - var cancellationToken: CancellationToken; function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken): Diagnostic[] { try { // Record the cancellation token so it can be checked later on during checkSourceElement. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ae4180cf8be99..28efaf24cca19 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -313,6 +313,13 @@ namespace ts { if (e instanceof OperationCanceledException) { // We were canceled while performing the operation. Because our type checker // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. noDiagnosticsTypeChecker = undefined; diagnosticsProducingTypeChecker = undefined; } From 97dd855663e48ee6d84e99869fc70c543dba5193 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 15:33:49 -0700 Subject: [PATCH 241/250] Fix test. --- tests/cases/fourslash/completionListInImportClause02.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/cases/fourslash/completionListInImportClause02.ts b/tests/cases/fourslash/completionListInImportClause02.ts index 570dd452a7ff7..9cf216f4578c9 100644 --- a/tests/cases/fourslash/completionListInImportClause02.ts +++ b/tests/cases/fourslash/completionListInImportClause02.ts @@ -1,10 +1,5 @@ /// -// @Filename: m1.ts -////export var foo: number = 1; -////export function bar() { return 10; } -////export function baz() { return 10; } - ////declare module "M1" { //// export var V; ////} From be183819269eb691f393b5fc0fbe668602e8e698 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 6 Jul 2015 15:34:44 -0700 Subject: [PATCH 242/250] Removed unnecessary check. --- src/services/services.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 5f2d171448277..d2f9ca8b89083 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3240,15 +3240,13 @@ namespace ts { isMemberCompletion = true; isNewIdentifierLocation = false; - let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); - Debug.assert(importDeclaration !== undefined); + let importDeclaration = importClause.parent; + Debug.assert(importDeclaration !== undefined && importDeclaration.kind === SyntaxKind.ImportDeclaration); let exports: Symbol[]; - if (importDeclaration.moduleSpecifier) { - let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } + let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); } //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); From 93a721cf1d54e701e5b9a0c2972465997f1d9560 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 7 Jul 2015 09:57:58 -0700 Subject: [PATCH 243/250] Bind classExpression and functionExpression to its name if the expression is declared with name --- src/compiler/binder.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e30178e987bb0..5a39e96b11903 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -892,7 +892,8 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); + let bindingName = (node).name ? (node).name.text : "__function"; + return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: return bindClassLikeDeclaration(node); @@ -964,7 +965,8 @@ namespace ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } else { - bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); + let bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); } let symbol = node.symbol; From 92d2d1957d0e6badcad6a6af228dea1df158244a Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 7 Jul 2015 09:58:13 -0700 Subject: [PATCH 244/250] Update tests --- .../reference/classExpressionTest2.types | 6 +++--- .../renameLocationsForClassExpression01.ts | 20 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/baselines/reference/classExpressionTest2.types b/tests/baselines/reference/classExpressionTest2.types index 5586b451d3a55..2ff7d79bc5fa4 100644 --- a/tests/baselines/reference/classExpressionTest2.types +++ b/tests/baselines/reference/classExpressionTest2.types @@ -28,13 +28,13 @@ function M() { } var v = new m(); ->v : ->new m() : +>v : C +>new m() : C >m : typeof C return v.f(); >v.f() : { t: string; x: number; } >v.f : () => { t: T; x: number; } ->v : +>v : C >f : () => { t: T; x: number; } } diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts index a1174d503ede7..e7247f8e4ee3d 100644 --- a/tests/cases/fourslash/renameLocationsForClassExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -3,13 +3,13 @@ ////class Foo { ////} //// -////var x = class /**/Foo { +////var x = class [|Foo|] { //// doIt() { -//// return Foo; +//// return [|Foo|]; //// } //// //// static doItStatically() { -//// return Foo; +//// return [|Foo|]; //// } ////} //// @@ -23,12 +23,10 @@ // TODO (yuit): Fix up this test when class expressions are supported. // Just uncomment the below, remove the marker, and add the // appropriate ranges in the test itself. -goTo.marker(); -verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -////let ranges = test.ranges() -////for (let range of ranges) { -//// goTo.position(range.start); -//// -//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -////} \ No newline at end of file +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file From 1a8200fea7e084757ee7810f062bdb7ddcf030b3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 7 Jul 2015 11:01:34 -0700 Subject: [PATCH 245/250] Add testcase for #3764 --- .../reference/tsxElementResolution19.js | 36 +++++++++++++++++++ .../reference/tsxElementResolution19.symbols | 28 +++++++++++++++ .../reference/tsxElementResolution19.types | 29 +++++++++++++++ .../jsx/tsxElementResolution19.tsx | 21 +++++++++++ 4 files changed, 114 insertions(+) create mode 100644 tests/baselines/reference/tsxElementResolution19.js create mode 100644 tests/baselines/reference/tsxElementResolution19.symbols create mode 100644 tests/baselines/reference/tsxElementResolution19.types create mode 100644 tests/cases/conformance/jsx/tsxElementResolution19.tsx diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js new file mode 100644 index 0000000000000..ebcb66e536f01 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution19.tsx] //// + +//// [react.d.ts] + +declare module "react" { + +} + +//// [file1.tsx] +declare module JSX { + interface Element { } +} +export class MyClass { } + +//// [file2.tsx] + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; + + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + var MyClass = (function () { + function MyClass() { + } + return MyClass; + })(); + exports.MyClass = MyClass; +}); +//// [file2.js] +define(["require", "exports", './file1'], function (require, exports, file1_1) { + React.createElement(file1_1.MyClass, null); +}); diff --git a/tests/baselines/reference/tsxElementResolution19.symbols b/tests/baselines/reference/tsxElementResolution19.symbols new file mode 100644 index 0000000000000..48aa4f962b69a --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(file1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file1.tsx, 0, 20)) +} +export class MyClass { } +>MyClass : Symbol(MyClass, Decl(file1.tsx, 2, 1)) + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : Symbol(React, Decl(file2.tsx, 2, 6)) + +import {MyClass} from './file1'; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + +; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + diff --git a/tests/baselines/reference/tsxElementResolution19.types b/tests/baselines/reference/tsxElementResolution19.types new file mode 100644 index 0000000000000..0fa1eefe5f63c --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} +export class MyClass { } +>MyClass : MyClass + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : typeof React + +import {MyClass} from './file1'; +>MyClass : typeof MyClass + +; +> : any +>MyClass : typeof MyClass + diff --git a/tests/cases/conformance/jsx/tsxElementResolution19.tsx b/tests/cases/conformance/jsx/tsxElementResolution19.tsx new file mode 100644 index 0000000000000..23e503ae962e7 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution19.tsx @@ -0,0 +1,21 @@ +//@jsx: react +//@module: amd + +//@filename: react.d.ts +declare module "react" { + +} + +//@filename: file1.tsx +declare module JSX { + interface Element { } +} +export class MyClass { } + +//@filename: file2.tsx + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; From 1568bfd642cd778c30851d8cf53b33a542020443 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 7 Jul 2015 11:32:57 -0700 Subject: [PATCH 246/250] Mark 'React' symbol as used and error if it doesn't exist --- src/compiler/checker.ts | 10 ++++++++++ tests/baselines/reference/tsxElementResolution19.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3ef2c6ada2a91..7a85a2f08b207 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7299,6 +7299,16 @@ namespace ts { checkGrammarJsxElement(node); checkJsxPreconditions(node); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if(compilerOptions.jsx === JsxEmit.React) { + let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + let targetAttributesType = getJsxElementAttributesType(node); if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js index ebcb66e536f01..72612e8ce54fd 100644 --- a/tests/baselines/reference/tsxElementResolution19.js +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -31,6 +31,6 @@ define(["require", "exports"], function (require, exports) { exports.MyClass = MyClass; }); //// [file2.js] -define(["require", "exports", './file1'], function (require, exports, file1_1) { +define(["require", "exports", 'react', './file1'], function (require, exports, React, file1_1) { React.createElement(file1_1.MyClass, null); }); From 1fa74c56a7eab52139ccfca0b858e9032ba473b7 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 7 Jul 2015 11:37:55 -0700 Subject: [PATCH 247/250] Fix up other React tests --- tests/baselines/reference/tsxReactEmit1.js | 1 + .../baselines/reference/tsxReactEmit1.symbols | 78 ++++++++++--------- tests/baselines/reference/tsxReactEmit1.types | 2 + tests/baselines/reference/tsxReactEmit2.js | 1 + .../baselines/reference/tsxReactEmit2.symbols | 18 +++-- tests/baselines/reference/tsxReactEmit2.types | 2 + tests/baselines/reference/tsxReactEmit3.js | 1 + .../baselines/reference/tsxReactEmit3.symbols | 19 +++-- tests/baselines/reference/tsxReactEmit3.types | 3 + .../reference/tsxReactEmit4.errors.txt | 3 +- tests/baselines/reference/tsxReactEmit4.js | 1 + .../reference/tsxReactEmitWhitespace.js | 1 + .../reference/tsxReactEmitWhitespace.symbols | 4 +- .../reference/tsxReactEmitWhitespace.types | 2 + tests/cases/conformance/jsx/tsxReactEmit1.tsx | 1 + tests/cases/conformance/jsx/tsxReactEmit2.tsx | 1 + tests/cases/conformance/jsx/tsxReactEmit3.tsx | 1 + tests/cases/conformance/jsx/tsxReactEmit4.tsx | 1 + .../jsx/tsxReactEmitWhitespace.tsx | 1 + 19 files changed, 85 insertions(+), 56 deletions(-) diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index b6c5fd96183fc..f1799e5bb77f9 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var selfClosed1 =
; diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index 60fa5e70b0a73..c9e819c82d3e3 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -12,133 +12,135 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmit1.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit1.tsx, 6, 11)) var p; ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var selfClosed1 =
; ->selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 8, 3)) +>selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var selfClosed2 =
; ->selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 9, 3)) +>selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) var selfClosed3 =
; ->selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 10, 3)) +>selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) var selfClosed4 =
; ->selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 11, 3)) +>selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed5 =
; ->selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 12, 3)) +>selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed6 =
; ->selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 13, 3)) +>selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed7 =
; ->selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 14, 3)) +>selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) >b : Symbol(unknown) var openClosed1 =
; ->openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 16, 3)) +>openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 17, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed2 =
foo
; ->openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 17, 3)) +>openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) var openClosed3 =
{p}
; ->openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 18, 3)) +>openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) var openClosed4 =
{p < p}
; ->openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 19, 3)) +>openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 20, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var openClosed5 =
{p > p}
; ->openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 20, 3)) +>openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 21, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) >b : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) class SomeClass { ->SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) f() { ->f : Symbol(f, Decl(tsxReactEmit1.tsx, 22, 17)) +>f : Symbol(f, Decl(tsxReactEmit1.tsx, 23, 17)) var rewrites1 =
{() => this}
; ->rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 24, 5)) +>rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 25, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) var rewrites2 =
{[p, ...p, p]}
; ->rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 25, 5)) +>rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 26, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var rewrites3 =
{{p}}
; ->rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 26, 5)) +>rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 27, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 26, 25)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 27, 25)) var rewrites4 =
this}>
; ->rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 28, 5)) +>rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 29, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) var rewrites5 =
; ->rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 29, 5)) +>rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 30, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var rewrites6 =
; ->rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 30, 5)) +>rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 31, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 30, 27)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 31, 27)) } } var whitespace1 =
; ->whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 34, 3)) +>whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace2 =
{p}
; ->whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 35, 3)) +>whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace3 =
->whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 36, 3)) +>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 37, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) {p} diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index d23cad4560a27..0b6e03c57428e 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any var p; >p : any diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js index f4a12946ed98f..4b2b46955617d 100644 --- a/tests/baselines/reference/tsxReactEmit2.js +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p1, p2, p3; var spreads1 =
{p2}
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 9607d9330da48..9cf739c960cb6 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -12,32 +12,34 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmit2.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit2.tsx, 6, 11)) var p1, p2, p3; ->p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 7, 7)) ->p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 7, 11)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) var spreads1 =
{p2}
; ->spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 8, 3)) +>spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; ->spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 9, 3)) +>spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; ->spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 10, 3)) +>spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) var spreads4 =
{p2}
; ->spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 11, 3)) +>spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) var spreads5 =
{p2}
; ->spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 12, 3)) +>spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types index 9f8d6e494d0dd..e28910b62c7b1 100644 --- a/tests/baselines/reference/tsxReactEmit2.types +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any var p1, p2, p3; >p1 : any diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index d31fec1c55035..1a6ba03723041 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -1,6 +1,7 @@ //// [tsxReactEmit3.tsx] declare module JSX { interface Element { } } +declare var React: any; declare var Foo, Bar, baz; diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols index 8ef0ccab2419a..857647400a9ec 100644 --- a/tests/baselines/reference/tsxReactEmit3.symbols +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -4,15 +4,18 @@ declare module JSX { interface Element { } } >JSX : Symbol(JSX, Decl(tsxReactEmit3.tsx, 0, 0)) >Element : Symbol(Element, Decl(tsxReactEmit3.tsx, 1, 20)) +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit3.tsx, 2, 11)) + declare var Foo, Bar, baz; ->Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 3, 21)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 4, 21)) q s ; ->Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) diff --git a/tests/baselines/reference/tsxReactEmit3.types b/tests/baselines/reference/tsxReactEmit3.types index 9e5d9fece5642..8babe724fa17a 100644 --- a/tests/baselines/reference/tsxReactEmit3.types +++ b/tests/baselines/reference/tsxReactEmit3.types @@ -4,6 +4,9 @@ declare module JSX { interface Element { } } >JSX : any >Element : Element +declare var React: any; +>React : any + declare var Foo, Bar, baz; >Foo : any >Bar : any diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt index 00b7cb8d019ec..fca2b02823746 100644 --- a/tests/baselines/reference/tsxReactEmit4.errors.txt +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find name 'blah'. +tests/cases/conformance/jsx/tsxReactEmit4.tsx(12,5): error TS2304: Cannot find name 'blah'. ==== tests/cases/conformance/jsx/tsxReactEmit4.tsx (1 errors) ==== @@ -8,6 +8,7 @@ tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find n [s: string]: any; } } + declare var React: any; var p; var openClosed1 =
diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js index 2254c4dd651c4..dcbfafcef2f2b 100644 --- a/tests/baselines/reference/tsxReactEmit4.js +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var openClosed1 =
diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index 2f32295c279fa..a124ce73312fb 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index afbb694498197..06c8258a2c2ea 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -12,12 +12,14 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmitWhitespace.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace.tsx, 6, 11)) // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; ->p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 10, 3)) +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) // Emit " "
; diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index e0e3639fa9b20..603dc4ca6c10f 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx index b8f14b0ba229c..15ece4153a85f 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit1.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var selfClosed1 =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit2.tsx b/tests/cases/conformance/jsx/tsxReactEmit2.tsx index 39a78a7da8791..96ab8c6046b27 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit2.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit2.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p1, p2, p3; var spreads1 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit3.tsx b/tests/cases/conformance/jsx/tsxReactEmit3.tsx index eb63be44f3b7a..12adcd3c2b6ff 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit3.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit3.tsx @@ -2,6 +2,7 @@ //@filename: test.tsx declare module JSX { interface Element { } } +declare var React: any; declare var Foo, Bar, baz; diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx index f007c35c24a9c..a032a5a3985d1 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit4.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var openClosed1 =
diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 38c966fa70026..34fd158eab196 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT From d353d624346d9372bf74792acacdf5d8cffb7f71 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 7 Jul 2015 12:48:17 -0700 Subject: [PATCH 248/250] Addressed CR feedback. --- src/services/services.ts | 15 +++++++++++++++ .../fourslash/completionListInImportClause01.ts | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 4149a7e786ccf..28c0b0ce2399a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3204,6 +3204,12 @@ namespace ts { return false; } + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | BindingPattern): boolean { // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; @@ -3242,6 +3248,15 @@ namespace ts { return true; } + /** + * Aggregates relevant symbols for completion in import clauses; for instance, + * + * import { $ } from "moduleName"; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean { // cursor is in import clause // try to show exported member for imported module diff --git a/tests/cases/fourslash/completionListInImportClause01.ts b/tests/cases/fourslash/completionListInImportClause01.ts index cf053868dd636..1191216baf168 100644 --- a/tests/cases/fourslash/completionListInImportClause01.ts +++ b/tests/cases/fourslash/completionListInImportClause01.ts @@ -14,8 +14,8 @@ function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { goTo.marker(marker); if (completions.length) { - for (let i = 0; i < completions.length; ++i) { - verify.completionListContains(completions[i]); + for (let completion of completions) { + verify.completionListContains(completion); } } else { From 006356d2a3c010fa304be3e3d5b8c1c4c72ead3b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 7 Jul 2015 12:53:53 -0700 Subject: [PATCH 249/250] Whitespace --- 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 7a85a2f08b207..6b59bd2df2ba5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7302,7 +7302,7 @@ namespace ts { // If we're compiling under --jsx react, the symbol 'React' should // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. - if(compilerOptions.jsx === JsxEmit.React) { + if (compilerOptions.jsx === JsxEmit.React) { let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React'); if (reactSym) { getSymbolLinks(reactSym).referenced = true; From 363dc03d8ee2ca670ca6047bafe9377726e34fb8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 7 Jul 2015 12:54:20 -0700 Subject: [PATCH 250/250] Delete some files that shouldn't have existed --- .../jsx/tsxAttributeResolution1.jsx | 15 ------- .../jsx/tsxAttributeResolution2.jsx | 5 --- .../jsx/tsxAttributeResolution3.jsx | 21 ---------- .../jsx/tsxAttributeResolution4.jsx | 4 -- .../jsx/tsxAttributeResolution5.jsx | 11 ----- .../conformance/jsx/tsxElementResolution1.jsx | 4 -- .../jsx/tsxElementResolution11.jsx | 6 --- .../jsx/tsxElementResolution12.jsx | 9 ---- .../jsx/tsxElementResolution13.jsx | 2 - .../jsx/tsxElementResolution14.jsx | 2 - .../jsx/tsxElementResolution15.jsx | 2 - .../jsx/tsxElementResolution16.jsx | 2 - .../conformance/jsx/tsxElementResolution7.jsx | 14 ------- .../conformance/jsx/tsxElementResolution8.jsx | 15 ------- .../conformance/jsx/tsxElementResolution9.jsx | 6 --- tests/cases/conformance/jsx/tsxEmit1.jsx | 34 --------------- tests/cases/conformance/jsx/tsxEmit3.jsx | 41 ------------------- 17 files changed, 193 deletions(-) delete mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution1.jsx delete mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution2.jsx delete mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution3.jsx delete mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution4.jsx delete mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution5.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution1.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution11.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution12.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution13.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution14.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution15.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution16.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution7.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution8.jsx delete mode 100644 tests/cases/conformance/jsx/tsxElementResolution9.jsx delete mode 100644 tests/cases/conformance/jsx/tsxEmit1.jsx delete mode 100644 tests/cases/conformance/jsx/tsxEmit3.jsx diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx deleted file mode 100644 index fb54f9d7c82b3..0000000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// OK -; // OK -; // OK -; // OK -; // OK -; // OK -// Errors -; // Error, '0' is not number -; // Error, no property "y" -; // Error, no property "y" -; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property -; // Error, missing reqd -; // Error, reqd is not string diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx deleted file mode 100644 index 7c47046dcdeb5..0000000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx +++ /dev/null @@ -1,5 +0,0 @@ -// OK -; // OK -; // OK -// Errors -; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx deleted file mode 100644 index 46cb5d8ff6980..0000000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx +++ /dev/null @@ -1,21 +0,0 @@ -// OK -var obj1 = { x: 'foo' }; -; -// Error, x is not string -var obj2 = { x: 32 }; -; -// Error, x is missing -var obj3 = { y: 32 }; -; -// OK -var obj4 = { x: 32, y: 32 }; -; -// Error -var obj5 = { x: 32, y: 32 }; -; -// OK -var obj6 = { x: 'ok', y: 32, extra: 100 }; -; -// Error -var obj7 = { x: 'foo' }; -; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx deleted file mode 100644 index da2e1d12038c2..0000000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx +++ /dev/null @@ -1,4 +0,0 @@ -// OK -; -// Error, no member 'len' on 'string' -; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx deleted file mode 100644 index 3e4c89d06fb8a..0000000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx +++ /dev/null @@ -1,11 +0,0 @@ -function make1(obj) { - return ; // OK -} -function make2(obj) { - return ; // Error (x is number, not string) -} -function make3(obj) { - return ; // Error, missing x -} -; // Error, missing x -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.jsx b/tests/cases/conformance/jsx/tsxElementResolution1.jsx deleted file mode 100644 index 97357dbba8e74..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution1.jsx +++ /dev/null @@ -1,4 +0,0 @@ -// OK -
; -// Fail -; diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.jsx b/tests/cases/conformance/jsx/tsxElementResolution11.jsx deleted file mode 100644 index 6349906508c23..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution11.jsx +++ /dev/null @@ -1,6 +0,0 @@ -var Obj1; -; // OK -var Obj2; -; // Error -var Obj3; -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.jsx b/tests/cases/conformance/jsx/tsxElementResolution12.jsx deleted file mode 100644 index ef137fd0e2960..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution12.jsx +++ /dev/null @@ -1,9 +0,0 @@ -var obj1; -; // OK -var obj2; -; // OK -var obj3; -; // Error -var obj4; -; // OK -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.jsx b/tests/cases/conformance/jsx/tsxElementResolution13.jsx deleted file mode 100644 index 6a55efa612d9f..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution13.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.jsx b/tests/cases/conformance/jsx/tsxElementResolution14.jsx deleted file mode 100644 index 29df7710af1fe..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution14.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.jsx b/tests/cases/conformance/jsx/tsxElementResolution15.jsx deleted file mode 100644 index 6a55efa612d9f..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution15.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.jsx b/tests/cases/conformance/jsx/tsxElementResolution16.jsx deleted file mode 100644 index e1987489bbb44..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution16.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error (JSX.Element is missing) diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.jsx b/tests/cases/conformance/jsx/tsxElementResolution7.jsx deleted file mode 100644 index e95505539abba..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution7.jsx +++ /dev/null @@ -1,14 +0,0 @@ -var my; -(function (my) { -})(my || (my = {})); -// OK -; -// Error -; -var q; -(function (q) { - // OK - ; - // Error - ; -})(q || (q = {})); diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.jsx b/tests/cases/conformance/jsx/tsxElementResolution8.jsx deleted file mode 100644 index e0f95dc6d2227..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution8.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// Error -var div = 3; -
; -// OK -function fact() { return null; } -; -// Error -function fnum() { return 42; } -; -var obj1; -; // OK, prefer construct signatures -var obj2; -; // Error -var obj3; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.jsx b/tests/cases/conformance/jsx/tsxElementResolution9.jsx deleted file mode 100644 index 2b62d86eac5f9..0000000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution9.jsx +++ /dev/null @@ -1,6 +0,0 @@ -var obj1; -; // Error, return type is not an object type -var obj2; -; // Error, return type is not an object type -var obj3; -; // OK diff --git a/tests/cases/conformance/jsx/tsxEmit1.jsx b/tests/cases/conformance/jsx/tsxEmit1.jsx deleted file mode 100644 index 45ca6e2469f38..0000000000000 --- a/tests/cases/conformance/jsx/tsxEmit1.jsx +++ /dev/null @@ -1,34 +0,0 @@ -var p; -/* -var selfClosed1 =
; -var selfClosed2 =
; -var selfClosed3 =
; -var selfClosed4 =
; -var selfClosed5 =
; -var selfClosed6 =
; -var selfClosed7 =
; - -var openClosed1 =
; -var openClosed2 =
foo
; -var openClosed3 =
{p}
; -var openClosed4 =
{p < p}
; -var openClosed5 =
{p > p}
; -*/ -var SomeClass = (function () { - function SomeClass() { - } - SomeClass.prototype.f = function () { - var _this = this; - var rewrites1 =
{function () { return _this; }}
; - var rewrites4 =
; - }; - return SomeClass; -})(); -/* -var q = () => this; -var rewrites2 =
{[p, ...p, p]}
; -var rewrites3 =
{{p}}
; - -var rewrites5 =
; -var rewrites6 =
; -*/ diff --git a/tests/cases/conformance/jsx/tsxEmit3.jsx b/tests/cases/conformance/jsx/tsxEmit3.jsx deleted file mode 100644 index 7c979051d00b3..0000000000000 --- a/tests/cases/conformance/jsx/tsxEmit3.jsx +++ /dev/null @@ -1,41 +0,0 @@ -var M; -(function (M) { - var Foo = (function () { - function Foo() { - } - return Foo; - })(); - M.Foo = Foo; - var S; - (function (S) { - var Bar = (function () { - function Bar() { - } - return Bar; - })(); - S.Bar = Bar; - })(S = M.S || (M.S = {})); -})(M || (M = {})); -var M; -(function (M) { - // Emit M.Foo - M.Foo, ; - var S; - (function (S) { - // Emit M.Foo - M.Foo, ; - // Emit S.Bar - S.Bar, ; - })(S = M.S || (M.S = {})); -})(M || (M = {})); -var M; -(function (M) { - // Emit M.S.Bar - M.S.Bar, ; -})(M || (M = {})); -var M; -(function (M_1) { - var M = 100; - // Emit M_1.Foo - M_1.Foo, ; -})(M || (M = {}));