diff --git a/.gitignore b/.gitignore index a05a65c95c1..21d79becb15 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ tests/*.d.ts scripts/debug.bat scripts/run.bat scripts/word2md.js +scripts/ior.js coverage/ diff --git a/Jakefile b/Jakefile index da91239d7a5..1709e1f7628 100644 --- a/Jakefile +++ b/Jakefile @@ -279,7 +279,6 @@ var word2mdJs = path.join(scriptsDirectory, "word2md.js"); var word2mdTs = path.join(scriptsDirectory, "word2md.ts"); var specWord = path.join(docDirectory, "TypeScript Language Specification.docx"); var specMd = path.join(docDirectory, "spec.md"); -var headerMd = path.join(docDirectory, "header.md"); file(word2mdTs); @@ -292,9 +291,8 @@ compileFile(word2mdJs, // The generated spec.md; built for the 'generate-spec' task file(specMd, [word2mdJs, specWord], function () { - jake.cpR(headerMd, specMd, {silent: true}); var specWordFullPath = path.resolve(specWord); - var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" >>' + specMd; + var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd; console.log(cmd); child_process.exec(cmd, function () { complete(); diff --git a/doc/TypeScript Language Specification (Change Markup).docx b/doc/TypeScript Language Specification (Change Markup).docx index aa9f495d04e..bb4be4fac1c 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).docx and b/doc/TypeScript Language Specification (Change Markup).docx differ diff --git a/doc/TypeScript Language Specification (Change Markup).pdf b/doc/TypeScript Language Specification (Change Markup).pdf index 6292c8f091a..0cffd20b7c7 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).pdf and b/doc/TypeScript Language Specification (Change Markup).pdf differ diff --git a/doc/TypeScript Language Specification.docx b/doc/TypeScript Language Specification.docx index 18ce8396a5b..3d2014252f2 100644 Binary files a/doc/TypeScript Language Specification.docx and b/doc/TypeScript Language Specification.docx differ diff --git a/doc/TypeScript Language Specification.pdf b/doc/TypeScript Language Specification.pdf index 4d483ed4e55..203269c3f24 100644 Binary files a/doc/TypeScript Language Specification.pdf and b/doc/TypeScript Language Specification.pdf differ diff --git a/doc/header.md b/doc/header.md deleted file mode 100644 index 3cf5b569800..00000000000 --- a/doc/header.md +++ /dev/null @@ -1,2 +0,0 @@ -# TypeScript Language Specification - diff --git a/doc/spec.md b/doc/spec.md index 0a802bd8685..158c431c229 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -6,7 +6,7 @@ October, 2014
-Microsoft is making this Specification available under the Open Web Foundation Final Specification Agreement Version 1.0 (“OWF 1.0”) as of October 1, 2012. The OWF 1.0 is available at http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0. +Microsoft is making this Specification available under the Open Web Foundation Final Specification Agreement Version 1.0 ("OWF 1.0") as of October 1, 2012. The OWF 1.0 is available at http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0. TypeScript is a trademark of Microsoft Corporation. @@ -103,13 +103,13 @@ TypeScript is a trademark of Microsoft Corporation. * [4.13 Type Assertions](#4.13) * [4.14 Unary Operators](#4.14) * [4.14.1 The ++ and -- operators](#4.14.1) - * [4.14.2 The +, –, and ~ operators](#4.14.2) + * [4.14.2 The +, –, and ~ operators](#4.14.2) * [4.14.3 The ! operator](#4.14.3) * [4.14.4 The delete Operator](#4.14.4) * [4.14.5 The void Operator](#4.14.5) * [4.14.6 The typeof Operator](#4.14.6) * [4.15 Binary Operators](#4.15) - * [4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators](#4.15.1) + * [4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators](#4.15.1) * [4.15.2 The + operator](#4.15.2) * [4.15.3 The <, >, <=, >=, ==, !=, ===, and !== operators](#4.15.3) * [4.15.4 The instanceof operator](#4.15.4) @@ -212,7 +212,7 @@ TypeScript is a trademark of Microsoft Corporation. # 1 Introduction -JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript’s optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring. +JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring. TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of Ecmascript 5 (ES5) syntax. Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development. @@ -220,7 +220,7 @@ TypeScript syntax includes several proposed features of Ecmascript 6 (ES6), incl TypeScript also provides to JavaScript programmers a system of optional type annotations. These type annotations are like the JSDoc comments found in the Closure system, but in TypeScript they are integrated directly into the language syntax. This integration makes the code more readable and reduces the maintenance cost of synchronizing type annotations with their corresponding variables. -The TypeScript type system enables programmers to express limits on the capabilities of JavaScript objects, and to use tools that enforce these limits. To minimize the number of annotations needed for tools to become useful, the TypeScript type system makes extensive use of type inference. For example, from the following statement, TypeScript will infer that the variable ‘i’ has the type number. +The TypeScript type system enables programmers to express limits on the capabilities of JavaScript objects, and to use tools that enforce these limits. To minimize the number of annotations needed for tools to become useful, the TypeScript type system makes extensive use of type inference. For example, from the following statement, TypeScript will infer that the variable 'i' has the type number. ```TypeScript var i = 0; @@ -249,7 +249,7 @@ f({}); // Error f("hello"); // Ok ``` -This optional type annotation on the parameter ‘s’ lets the TypeScript type checker know that the programmer expects parameter ‘s’ to be of type ‘string’. Within the body of function ‘f’, tools can assume ‘s’ is of type ‘string’ and provide operator type checking and member completion consistent with this assumption. Tools can also signal an error on the first call to ‘f’, because ‘f’ expects a string, not an object, as its parameter. For the function ‘f’, the TypeScript compiler will emit the following JavaScript code: +This optional type annotation on the parameter 's' lets the TypeScript type checker know that the programmer expects parameter 's' to be of type 'string'. Within the body of function 'f', tools can assume 's' is of type 'string' and provide operator type checking and member completion consistent with this assumption. Tools can also signal an error on the first call to 'f', because 'f' expects a string, not an object, as its parameter. For the function 'f', the TypeScript compiler will emit the following JavaScript code: ```TypeScript function f(s) { @@ -261,14 +261,14 @@ In the JavaScript output, all type annotations have been erased. In general, Typ ## 1.1 Ambient Declarations -An ambient declaration introduces a variable into a TypeScript scope, but has zero impact on the emitted JavaScript program. Programmers can use ambient declarations to tell the TypeScript compiler that some other component will supply a variable. For example, by default the TypeScript compiler will print an error for uses of undefined variables. To add some of the common variables defined by browsers, a TypeScript programmer can use ambient declarations. The following example declares the ‘document’ object supplied by browsers. Because the declaration does not specify a type, the type ‘any’ is inferred. The type ‘any’ means that a tool can assume nothing about the shape or behavior of the document object. Some of the examples below will illustrate how programmers can use types to further characterize the expected behavior of an object. +An ambient declaration introduces a variable into a TypeScript scope, but has zero impact on the emitted JavaScript program. Programmers can use ambient declarations to tell the TypeScript compiler that some other component will supply a variable. For example, by default the TypeScript compiler will print an error for uses of undefined variables. To add some of the common variables defined by browsers, a TypeScript programmer can use ambient declarations. The following example declares the 'document' object supplied by browsers. Because the declaration does not specify a type, the type 'any' is inferred. The type 'any' means that a tool can assume nothing about the shape or behavior of the document object. Some of the examples below will illustrate how programmers can use types to further characterize the expected behavior of an object. ```TypeScript declare var document; document.title = "Hello"; // Ok because document has been declared ``` -In the case of ‘document’, the TypeScript compiler automatically supplies a declaration, because TypeScript by default includes a file ‘lib.d.ts’ that provides interface declarations for the built-in JavaScript library as well as the Document Object Model. +In the case of 'document', the TypeScript compiler automatically supplies a declaration, because TypeScript by default includes a file 'lib.d.ts' that provides interface declarations for the built-in JavaScript library as well as the Document Object Model. The TypeScript compiler does not include by default an interface for jQuery, so to use jQuery, a programmer could supply a declaration such as: @@ -280,7 +280,7 @@ Section [1.3](#1.3) provides a more extensive example of how a programmer can ad ## 1.2 Function Types -Function expressions are a powerful feature of JavaScript. They enable function definitions to create closures: functions that capture information from the lexical scope surrounding the function’s definition. Closures are currently JavaScript’s only way of enforcing data encapsulation. By capturing and using environment variables, a closure can retain information that cannot be accessed from outside the closure. JavaScript programmers often use closures to express event handlers and other asynchronous callbacks, in which another software component, such as the DOM, will call back into JavaScript through a handler function. +Function expressions are a powerful feature of JavaScript. They enable function definitions to create closures: functions that capture information from the lexical scope surrounding the function's definition. Closures are currently JavaScript's only way of enforcing data encapsulation. By capturing and using environment variables, a closure can retain information that cannot be accessed from outside the closure. JavaScript programmers often use closures to express event handlers and other asynchronous callbacks, in which another software component, such as the DOM, will call back into JavaScript through a handler function. TypeScript function types make it possible for programmers to express the expected *signature* of a function. A function signature is a sequence of parameter types plus a return type. The following example uses function types to express the callback signature requirements of an asynchronous voting mechanism. @@ -298,19 +298,19 @@ vote("BigPig", ); ``` -In this example, the second parameter to ‘vote’ has the function type +In this example, the second parameter to 'vote' has the function type ```TypeScript (result: string) => any ``` -which means the second parameter is a function returning type ‘any’ that has a single parameter of type ‘string’ named ‘result’. +which means the second parameter is a function returning type 'any' that has a single parameter of type 'string' named 'result'. Section [3.7.2](#3.7.2) provides additional information about function types. ## 1.3 Object Types -TypeScript programmers use *object types* to declare their expectations of object behavior. The following code uses an *object type literal* to specify the return type of the ‘MakePoint’ function. +TypeScript programmers use *object types* to declare their expectations of object behavior. The following code uses an *object type literal* to specify the return type of the 'MakePoint' function. ```TypeScript var MakePoint: () => { @@ -335,7 +335,7 @@ add({ favoriteColor: "blue" }); // Error, name required add({ name: "Jill", favoriteColor: "green" }); // Ok ``` -TypeScript object types model the diversity of behaviors that a JavaScript object can exhibit. For example, the jQuery library defines an object, ‘$’, that has methods, such as ‘get’ (which sends an Ajax message), and fields, such as ‘browser’ (which gives browser vendor information). However, jQuery clients can also call ‘$’ as a function. The behavior of this function depends on the type of parameters passed to the function. +TypeScript object types model the diversity of behaviors that a JavaScript object can exhibit. For example, the jQuery library defines an object, '$', that has methods, such as 'get' (which sends an Ajax message), and fields, such as 'browser' (which gives browser vendor information). However, jQuery clients can also call '$' as a function. The behavior of this function depends on the type of parameters passed to the function. The following code fragment captures a small subset of jQuery behavior, just enough to use jQuery in a simple way. @@ -358,9 +358,9 @@ $.get("http://mysite.org/divContent", ); ``` -The ‘JQueryStatic’ interface references another interface: ‘JQuery’. This interface represents a collection of one or more DOM elements. The jQuery library can perform many operations on such a collection, but in this example the jQuery client only needs to know that it can set the text content of each jQuery element in a collection by passing a string to the ‘text’ method. The ‘JQueryStatic’ interface also contains a method, ‘get’, that performs an Ajax get operation on the provided URL and arranges to invoke the provided callback upon receipt of a response. +The 'JQueryStatic' interface references another interface: 'JQuery'. This interface represents a collection of one or more DOM elements. The jQuery library can perform many operations on such a collection, but in this example the jQuery client only needs to know that it can set the text content of each jQuery element in a collection by passing a string to the 'text' method. The 'JQueryStatic' interface also contains a method, 'get', that performs an Ajax get operation on the provided URL and arranges to invoke the provided callback upon receipt of a response. -Finally, the ‘JQueryStatic’ interface contains a bare function signature +Finally, the 'JQueryStatic' interface contains a bare function signature ```TypeScript (query: string): JQuery; @@ -374,13 +374,13 @@ var sameType: () => string = f; // Ok var nope: () => number = sameType; // Error: type mismatch ``` -We mentioned above that the ‘$’ function behaves differently depending on the type of its parameter. So far, our jQuery typing only captures one of these behaviors: return an object of type ‘JQuery’ when passed a string. To specify multiple behaviors, TypeScript supports *overloading* of function signatures in object types. For example, we can add an additional call signature to the ‘JQueryStatic’ interface. +We mentioned above that the '$' function behaves differently depending on the type of its parameter. So far, our jQuery typing only captures one of these behaviors: return an object of type 'JQuery' when passed a string. To specify multiple behaviors, TypeScript supports *overloading* of function signatures in object types. For example, we can add an additional call signature to the 'JQueryStatic' interface. ```TypeScript (ready: () => any): any; ``` -This signature denotes that a function may be passed as the parameter of the ‘$’ function. When a function is passed to ‘$’, the jQuery library will invoke that function when a DOM document is ready. Because TypeScript supports overloading, tools can use TypeScript to show all available function signatures with their documentation tips and to give the correct documentation once a function has been called with a particular signature. +This signature denotes that a function may be passed as the parameter of the '$' function. When a function is passed to '$', the jQuery library will invoke that function when a DOM document is ready. Because TypeScript supports overloading, tools can use TypeScript to show all available function signatures with their documentation tips and to give the correct documentation once a function has been called with a particular signature. A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot. @@ -390,7 +390,7 @@ Section [3.3](#3.3) provides additional information about object types. ## 1.4 Structural Subtyping -Object types are compared *structurally*. For example, in the code fragment below, class ‘CPoint’ matches interface ‘Point’ because ‘CPoint’ has all of the required members of ‘Point’. A class may optionally declare that it implements an interface, so that the compiler will check the declaration for structural compatibility. The example also illustrates that an object type can match the type inferred from an object literal, as long as the object literal supplies all of the required members. +Object types are compared *structurally*. For example, in the code fragment below, class 'CPoint' matches interface 'Point' because 'CPoint' has all of the required members of 'Point'. A class may optionally declare that it implements an interface, so that the compiler will check the declaration for structural compatibility. The example also illustrates that an object type can match the type inferred from an object literal, as long as the object literal supplies all of the required members. ```TypeScript interface Point { @@ -422,7 +422,7 @@ See section [3.8](#3.8) for more information about type comparisons. ## 1.5 Contextual Typing -Ordinarily, TypeScript type inference proceeds “bottom-up”: from the leaves of an expression tree to its root. In the following example, TypeScript infers ‘number’ as the return type of the function ‘mul’ by flowing type information bottom up in the return expression. +Ordinarily, TypeScript type inference proceeds "bottom-up": from the leaves of an expression tree to its root. In the following example, TypeScript infers 'number' as the return type of the function 'mul' by flowing type information bottom up in the return expression. ```TypeScript function mul(a: number, b: number) { @@ -430,9 +430,9 @@ function mul(a: number, b: number) { } ``` -For variables and parameters without a type annotation or a default value, TypeScript infers type ‘any’, ensuring that compilers do not need non-local information about a function’s call sites to infer the function’s return type. Generally, this bottom-up approach provides programmers with a clear intuition about the flow of type information. +For variables and parameters without a type annotation or a default value, TypeScript infers type 'any', ensuring that compilers do not need non-local information about a function's call sites to infer the function's return type. Generally, this bottom-up approach provides programmers with a clear intuition about the flow of type information. -However, in some limited contexts, inference proceeds “top-down” from the context of an expression. Where this happens, it is called contextual typing. Contextual typing helps tools provide excellent information when a programmer is using a type but may not know all of the details of the type. For example, in the jQuery example, above, the programmer supplies a function expression as the second parameter to the ‘get’ method. During typing of that expression, tools can assume that the type of the function expression is as given in the ‘get’ signature and can provide a template that includes parameter names and types. +However, in some limited contexts, inference proceeds "top-down" from the context of an expression. Where this happens, it is called contextual typing. Contextual typing helps tools provide excellent information when a programmer is using a type but may not know all of the details of the type. For example, in the jQuery example, above, the programmer supplies a function expression as the second parameter to the 'get' method. During typing of that expression, tools can assume that the type of the function expression is as given in the 'get' signature and can provide a template that includes parameter names and types. ```TypeScript $.get("http://mysite.org/divContent", @@ -448,9 +448,9 @@ Section [4.19](#4.19) provides additional information about contextually typed e ## 1.6 Classes -JavaScript practice has at least two common design patterns: the module pattern and the class pattern. Roughly speaking, the module pattern uses closures to hide names and to encapsulate private data, while the class pattern uses prototype chains to implement many variations on object-oriented inheritance mechanisms. Libraries such as ‘prototype.js’ are typical of this practice. +JavaScript practice has at least two common design patterns: the module pattern and the class pattern. Roughly speaking, the module pattern uses closures to hide names and to encapsulate private data, while the class pattern uses prototype chains to implement many variations on object-oriented inheritance mechanisms. Libraries such as 'prototype.js' are typical of this practice. -This section and the module section below will show how TypeScript emits consistent, idiomatic JavaScript code to implement classes and modules that are closely aligned with the current ES6 proposal. The goal of TypeScript’s translation is to emit exactly what a programmer would type when implementing a class or module unaided by a tool. This section will also describe how TypeScript infers a type for each class declaration. We’ll start with a simple BankAccount class. +This section and the module section below will show how TypeScript emits consistent, idiomatic JavaScript code to implement classes and modules that are closely aligned with the current ES6 proposal. The goal of TypeScript's translation is to emit exactly what a programmer would type when implementing a class or module unaided by a tool. This section will also describe how TypeScript infers a type for each class declaration. We'll start with a simple BankAccount class. ```TypeScript class BankAccount { @@ -477,7 +477,7 @@ var BankAccount = (function () { })(); ``` -This TypeScript class declaration creates a variable named ‘BankAccount’ whose value is the constructor function for ‘BankAccount’ instances. This declaration also creates an instance type of the same name. If we were to write this type as an interface it would look like the following. +This TypeScript class declaration creates a variable named 'BankAccount' whose value is the constructor function for 'BankAccount' instances. This declaration also creates an instance type of the same name. If we were to write this type as an interface it would look like the following. ```TypeScript interface BankAccount { @@ -486,15 +486,15 @@ interface BankAccount { } ``` -If we were to write out the function type declaration for the ‘BankAccount’ constructor variable, it would have the following form. +If we were to write out the function type declaration for the 'BankAccount' constructor variable, it would have the following form. ```TypeScript var BankAccount: new() => BankAccount; ``` -The function signature is prefixed with the keyword ‘new’ indicating that the ‘BankAccount’ function must be called as a constructor. It is possible for a function’s type to have both call and constructor signatures. For example, the type of the built-in JavaScript Date object includes both kinds of signatures. +The function signature is prefixed with the keyword 'new' indicating that the 'BankAccount' function must be called as a constructor. It is possible for a function's type to have both call and constructor signatures. For example, the type of the built-in JavaScript Date object includes both kinds of signatures. -If we want to start our bank account with an initial balance, we can add to the ‘BankAccount’ class a constructor declaration. +If we want to start our bank account with an initial balance, we can add to the 'BankAccount' class a constructor declaration. ```TypeScript class BankAccount { @@ -509,7 +509,7 @@ class BankAccount { } ``` -This version of the ‘BankAccount’ class requires us to introduce a constructor parameter and then assign it to the ‘balance’ field. To simplify this common case, TypeScript accepts the following shorthand syntax. +This version of the 'BankAccount' class requires us to introduce a constructor parameter and then assign it to the 'balance' field. To simplify this common case, TypeScript accepts the following shorthand syntax. ```TypeScript class BankAccount { @@ -522,7 +522,7 @@ class BankAccount { } ``` -The ‘public’ keyword denotes that the constructor parameter is to be retained as a field. Public is the default accessibility for class members, but a programmer can also specify private or protected accessibility for a class member. Accessibility is a design-time construct; it is enforced during static type checking but does not imply any runtime enforcement. +The 'public' keyword denotes that the constructor parameter is to be retained as a field. Public is the default accessibility for class members, but a programmer can also specify private or protected accessibility for a class member. Accessibility is a design-time construct; it is enforced during static type checking but does not imply any runtime enforcement. TypeScript classes also support inheritance, as in the following example.* * @@ -537,7 +537,7 @@ class CheckingAccount extends BankAccount { } ``` -In this example, the class ‘CheckingAccount’ *derives* from class ‘BankAccount’. The constructor for ‘CheckingAccount’ calls the constructor for class ‘BankAccount’ using the ‘super’ keyword. In the emitted JavaScript code, the prototype of ‘CheckingAccount’ will chain to the prototype of ‘BankingAccount’. +In this example, the class 'CheckingAccount' *derives* from class 'BankAccount'. The constructor for 'CheckingAccount' calls the constructor for class 'BankAccount' using the 'super' keyword. In the emitted JavaScript code, the prototype of 'CheckingAccount' will chain to the prototype of 'BankingAccount'. TypeScript classes may also specify static members. Static class members become properties of the class constructor. @@ -561,11 +561,11 @@ function compute(op: Operator, a: number, b: number) { } ``` -In this example, the compute function logs the operator ‘op’ using a feature of enum types: reverse mapping from the enum value (‘op’) to the string corresponding to that value. For example, the declaration of ‘Operator’ automatically assigns integers, starting from zero, to the listed enum members. Section [9](#9) describes how programmers can also explicitly assign integers to enum members, and can use any string to name an enum member. +In this example, the compute function logs the operator 'op' using a feature of enum types: reverse mapping from the enum value ('op') to the string corresponding to that value. For example, the declaration of 'Operator' automatically assigns integers, starting from zero, to the listed enum members. Section [9](#9) describes how programmers can also explicitly assign integers to enum members, and can use any string to name an enum member. -If all enum members have explicitly assigned literal integers, or if an enum has all members automatically assigned, the TypeScript compiler will emit for an enum member a JavaScript constant corresponding to that member’s assigned value (annotated with a comment). This improves performance on many JavaScript engines. +If all enum members have explicitly assigned literal integers, or if an enum has all members automatically assigned, the TypeScript compiler will emit for an enum member a JavaScript constant corresponding to that member's assigned value (annotated with a comment). This improves performance on many JavaScript engines. -For example, the ‘compute’ function could contain a switch statement like the following. +For example, the 'compute' function could contain a switch statement like the following. ```TypeScript switch (op) { @@ -599,18 +599,18 @@ JavaScript implementations can use these explicit constants to generate efficien An important goal of TypeScript is to provide accurate and straightforward types for existing JavaScript programming patterns. To that end, TypeScript includes generic types, discussed in the next section, and *overloading on string parameters*, the topic of this section. -JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the ‘createElement’ method of the ‘document’ object has multiple signatures, some of which identify the types returned when specific strings are passed into the method. +JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method. / -The following code fragment uses this feature. Because the ‘span’ variable is inferred to have the type ‘HTMLSpanElement’, the code can reference without static error the ‘isMultiline’ property of ‘span’. +The following code fragment uses this feature. Because the 'span' variable is inferred to have the type 'HTMLSpanElement', the code can reference without static error the 'isMultiline' property of 'span'. ```TypeScript var span = document.createElement("span"); span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property ``` -In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable ‘e’ is ‘MouseEvent’ and that therefore ‘e’ has a ‘clientX’ property. +In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property. / @@ -620,7 +620,7 @@ Section [3.7.2.4](#3.7.2.4) provides details on how to use string literals in fu Like overloading on string parameters, *generic types* make it easier for TypeScript to accurately capture the behavior of JavaScript libraries. Because they enable type information to flow from client code, through library code, and back into client code, generic types may do more than any other TypeScript feature to support detailed API descriptions. -To illustrate this, let’s take a look at part of the TypeScript interface for the built-in JavaScript array type. You can find this interface in the ‘lib.d.ts’ file that accompanies a TypeScript distribution. +To illustrate this, let's take a look at part of the TypeScript interface for the built-in JavaScript array type. You can find this interface in the 'lib.d.ts' file that accompanies a TypeScript distribution. ```TypeScript interface Array { @@ -630,17 +630,17 @@ interface Array { } ``` -Interface definitions, like the one above, can have one or more *type parameters*. In this case the ‘Array’ interface has a single parameter, ‘T’, that defines the element type for the array. The ‘reverse’ method returns an array with the same element type. The sort method takes an optional parameter, ‘compareFn’, whose type is a function that takes two parameters of type ‘T’ and returns a number. Finally, sort returns an array with element type ‘T’. +Interface definitions, like the one above, can have one or more *type parameters*. In this case the 'Array' interface has a single parameter, 'T', that defines the element type for the array. The 'reverse' method returns an array with the same element type. The sort method takes an optional parameter, 'compareFn', whose type is a function that takes two parameters of type 'T' and returns a number. Finally, sort returns an array with element type 'T'. -Functions can also have generic parameters. For example, the array interface contains a ‘map’ method, defined as follows: +Functions can also have generic parameters. For example, the array interface contains a 'map' method, defined as follows: ```TypeScript map(func: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; ``` -The map method, invoked on an array ‘a’ with element type ‘T’, will apply function ‘func’ to each element of ‘a’, returning a value of type ‘U’. +The map method, invoked on an array 'a' with element type 'T', will apply function 'func' to each element of 'a', returning a value of type 'U'. -The TypeScript compiler can often infer generic method parameters, making it unnecessary for the programmer to explicitly provide them. In the following example, the compiler infers that parameter ‘U’ of the map method has type ‘string’, because the function passed to map returns a string. +The TypeScript compiler can often infer generic method parameters, making it unnecessary for the programmer to explicitly provide them. In the following example, the compiler infers that parameter 'U' of the map method has type 'string', because the function passed to map returns a string. ```TypeScript function numberToString(a: number[]) { @@ -649,9 +649,9 @@ function numberToString(a: number[]) { } ``` -The compiler infers in this example that the ‘numberToString’ function returns an array of strings. +The compiler infers in this example that the 'numberToString' function returns an array of strings. -In TypeScript, classes can also have type parameters. The following code declares a class that implements a linked list of items of type ‘T’. This code illustrates how programmers can *constrain* type parameters to extend a specific type. In this case, the items on the list must extend the type ‘NamedItem’. This enables the programmer to implement the ‘log’ function, which logs the name of the item. +In TypeScript, classes can also have type parameters. The following code declares a class that implements a linked list of items of type 'T'. This code illustrates how programmers can *constrain* type parameters to extend a specific type. In this case, the items on the list must extend the type 'NamedItem'. This enables the programmer to implement the 'log' function, which logs the name of the item. ```TypeScript interface NamedItem { @@ -682,7 +682,7 @@ Section [3.5](#3.5) provides further information about generic types. ## 1.10 Modules -Classes and interfaces support large-scale JavaScript development by providing a mechanism for describing how to use a software component that can be separated from that component’s implementation. TypeScript enforces *encapsulation* of implementation in classes at design time (by restricting use of private and protected members), but cannot enforce encapsulation at runtime because all object properties are accessible at runtime. Future versions of JavaScript may provide *private names* which would enable runtime enforcement of private and protected members. +Classes and interfaces support large-scale JavaScript development by providing a mechanism for describing how to use a software component that can be separated from that component's implementation. TypeScript enforces *encapsulation* of implementation in classes at design time (by restricting use of private and protected members), but cannot enforce encapsulation at runtime because all object properties are accessible at runtime. Future versions of JavaScript may provide *private names* which would enable runtime enforcement of private and protected members. In the current version of JavaScript, the only way to enforce encapsulation at runtime is to use the module pattern: encapsulate private fields and methods using closure variables. The module pattern is a natural way to provide organizational structure and dynamic loading options by drawing a boundary around a software component. A module can also provide the ability to introduce namespaces, avoiding use of the global namespace for most software components. @@ -698,9 +698,9 @@ The following example illustrates the JavaScript module pattern. })(MessageModule); ``` -This example illustrates the two essential elements of the module pattern: a *module closure* and a *module* *object*. The module closure is a function that encapsulates the module’s implementation, in this case the variable ‘key’ and the function ‘sendMessage’. The module object contains the exported variables and functions of the module. Simple modules may create and return the module object. The module above takes the module object as a parameter, ‘exports’, and adds the ‘sendMessage’ property to the module object. This *augmentation* approach simplifies dynamic loading of modules and also supports separation of module code into multiple files. +This example illustrates the two essential elements of the module pattern: a *module closure* and a *module* *object*. The module closure is a function that encapsulates the module's implementation, in this case the variable 'key' and the function 'sendMessage'. The module object contains the exported variables and functions of the module. Simple modules may create and return the module object. The module above takes the module object as a parameter, 'exports', and adds the 'sendMessage' property to the module object. This *augmentation* approach simplifies dynamic loading of modules and also supports separation of module code into multiple files. -The example assumes that an outer lexical scope defines the functions ‘generateSecretKey’ and ‘sendSecureMessage’; it also assumes that the outer scope has assigned the module object to the variable ‘MessageModule’. +The example assumes that an outer lexical scope defines the functions 'generateSecretKey' and 'sendSecureMessage'; it also assumes that the outer scope has assigned the module object to the variable 'MessageModule'. TypeScript modules provide a mechanism for succinctly expressing the module pattern. In TypeScript, programmers can combine the module pattern with the class pattern by nesting modules and classes within an outer module. @@ -718,7 +718,7 @@ M.f(); M.s; // Error, s is not exported ``` -In this example, variable ‘s’ is a private feature of the module, but function ‘f’ is exported from the module and accessible to code outside of the module. If we were to describe the effect of module ‘M’ in terms of interfaces and variables, we would write +In this example, variable 's' is a private feature of the module, but function 'f' is exported from the module and accessible to code outside of the module. If we were to describe the effect of module 'M' in terms of interfaces and variables, we would write ```TypeScript interface M { @@ -728,9 +728,9 @@ interface M { var M: M; ``` -The interface ‘M’ summarizes the externally visible behavior of module ‘M’. In this example, we can use the same name for the interface as for the initialized variable because in TypeScript type names and variable names do not conflict: each lexical scope contains a variable declaration space and type declaration space (see section [2.3](#2.3) for more details). +The interface 'M' summarizes the externally visible behavior of module 'M'. In this example, we can use the same name for the interface as for the initialized variable because in TypeScript type names and variable names do not conflict: each lexical scope contains a variable declaration space and type declaration space (see section [2.3](#2.3) for more details). -Module ‘M’ is an example of an *internal* module, because it is nested within the *global* module (see section [10](#10) for more details). The TypeScript compiler emits the following JavaScript code for this module. +Module 'M' is an example of an *internal* module, because it is nested within the *global* module (see section [10](#10) for more details). The TypeScript compiler emits the following JavaScript code for this module. ```TypeScript var M; @@ -743,7 +743,7 @@ var M; })(M || (M = {})); ``` -In this case, the compiler assumes that the module object resides in global variable ‘M’, which may or may not have been initialized to the desired module object. +In this case, the compiler assumes that the module object resides in global variable 'M', which may or may not have been initialized to the desired module object. TypeScript also supports *external* modules, which are files that contain top-level *export* and *import *directives. For this type of module the TypeScript compiler will emit code whose module closure and module object implementation vary according to the specified dynamic loading system, for example, the Asynchronous Module Definition system. @@ -758,13 +758,13 @@ The remainder of this document is the formal specification of the TypeScript pro The syntactic grammar added by TypeScript language is specified throughout this document using the existing conventions and production names of the ECMAScript grammar. In places where TypeScript augments an existing grammar production it is so noted. For example:   *CallExpression:* *( Modified )* -   … +   …    `super` `(` *ArgumentListopt* `)`    `super` `.` *IdentifierName* -The ‘*( Modified )*’ annotation indicates that an existing grammar production is being replaced, and the ‘…’ references the contents of the original grammar production. +The '*( Modified )*' annotation indicates that an existing grammar production is being replaced, and the '…' references the contents of the original grammar production. -Similar to the ECMAScript grammar, if the phrase “*[no LineTerminator here]*” appears in the right-hand side of a production of the syntactic grammar, it indicates that the production is not a match if a *LineTerminator* occurs in the input stream at the indicated position. +Similar to the ECMAScript grammar, if the phrase "*[no LineTerminator here]*" appears in the right-hand side of a production of the syntactic grammar, it indicates that the production is not a match if a *LineTerminator* occurs in the input stream at the indicated position. ## 2.2 Namespaces and Named Types @@ -779,7 +779,7 @@ module X { } ``` -declares two interface types with the qualified names ‘X.Y.Z’ and ‘X.Y’ relative to the root module in which ‘X’ is declared. +declares two interface types with the qualified names 'X.Y.Z' and 'X.Y' relative to the root module in which 'X' is declared. In a qualified type name all identifiers but the last one refer to namespaces and the last identifier refers to a named type. Named type and namespace names are in separate declaration spaces and it is therefore possible for a named type and a namespace to have the same name, as in the example above. @@ -793,23 +793,23 @@ module A { } ``` -introduces a named type with the qualified name ‘A.B.C’ and also introduces a constructor function that can be accessed using the expression ‘A.B.C’. Thus, in the example +introduces a named type with the qualified name 'A.B.C' and also introduces a constructor function that can be accessed using the expression 'A.B.C'. Thus, in the example ```TypeScript var c: A.B.C = new A.B.C(); ``` -the two occurrences of ‘A.B.C’ in fact refer to different entities. It is the context of the occurrences that determines whether ‘A.B.C’ is processed as a type name or an expression. +the two occurrences of 'A.B.C' in fact refer to different entities. It is the context of the occurrences that determines whether 'A.B.C' is processed as a type name or an expression. ## 2.3 Declarations Declarations introduce names in the ***declaration spaces*** to which they belong. It is an error to have two names with same spelling in the same declaration space. Declaration spaces exist as follows: * The global module and each external or internal module has a declaration space for variables (including functions, modules, class constructor functions, and enum objects), a declaration space for named types (classes, interfaces, and enums), and a declaration space for namespaces (containers of named types). Every declaration (whether local or exported) in a module contributes to one or more of these declaration spaces. -* Each external or internal module has a declaration space for exported members, a declaration space for exported named types, and a declaration space for exported namespaces. All export declarations in the module contribute to these declaration spaces. Each internal module’s export declaration spaces are shared with other internal modules that have the same root module and the same qualified name starting from that root module. +* Each external or internal module has a declaration space for exported members, a declaration space for exported named types, and a declaration space for exported namespaces. All export declarations in the module contribute to these declaration spaces. Each internal module's export declaration spaces are shared with other internal modules that have the same root module and the same qualified name starting from that root module. * Each class declaration has a declaration space for instance members, a declaration space for static members, and a declaration space for type parameters. -* Each interface declaration has a declaration space for members and a declaration space for type parameters. An interface’s declaration space is shared with other interfaces that have the same root module and the same qualified name starting from that root module. -* Each enum declaration has a declaration space for its enum members. An enum’s declaration space is shared with other enums that have the same root module and the same qualified name starting from that root module. +* Each interface declaration has a declaration space for members and a declaration space for type parameters. An interface's declaration space is shared with other interfaces that have the same root module and the same qualified name starting from that root module. +* Each enum declaration has a declaration space for its enum members. An enum's declaration space is shared with other enums that have the same root module and the same qualified name starting from that root module. * Each function declaration (including constructor, member function, and member accessor declarations) and each function expression has a declaration space for variables (parameters, local variables, and local functions) and a declaration space for type parameters. * Each object literal has a declaration space for its properties. * Each object type literal has a declaration space for its members. @@ -827,14 +827,14 @@ The ***parent module*** of an entity is defined as follows: The ***root module*** of an entity is defined as follows: -* The root module of a non-exported entity is the entity’s parent module. -* The root module of an exported entity is the root module of the entity’s parent module. +* The root module of a non-exported entity is the entity's parent module. +* The root module of an exported entity is the root module of the entity's parent module. Intuitively, the root module of an entity is the outermost module body from within which the entity is reachable. -Interfaces, enums, and internal modules are “open ended,” meaning that interface, enum, and internal module declarations with the same qualified name relative to a common root are automatically merged. For further details, see sections [7.2](#7.2), [9.3](#9.3), and [10.5](#10.5). +Interfaces, enums, and internal modules are "open ended," meaning that interface, enum, and internal module declarations with the same qualified name relative to a common root are automatically merged. For further details, see sections [7.2](#7.2), [9.3](#9.3), and [10.5](#10.5). -Namespace, type, and member names exist in separate declaration spaces. Furthermore, declarations of non-instantiated modules (modules that contain only interfaces or modules at all levels of nesting) do not introduce a member name in their containing declaration space. This means that the following is permitted, provided module ‘X’ contains only interface or module declarations at all levels of nesting: +Namespace, type, and member names exist in separate declaration spaces. Furthermore, declarations of non-instantiated modules (modules that contain only interfaces or modules at all levels of nesting) do not introduce a member name in their containing declaration space. This means that the following is permitted, provided module 'X' contains only interface or module declarations at all levels of nesting: ```TypeScript module M { @@ -844,7 +844,7 @@ module M { } ``` -If module ‘X’ above was an instantiated module (section [10.1](#10.1)) it would cause a member ‘X’ to be introduced in ‘M’. This member would conflict with the variable ‘X’ and thus cause an error. +If module 'X' above was an instantiated module (section [10.1](#10.1)) it would cause a member 'X' to be introduced in 'M'. This member would conflict with the variable 'X' and thus cause an error. Instance and static members in a class are likewise in separate declaration spaces. Thus the following is permitted: @@ -876,7 +876,7 @@ When an identifier is resolved as a *ModuleName* (section [3.6.2](#3.6.2)), only When an identifier is resolved as a *PrimaryExpression* (section [4.3](#4.3)), only instantiated modules (section [10.1](#10.1)), classes, enums, functions, variables, and parameters are considered and other entities in scope are ignored. -Note that class and enum members are never directly in scope—they can only be accessed by applying the dot (‘.’) operator to a class instance or enum object. This even includes members of the current instance in a constructor or member function, which are accessed by applying the dot operator to `this`. +Note that class and enum members are never directly in scope—they can only be accessed by applying the dot ('.') operator to a class instance or enum object. This even includes members of the current instance in a constructor or member function, which are accessed by applying the dot operator to `this`. As the rules above imply, locally declared entities in an internal module are closer in scope than exported entities declared in other module declarations for the same internal module. For example: @@ -899,11 +899,11 @@ module M { # 3 Types -TypeScript adds optional static types to JavaScript. Types are used to place static constraints on program entities such as functions, variables, and properties so that compilers and development tools can offer better verification and assistance during software development. TypeScript’s *static* compile-time type system closely models the *dynamic* run-time type system of JavaScript, allowing programmers to accurately express the type relationships that are expected to exist when their programs run and have those assumptions pre-validated by the TypeScript compiler. TypeScript’s type analysis occurs entirely at compile-time and adds no run-time overhead to program execution. +TypeScript adds optional static types to JavaScript. Types are used to place static constraints on program entities such as functions, variables, and properties so that compilers and development tools can offer better verification and assistance during software development. TypeScript's *static* compile-time type system closely models the *dynamic* run-time type system of JavaScript, allowing programmers to accurately express the type relationships that are expected to exist when their programs run and have those assumptions pre-validated by the TypeScript compiler. TypeScript's type analysis occurs entirely at compile-time and adds no run-time overhead to program execution. All types in TypeScript are subtypes of a single top type called the Any type. The `any` keyword references this type. The Any type is the one type that can represent *any* JavaScript value with no constraints. All other types are categorized as ***primitive types***, ***object types***, or ***type parameters***. These types introduce various static constraints on their values. -The primitive types are the Number, Boolean, String, Void, Null, and Undefined types along with user defined enum types. The `number`, `boolean`, `string`, and `void` keywords reference the Number, Boolean, String, and Void primitive types respectively. The Void type exists purely to indicate the absence of a value, such as in a function with no return value. It is not possible to explicitly reference the Null and Undefined types—only *values* of those types can be referenced, using the `null` and `undefined` literals. +The primitive types are the Number, Boolean, String, Void, Null, and Undefined types along with user defined enum types. The `number`, `boolean`, `string`, and `void` keywords reference the Number, Boolean, String, and Void primitive types respectively. The Void type exists purely to indicate the absence of a value, such as in a function with no return value. It is not possible to explicitly reference the Null and Undefined types—only *values* of those types can be referenced, using the `null` and `undefined` literals. The object types are all class, interface, array, and literal types. Class and interface types are introduced through class and interface declarations and are referenced by the name given to them in their declarations. Class and interface types may be ***generic types*** which have one or more type parameters. Literal types are written as object, array, function, or constructor type literals and are used to compose new types from other types. @@ -919,7 +919,7 @@ or through implicit ***type inference***, as in var x = 1; ``` -which infers the type of ‘x’ to be the Number primitive type because that is the type of the value used to initialize ‘x’. +which infers the type of 'x' to be the Number primitive type because that is the type of the value used to initialize 'x'. ## 3.1 The Any Type @@ -951,7 +951,7 @@ The Number primitive type corresponds to the similarly named JavaScript primitiv The `number` keyword references the Number primitive type and numeric literals may be used to write values of the Number primitive type. -For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the Number primitive type behaves as an object type with the same properties as the global interface type ‘Number’. +For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. Some examples: @@ -968,7 +968,7 @@ The Boolean primitive type corresponds to the similarly named JavaScript primiti The `boolean` keyword references the Boolean primitive type and the `true` and `false` literals reference the two Boolean truth values. -For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the Boolean primitive type behaves as an object type with the same properties as the global interface type ‘Boolean’. +For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the Boolean primitive type behaves as an object type with the same properties as the global interface type 'Boolean'. Some examples: @@ -984,7 +984,7 @@ The String primitive type corresponds to the similarly named JavaScript primitiv The `string` keyword references the String primitive type and string literals may be used to write values of the String primitive type. -For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the String primitive type behaves as an object type with the same properties as the global interface type ‘String’. +For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the String primitive type behaves as an object type with the same properties as the global interface type 'String'. Some examples: @@ -1071,9 +1071,9 @@ Type references (section [3.6.2](#3.6.2)) to class and interface types are class ### 3.3.2 Array Types -***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type ‘Array’ in the global module with the array element type as a type argument. Array type literals (section [3.6.4](#3.6.4)) provide a shorthand notation for creating such references. +***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type 'Array' in the global module with the array element type as a type argument. Array type literals (section [3.6.4](#3.6.4)) provide a shorthand notation for creating such references. -The declaration of the ‘Array’ interface includes a property ‘length’ and a numeric index signature for the element type, along with other members: +The declaration of the 'Array' interface includes a property 'length' and a numeric index signature for the element type, along with other members: ```TypeScript interface Array { @@ -1126,7 +1126,7 @@ var x = t[i]; // Type of x is number | string ***Union types*** represent values that may have one of several disjoint representations. A value of a union type *A* | *B* is a value that is *either* of type *A* or type *B*. Union types are written using union type literals (section [3.6.6](#3.6.6)). -A union type encompasses an unordered set of unrelated types (that is, types that aren’t subtypes of each other). The following rules govern union types: +A union type encompasses an unordered set of unrelated types (that is, types that aren't subtypes of each other). The following rules govern union types: * *A* | *B* is equivalent to *A* if *B* is a subtype of *A*. * *A* | *B* is equivalent to *B* | *A*. @@ -1155,8 +1155,8 @@ For purposes of property access (section [4.10](#4.10)) and function calls ([4.1 When used as a contextual type (section [4.19](#4.19)), a union type *U* has those members that are present in any of its constituent types, with types that are unions of the respective members in the constituent types. Specifically: * Let *S* be the set of types in *U* that has a property *P*. If *S* is not empty, *U* has a property *P* of a union type of the types of *P* from each type in *S*. -* Let *S* be the set of types in *U* that have call signatures. If *S* is not empty and the sets of call signatures of the types in *S* are identical ignoring return types,* U* has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in *S*. -* Let *S* be the set of types in *U* that have construct signatures. If *S* is not empty and the sets of construct signatures of the types in *S* are identical ignoring return types,* U* has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in *S*. +* Let *S* be the set of types in *U* that have call signatures. If *S* is not empty and the sets of call signatures of the types in *S* are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in *S*. +* Let *S* be the set of types in *U* that have construct signatures. If *S* is not empty and the sets of construct signatures of the types in *S* are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in *S*. * Let *S* be the set of types in *U* that has a string index signature. If *S* is not empty, *U* has a string index signature of a union type of the types of the string index signatures from each type in *S*. * Let *S* be the set of types in *U* that has a numeric index signature. If *S* is not empty, *U* has a numeric index signature of a union type of the types of the numeric index signatures from each type in *S*. @@ -1176,7 +1176,7 @@ x = test ? 5 : "five"; // Ok x = test ? 0 : false; // Error, number | boolean not asssignable ``` -it is possible to assign ‘x’ a value of type string, number, or the union type string | number, but not any other type. To access a value in ‘x’, a type guard can be used to first narrow the type of ‘x’ to either string or number: +it is possible to assign 'x' a value of type string, number, or the union type string | number, but not any other type. To access a value in 'x', a type guard can be used to first narrow the type of 'x' to either string or number: ```TypeScript var n = typeof x === "string" ? x.length : x; // Type of n is number @@ -1202,7 +1202,7 @@ var b = x.b; // b has type number var c = x.c; // Error, no property c in union type ``` -Note that ‘x.a’ has a union type because the type of ‘a’ is different in ‘A’ and ‘B’, whereas ‘x.b’ simply has type number because that is the type of ‘b’ in both ‘A’ and ‘B’. Also note that there is no property ‘x.c’ because only ‘A’ has a property ‘c’. +Note that 'x.a' has a union type because the type of 'a' is different in 'A' and 'B', whereas 'x.b' simply has type number because that is the type of 'b' in both 'A' and 'B'. Also note that there is no property 'x.c' because only 'A' has a property 'c'. ### 3.3.5 Function Types @@ -1259,9 +1259,9 @@ Each type parameter has an associated type parameter ***constraint*** that estab The ***base constraint*** of a type parameter *T* is defined as follows: -* If *T* has no declared constraint, *T*’s base constraint is the empty object type `{}`. -* If *T*’s declared constraint is a type parameter, *T*’s base constraint is that of the type parameter. -* Otherwise, *T*’s base constraint is *T*’s declared constraint. +* If *T* has no declared constraint, *T*'s base constraint is the empty object type `{}`. +* If *T*'s declared constraint is a type parameter, *T*'s base constraint is that of the type parameter. +* Otherwise, *T*'s base constraint is *T*'s declared constraint. In the example @@ -1271,7 +1271,7 @@ interface G { } ``` -the base constraint of ‘T’ is the empty object type, and the base constraint of ‘U’ and ‘V’ is ‘Function’. +the base constraint of 'T' is the empty object type, and the base constraint of 'U' and 'V' is 'Function'. For purposes of determining type relationships (section [3.8](#3.8)), type parameters appear to be subtypes of their base constraint. Likewise, in property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)), type parameters appear to have the members of their base constraint, but no other members. @@ -1297,7 +1297,7 @@ Given the declaration interface G { } ``` -a type reference of the form ‘G<A, B>’ places no requirements on ‘A’ but requires ‘B’ to be assignable to ‘Function’. +a type reference of the form 'G<A, B>' places no requirements on 'A' but requires 'B' to be assignable to 'Function'. The process of substituting type arguments for type parameters in a generic type or generic signature is known as ***instantiating*** the generic type or signature. Instantiation of a generic type or signature can fail if the supplied type arguments do not satisfy the constraints of their corresponding type parameters. @@ -1305,11 +1305,11 @@ The process of substituting type arguments for type parameters in a generic type Class, interface, and enum types are ***named types*** that are introduced through class declarations (section [8.1](#8.1)), interface declarations (section [7.1](#7.1)), and enum declarations ([9.1](#9.1)). Class and interface types may have type parameters and are then called ***generic types***. Conversely, named types without type parameters are called ***non-generic types***. -Interface declarations only introduce named types, whereas class declarations introduce named types *and* constructor functions that create instances of implementations of those named types. The named types introduced by class and interface declarations have only minor differences (classes can’t declare optional members and interfaces can’t declare private or protected members) and are in most contexts interchangeable. In particular, class declarations with only public members introduce named types that function exactly like those created by interface declarations. +Interface declarations only introduce named types, whereas class declarations introduce named types *and* constructor functions that create instances of implementations of those named types. The named types introduced by class and interface declarations have only minor differences (classes can't declare optional members and interfaces can't declare private or protected members) and are in most contexts interchangeable. In particular, class declarations with only public members introduce named types that function exactly like those created by interface declarations. Named types are referenced through ***type references*** (section [3.6.2](#3.6.2)) that specify a type name and, if applicable, the type arguments to be substituted for the type parameters of the named type. -Named types are technically not types—only *references* to named types are. This distinction is particularly evident with generic types: Generic types are “templates” from which multiple *actual* types can be created by writing type references that supply type arguments to substitute in place of the generic type’s type parameters. This substitution process is known as ***instantiating*** a generic type. Only once a generic type is instantiated does it denote an actual type. +Named types are technically not types—only *references* to named types are. This distinction is particularly evident with generic types: Generic types are "templates" from which multiple *actual* types can be created by writing type references that supply type arguments to substitute in place of the generic type's type parameters. This substitution process is known as ***instantiating*** a generic type. Only once a generic type is instantiated does it denote an actual type. TypeScript has a structural type system, and therefore an instantiation of a generic type is indistinguishable from an equivalent manually written expansion. For example, given the declaration @@ -1331,7 +1331,7 @@ is indistinguishable from the type ### 3.5.1 Instance Types -Each named type has an associated actual type known as the ***instance type***. For a non-generic type, the instance type is simply a type reference to the non-generic type. For a generic type, the instance type is an instantiation of the generic type where each of the type arguments is the corresponding type parameter. Since the instance type uses the type parameters it can be used only where the type parameters are in scope—that is, inside the declaration of the generic type. Within the constructor and instance member functions of a class, the type of `this` is the instance type of the class. +Each named type has an associated actual type known as the ***instance type***. For a non-generic type, the instance type is simply a type reference to the non-generic type. For a generic type, the instance type is an instantiation of the generic type where each of the type arguments is the corresponding type parameter. Since the instance type uses the type parameters it can be used only where the type parameters are in scope—that is, inside the declaration of the generic type. Within the constructor and instance member functions of a class, the type of `this` is the instance type of the class. The following example illustrates the concept of an instance type: @@ -1349,16 +1349,33 @@ class G { // Introduce type parameter T Types are specified either by referencing their keyword or name, or by writing object type literals, array type literals, tuple type literals, function type literals, constructor type literals, or type queries.   *Type:* +   *PrimaryOrUnionType* +   *FunctionType* +   *ConstructorType* + +  *PrimaryOrUnionType:* +   *PrimaryType* +   *UnionType* + +  *PrimaryType:* +   *ParenthesizedType*    *PredefinedType*    *TypeReference*    *ObjectType*    *ArrayType*    *TupleType* -   *UnionType* -   *FunctionType* -   *ConstructorType*    *TypeQuery* +  *ParenthesizedType:* +   `(` *Type* `)` + +Parentheses are required around union, function, or constructor types when they are used as array element types, and parentheses are required around function or constructor types in union types. For example: + +```TypeScript +(string | number)[] +((x: string) => string) | (x: number) => number) +``` + The different forms of type notations are described in the following sections. ### 3.6.1 Predefined Types @@ -1422,9 +1439,9 @@ var v6: G; // Error, wrong number of arguments var v7: G; // Error, no arguments ``` -A type argument is simply a *Type* and may itself be a type reference to a generic type, as demonstrated by ‘v4’ in the example above. +A type argument is simply a *Type* and may itself be a type reference to a generic type, as demonstrated by 'v4' in the example above. -As described in section [3.5](#3.5), a type reference to a generic type *G* designates a type wherein all occurrences of *G*’s type parameters have been replaced with the actual type arguments supplied in the type reference. For example, the declaration of ‘v1’ above is equivalent to: +As described in section [3.5](#3.5), a type reference to a generic type *G* designates a type wherein all occurrences of *G*'s type parameters have been replaced with the actual type arguments supplied in the type reference. For example, the declaration of 'v1' above is equivalent to: ```TypeScript var v1: { @@ -1461,36 +1478,24 @@ The members of an object type literal are specified as a combination of property An array type literal is written as an element type followed by an open and close square bracket.   *ArrayType:* -   *ElementType* *[no LineTerminator here]* `[` `]` +   *PrimaryType* *[no LineTerminator here]* `[` `]` -  *ElementType:* -   *PredefinedType* -   *TypeReference* -   *ObjectType* -   *ArrayType* -   *TupleType* -   *TypeQuery* +An array type literal references an array type (section [3.3.2](#3.3.2)) with the given element type. An array type literal is simply shorthand notation for a reference to the generic interface type 'Array' in the global module with the element type as a type argument. -An array type literal references an array type (section [3.3.2](#3.3.2)) with the given element type. An array type literal is simply shorthand notation for a reference to the generic interface type ‘Array’ in the global module with the element type as a type argument. - -In order to avoid grammar ambiguities, array type literals permit only a restricted set of notations for the element type. Specifically, an *ArrayType* cannot start with a *UnionType*, *FunctionType* or *ConstructorType*. To use one of those forms for the element type, an array type must be written using the ‘Array<T>’ notation. For example, the type +When union, function, or constructor types are used as array element types they must be enclosed in parentheses. For example: ```TypeScript -() => string[] +(string | number)[] +(() => string))[] ``` -denotes a function returning a string array, not an array of functions returning string. The latter can be expressed using ‘Array<T>’ notation +Alternatively, array types can be written using the 'Array<T>' notation. For example, the types above are equivalent to ```TypeScript +Array Array<() => string> ``` -or by writing the element type as an object type literal - -```TypeScript -{ (): string }[] -``` - ### 3.6.5 Tuple Type Literals A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. @@ -1512,28 +1517,22 @@ A tuple type literal references a tuple type (section [3.3.3](#3.3.3)). A union type literal is written as a sequence of types separated by vertical bars.   *UnionType:* -   *ElementType* `|` *UnionOrElementType* - -  *UnionOrElementType:* -   *UnionType* -   *ElementType* +   *PrimaryOrUnionType* `|` *PrimaryType* A union typle literal references a union type (section [3.3.4](#3.3.4)). -In order to avoid grammar ambiguities, union type literals permit only a restricted set of notations for the element types. Specifically, an element of a *UnionType* cannot be written as a *FunctionType* or *ConstructorType*. To include function or constructor types in a union type the function or constructor types must be written as object type literals. For example +When function or constructor types are included in union types they must be enclosed in parentheses. For example: ```TypeScript -() => string | () => number +((x: string) => string) | ((x: number) => number) ``` -denotes a function whose return value is either a string or a function returning number, whereas +Alternatively, function or constructor types in union types can be written using object literals: ```TypeScript -{ (): string } | { (): number } +{ (x: string): string } | { (x: number): number } ``` -denotes either a function returning string or a function returning number. - ### 3.6.7 Function Type Literals A function type literal specifies the type parameters, regular parameters, and return type of a call signature. @@ -1596,7 +1595,7 @@ var a = { x: 10, y: 20 }; var b: typeof a; ``` -Above, ‘b’ is given the same type as ‘a’, namely ‘{ x: number; y: number; }’. +Above, 'b' is given the same type as 'a', namely '{ x: number; y: number; }'. If a declaration includes a type annotation that references the entity being declared through a circular path of type queries or type references containing type queries, the resulting type is the Any type. For example, all of the following variables are given the type Any: @@ -1614,7 +1613,7 @@ var g: { x: typeof g; }; var h: () => typeof h; ``` -Here, ‘g’ and ‘g.x’ have the same recursive type, and likewise ‘h’ and ‘h()’ have the same recursive type. +Here, 'g' and 'g.x' have the same recursive type, and likewise 'h' and 'h()' have the same recursive type. ## 3.7 Specifying Members @@ -1673,7 +1672,7 @@ A function taking two values of the same type, returning an array of that type: (x: T, y: T): T[] ``` -A function taking two arguments of different types, returning an object with properties ‘x’ and ‘y’ of those types: +A function taking two arguments of different types, returning an object with properties 'x' and 'y' of those types: ```TypeScript (x: T, y: U): { x: T; y: U; } @@ -1687,7 +1686,7 @@ A function taking an array of one type and a function argument, returning an arr #### 3.7.2.2 Parameter List -A signature’s parameter list consists of zero or more required parameters, followed by zero or more optional parameters, finally followed by an optional rest parameter. +A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, finally followed by an optional rest parameter.   *ParameterList:*    *RequiredParameterList* @@ -1737,7 +1736,7 @@ A parameter can be marked optional by following its name with a question mark (` #### 3.7.2.3 Return Type -If present, a call signature’s return type annotation specifies the type of the value computed and returned by a call operation. A `void` return type annotation is used to indicate that a function has no return value. +If present, a call signature's return type annotation specifies the type of the value computed and returned by a call operation. A `void` return type annotation is used to indicate that a function has no return value. When a call signature with no return type annotation occurs in a context without a function body, the return type is assumed to be the Any type. @@ -1756,11 +1755,11 @@ interface Document { } ``` -states that calls to ‘createElement’ with the string literals “div”, “span”, and “canvas” return values of type ‘HTMLDivElement’, ‘HTMLSpanElement’, and ‘HTMLCanvasElement’ respectively, and that calls with all other string expressions return values of type ‘HTMLElement’. +states that calls to 'createElement' with the string literals "div", "span", and "canvas" return values of type 'HTMLDivElement', 'HTMLSpanElement', and 'HTMLCanvasElement' respectively, and that calls with all other string expressions return values of type 'HTMLElement'. When writing overloaded declarations such as the one above it is important to list the non-specialized signature last. This is because overload resolution (section [4.12.1](#4.12.1)) processes the candidates in declaration order and picks the first one that matches. -Every specialized call or construct signature in an object type must be assignable to at least one non-specialized call or construct signature in the same object type (where a call signature *A* is considered assignable to another call signature *B* if an object type containing only *A* would be assignable to an object type containing only *B*). For example, the ‘createElement’ property in the example above is of a type that contains three specialized signatures, all of which are assignable to the non-specialized signature in the type. +Every specialized call or construct signature in an object type must be assignable to at least one non-specialized call or construct signature in the same object type (where a call signature *A* is considered assignable to another call signature *B* if an object type containing only *A* would be assignable to an object type containing only *B*). For example, the 'createElement' property in the example above is of a type that contains three specialized signatures, all of which are assignable to the non-specialized signature in the type. ### 3.7.3 Construct Signatures @@ -1841,7 +1840,7 @@ In the following example of an object type } ``` -the properties ‘func1’, ‘func2’, and ‘func3’ are all of the same type, namely an object type with a single call signature taking a number and returning a number. Likewise, in the object type +the properties 'func1', 'func2', and 'func3' are all of the same type, namely an object type with a single call signature taking a number and returning a number. Likewise, in the object type ```TypeScript { @@ -1854,29 +1853,29 @@ the properties } ``` -the properties ‘func4’ and ‘func5’ are of the same type, namely an object type with two call signatures taking and returning number and string respectively. +the properties 'func4' and 'func5' are of the same type, namely an object type with two call signatures taking and returning number and string respectively. ## 3.8 Type Relationships Types in TypeScript have identity, subtype, supertype, and assignment compatibility relationships as defined in the following sections. -For purposes of determining type relationships, all object types appear to have the members of the ‘Object’ interface unless those members are hidden by members with the same name in the object types, and object types with one or more call or construct signatures appear to have the members of the ‘Function’ interface unless those members are hidden by members with the same name in the object types. Apparent types (section [3.8.1](#3.8.1)) that are object types appear to have these extra members as well. +For purposes of determining type relationships, all object types appear to have the members of the 'Object' interface unless those members are hidden by members with the same name in the object types, and object types with one or more call or construct signatures appear to have the members of the 'Function' interface unless those members are hidden by members with the same name in the object types. Apparent types (section [3.8.1](#3.8.1)) that are object types appear to have these extra members as well. ### 3.8.1 Apparent Type -In certain contexts a type appears to have the characteristics of a related type called the type’s ***apparent type***. Specifically, a type’s apparent type is used when determining subtype, supertype, and assignment compatibility relationships, as well as in the type checking of property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)). +In certain contexts a type appears to have the characteristics of a related type called the type's ***apparent type***. Specifically, a type's apparent type is used when determining subtype, supertype, and assignment compatibility relationships, as well as in the type checking of property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)). The apparent type of a type *T* is defined as follows: -* If *T* is the primitive type Number, Boolean, or String, the apparent type of *T* is the augmented form (as defined below) of the global interface type ‘Number’, ‘Boolean’, or ‘String’. -* if *T* is an enum type, the apparent type of *T* is the augmented form of the global interface type ‘Number’. +* If *T* is the primitive type Number, Boolean, or String, the apparent type of *T* is the augmented form (as defined below) of the global interface type 'Number', 'Boolean', or 'String'. +* if *T* is an enum type, the apparent type of *T* is the augmented form of the global interface type 'Number'. * If *T* is an object type, the apparent type of *T* is the augmented form of *T*. -* If *T* is a type parameter, the apparent type of *T* is the apparent type of *T*’s base constraint (section [3.4.1](#3.4.1)). +* If *T* is a type parameter, the apparent type of *T* is the apparent type of *T*'s base constraint (section [3.4.1](#3.4.1)). * Otherwise, the apparent type of *T* is *T* itself. -The augmented form of an object type *T* adds to *T* those properties of the global interface type ‘Object’ that aren’t hidden by properties in *T*. Furthermore, if *T* has one or more call or construct signatures, the augmented form of *T* adds to *T* the properties of the global interface type ‘Function’ that aren’t hidden by properties in *T*. Properties in *T* hide ‘Object’ or ‘Function’ interface properties with the same name. +The augmented form of an object type *T* adds to *T* those properties of the global interface type 'Object' that aren't hidden by properties in *T*. Furthermore, if *T* has one or more call or construct signatures, the augmented form of *T* adds to *T* the properties of the global interface type 'Function' that aren't hidden by properties in *T*. Properties in *T* hide 'Object' or 'Function' interface properties with the same name. -In effect, a type’s apparent type is a subtype of the ‘Object’ or ‘Function’ interface unless the type defines members that are incompatible with those of the ‘Object’ or ‘Function’ interface—which, for example, occurs if the type defines a property with the same name as a property in the ‘Object’ or ‘Function’ interface but with a type that isn’t a subtype of that in the ‘Object’ or ‘Function’ interface. +In effect, a type's apparent type is a subtype of the 'Object' or 'Function' interface unless the type defines members that are incompatible with those of the 'Object' or 'Function' interface—which, for example, occurs if the type defines a property with the same name as a property in the 'Object' or 'Function' interface but with a type that isn't a subtype of that in the 'Object' or 'Function' interface. Some examples: @@ -1886,7 +1885,7 @@ var f: Function = (x: number) => x * x; // Ok var err: Object = { toString: 0 }; // Error ``` -The last assignment is an error because the apparent type of the object literal has a ‘toString’ method that isn’t compatible with that of ‘Object’. +The last assignment is an error because the apparent type of the object literal has a 'toString' method that isn't compatible with that of 'Object'. ### 3.8.2 Type and Member Identity @@ -1923,11 +1922,11 @@ var a: C; var b: C; ``` -the variables ‘a’ and ‘b’ are of identical types because the two type references to ‘C’ create types with a private member ‘x’ that originates in the same declaration, and because the two private ‘x’ members have types with identical sets of members once the type arguments ‘X’ and ‘Y’ are substituted. +the variables 'a' and 'b' are of identical types because the two type references to 'C' create types with a private member 'x' that originates in the same declaration, and because the two private 'x' members have types with identical sets of members once the type arguments 'X' and 'Y' are substituted. ### 3.8.3 Subtypes and Supertypes -*S* is a ***subtype*** of a type *T*, and *T* is a ***supertype*** of *S*, if one of the following is true, where *S*’ denotes the apparent type (section [3.8.1](#3.8.1)) of *S*: +*S* is a ***subtype*** of a type *T*, and *T* is a ***supertype*** of *S*, if one of the following is true, where *S*' denotes the apparent type (section [3.8.1](#3.8.1)) of *S*: * *S* and *T* are identical types. * *T* is the Any type. @@ -1938,20 +1937,20 @@ the variables * *S* and *T* are type parameters, and *S* is directly or indirectly constrained to *T*. * *S* is a union type and each constituent type of *S* is a subtype of *T*. * *T* is a union type and *S* is a subtype of at least one constituent type of *T*. -* *S’* and *T* are object types and, for each member *M* in *T*, one of the following is true: - * *M* is a property and *S’* contains a property *N* where +* *S'* and *T* are object types and, for each member *M* in *T*, one of the following is true: + * *M* is a property and *S'* contains a property *N* where * *M* and *N* have the same name, * the type of *N* is a subtype of that of *M*, * if *M* is a required property, *N* is also a required property, and * *M* and *N* are both public, *M* and *N* are both private and originate in the same declaration, *M* and *N* are both protected and originate in the same declaration, or *M* is protected and *N* is declared in a class derived from the class in which *M* is declared. - * *M* is an optional property and *S’* contains no property of the same name as *M*. - * *M* is a non-specialized call or construct signature and *S*’ contains a call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), + * *M* is an optional property and *S'* contains no property of the same name as *M*. + * *M* is a non-specialized call or construct signature and *S*' contains a call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), * the signatures are of the same kind (call or construct), * *M* has a rest parameter or the number of non-optional parameters in *N* is less than or equal to the total number of parameters in *M*, * for parameter positions that are present in both signatures, each parameter type in *N* is a subtype or supertype of the corresponding parameter type in *M*, and * the result type of *M* is Void, or the result type of *N* is a subtype of that of *M*. - * *M* is a string index signature of type *U* and *S’* contains a string index signature of a type that is a subtype of *U*. - * *M* is a numeric index signature of type *U* and *S’* contains a string or numeric index signature of a type that is a subtype of *U*. + * *M* is a string index signature of type *U* and *S'* contains a string index signature of a type that is a subtype of *U*. + * *M* is a numeric index signature of type *U* and *S'* contains a string or numeric index signature of a type that is a subtype of *U*. When comparing call or construct signatures, parameter names are ignored and rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. @@ -1963,7 +1962,7 @@ Also note that type parameters are not considered object types. Thus, the only s Types are required to be assignment compatible in certain circumstances, such as expression and variable types in assignment statements and argument and parameter types in function calls. -*S* is ***assignable to*** a type *T*, and *T* is ***assignable from*** *S*, if one of the following is true, where *S*’ denotes the apparent type (section [3.8.1](#3.8.1)) of *S*: +*S* is ***assignable to*** a type *T*, and *T* is ***assignable from*** *S*, if one of the following is true, where *S*' denotes the apparent type (section [3.8.1](#3.8.1)) of *S*: * *S* and *T* are identical types. * *S* or *T* is the Any type. @@ -1974,20 +1973,20 @@ Types are required to be assignment compatible in certain circumstances, such as * *S* and *T* are type parameters, and *S* is directly or indirectly constrained to *T*. * *S* is a union type and each constituent type of *S* is assignable to *T*. * *T* is a union type and *S* is assignable to at least one constituent type of *T*. -* *S’* and *T* are object types and, for each member *M* in *T*, one of the following is true: - * *M* is a property and *S’* contains a property *N* where +* *S'* and *T* are object types and, for each member *M* in *T*, one of the following is true: + * *M* is a property and *S'* contains a property *N* where * *M* and *N* have the same name, * the type of *N* is assignable to that of *M*, * if *M* is a required property, *N* is also a required property, and * *M* and *N* are both public, *M* and *N* are both private and originate in the same declaration, *M* and *N* are both protected and originate in the same declaration, or *M* is protected and *N* is declared in a class derived from the class in which *M* is declared. - * *M* is an optional property and *S’* contains no property of the same name as *M*. - * *M* is a non-specialized call or construct signature and *S*’ contains a call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), + * *M* is an optional property and *S'* contains no property of the same name as *M*. + * *M* is a non-specialized call or construct signature and *S*' contains a call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), * the signatures are of the same kind (call or construct), * *M* has a rest parameter or the number of non-optional parameters in *N* is less than or equal to the total number of parameters in *M*, * for parameter positions that are present in both signatures, each parameter type in *N* is assignable to or from the corresponding parameter type in *M*, and * the result type of *M* is Void, or the result type of *N* is assignable to that of *M*. - * *M* is a string index signature of type *U* and *S’* contains a string index signature of a type that is assignable to *U*. - * *M* is a numeric index signature of type *U* and *S’* contains a string or numeric index signature of a type that is assignable to *U*. + * *M* is a string index signature of type *U* and *S'* contains a string index signature of a type that is assignable to *U*. + * *M* is a numeric index signature of type *U* and *S'* contains a string or numeric index signature of a type that is assignable to *U*. When comparing call or construct signatures, parameter names are ignored and rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. @@ -2013,7 +2012,7 @@ foo({ name: "hello" }); // Error, id required but missing During type argument inference in a function call (section [4.12.2](#4.12.2)) it is in certain circumstances necessary to instantiate a generic call signature of an argument expression in the context of a non-generic call signature of a parameter such that further inferences can be made. A generic call signature *A* is ***instantiated in the context of*** non-generic call signature *B* as follows: -* Using the process described in [3.8.6](#3.8.6), inferences for *A*’s type parameters are made from each parameter type in *B* to the corresponding parameter type in *A* for those parameter positions that are present in both signatures, where rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. +* Using the process described in [3.8.6](#3.8.6), inferences for *A*'s type parameters are made from each parameter type in *B* to the corresponding parameter type in *A* for those parameter positions that are present in both signatures, where rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. * The inferred type argument for each type parameter is the union type of the set of inferences made for that type parameter. However, if the union type does not satisfy the constraint of the type parameter, the inferred type argument is instead the constraint. ### 3.8.6 Type Inference @@ -2023,7 +2022,7 @@ In certain contexts, inferences for a given set of type parameters are made *fro * If *T* is one of the type parameters for which inferences are being made, *S* is added to the set of inferences for that type parameter. * Otherwise, if *S* and *T* are references to the same generic type, inferences are made from each type argument in *S* to each corresponding type argument in *T*. * Otherwise, if *T* is a union type: - * First, inferences are made from *S* to each constituent type in *T* that isn’t simply one of the type parameters for which inferences are being made. + * First, inferences are made from *S* to each constituent type in *T* that isn't simply one of the type parameters for which inferences are being made. * If the first step produced no inferences and exactly one constituent type in *T* is simply a type parameter for which inferences are being made, inferences are made from *S* to that type parameter. * Otherwise, if *S* is a union type, inferences are made from each constituent type in *S* to *T*. * Otherwise, if *S* and *T* are object types, then for each member *M* in *T*: @@ -2044,7 +2043,7 @@ Classes and interfaces can reference themselves in their internal structure, in interface A { next: A; } ``` -contains an infinitely nested sequence of ‘next’ properties. Types such as this are perfectly valid but require special treatment when determining type relationships. Specifically, when comparing types *S* and *T* for a given relationship (identity, subtype, or assignability), the relationship in question is assumed to be true for every directly or indirectly nested occurrence of the same *S* and the same *T* (where same means originating in the same declaration and, if applicable, having identical type arguments). For example, consider the identity relationship between ‘A’ above and ‘B’ below: +contains an infinitely nested sequence of 'next' properties. Types such as this are perfectly valid but require special treatment when determining type relationships. Specifically, when comparing types *S* and *T* for a given relationship (identity, subtype, or assignability), the relationship in question is assumed to be true for every directly or indirectly nested occurrence of the same *S* and the same *T* (where same means originating in the same declaration and, if applicable, having identical type arguments). For example, consider the identity relationship between 'A' above and 'B' below: ```TypeScript interface B { next: C; } @@ -2054,7 +2053,7 @@ interface C { next: D; } interface D { next: B; } ``` -To determine whether ‘A’ and ‘B’ are identical, first the ‘next’ properties of type ‘A’ and ‘C’ are compared. That leads to comparing the ‘next’ properties of type ‘A’ and ‘D’, which leads to comparing the ‘next’ properties of type ‘A’ and ‘B’. Since ‘A’ and ‘B’ are already being compared this relationship is by definition true. That in turn causes the other comparisons to be true, and therefore the final result is true. +To determine whether 'A' and 'B' are identical, first the 'next' properties of type 'A' and 'C' are compared. That leads to comparing the 'next' properties of type 'A' and 'D', which leads to comparing the 'next' properties of type 'A' and 'B'. Since 'A' and 'B' are already being compared this relationship is by definition true. That in turn causes the other comparisons to be true, and therefore the final result is true. When this same technique is used to compare generic type references, two type references are considered the same when they originate in the same declaration and have identical type arguments. @@ -2068,7 +2067,7 @@ interface List { } ``` -‘List<T>’ has a member ‘owner’ of type ‘List<List<T>>’, which has a member ‘owner’ of type ‘List<List<List<T>>>’, which has a member ‘owner’ of type ‘List<List<List<List<T>>>>’ and so on, ad infinitum. Since type relationships are determined structurally, possibly exploring the constituent types to their full depth, in order to determine type relationships involving infinitely expanding generic types it may be necessary for the compiler to terminate the recursion at some point with the assumption that no further exploration will change the outcome. +'List<T>' has a member 'owner' of type 'List<List<T>>', which has a member 'owner' of type 'List<List<List<T>>>', which has a member 'owner' of type 'List<List<List<List<T>>>>' and so on, ad infinitum. Since type relationships are determined structurally, possibly exploring the constituent types to their full depth, in order to determine type relationships involving infinitely expanding generic types it may be necessary for the compiler to terminate the recursion at some point with the assumption that no further exploration will change the outcome. ## 3.9 Widened Types @@ -2078,7 +2077,7 @@ In several situations TypeScript infers types from context, alleviating the need var name = "Steve"; ``` -infers the type of ‘name’ to be the String primitive type since that is the type of the value used to initialize it. When inferring the type of a variable, property or function result from an expression, the ***widened*** form of the source type is used as the inferred type of the target. The widened form of a type is the type in which all occurrences of the Null and Undefined types have been replaced with the type `any`. +infers the type of 'name' to be the String primitive type since that is the type of the value used to initialize it. When inferring the type of a variable, property or function result from an expression, the ***widened*** form of the source type is used as the inferred type of the target. The widened form of a type is the type in which all occurrences of the Null and Undefined types have been replaced with the type `any`. The following example shows the results of widening types to produce inferred variable types. @@ -2093,9 +2092,9 @@ var d = [ null, undefined ]; // var d: any[] # 4 Expressions -This chapter describes the manner in which TypeScript provides type inference and type checking for JavaScript expressions. TypeScript’s type analysis occurs entirely at compile-time and adds no run-time overhead to expression evaluation. +This chapter describes the manner in which TypeScript provides type inference and type checking for JavaScript expressions. TypeScript's type analysis occurs entirely at compile-time and adds no run-time overhead to expression evaluation. -TypeScript’s typing rules define a type for every expression construct. For example, the type of the literal 123 is the Number primitive type, and the type of the object literal { a: 10, b: "hello" } is { a: number; b: string; }. The sections in this chapter describe these rules in detail. +TypeScript's typing rules define a type for every expression construct. For example, the type of the literal 123 is the Number primitive type, and the type of the object literal { a: 10, b: "hello" } is { a: number; b: string; }. The sections in this chapter describe these rules in detail. In addition to type inference and type checking, TypeScript augments JavaScript expressions with the following constructs: @@ -2145,7 +2144,7 @@ Literals are typed as follows: * The type of the literals `true` and `false` is the Boolean primitive type. * The type of numeric literals is the Number primitive type. * The type of string literals is the String primitive type. -* The type of regular expression literals is the global interface type ‘RegExp’. +* The type of regular expression literals is the global interface type 'RegExp'. ## 4.5 Object Literals @@ -2215,14 +2214,14 @@ Each element expression in a non-empty array literal is processed as follows: The resulting type an array literal expression is determined as follows: * If the array literal is empty, the resulting type is an array type with the element type Undefined. -* Otherwise, if the array literal is contextually typed by a type that has a property with the numeric name ‘0’, the resulting type is a tuple type constructed from the types of the element expressions. +* Otherwise, if the array literal is contextually typed by a type that has a property with the numeric name '0', the resulting type is a tuple type constructed from the types of the element expressions. * Otherwise, the resulting type is an array type with an element type that is the union of the types of the element expressions. The rules above mean that an array literal is always of an array type, unless it is contextually typed by a type with numerically named properties (such as a tuple type). For example ```TypeScript -var a = [1, 2]; // Array -var b = ["hello", true]; // Array +var a = [1, 2]; // number[] +var b = ["hello", true]; // (string | boolean)[] var c: [number, string] = [3, "three"]; // [number, string] ``` @@ -2241,7 +2240,7 @@ has the same type and classification as the contained expression itself. Specifi The `super` keyword can be used in expressions to reference base class properties and the base class constructor.   *CallExpression:* *( Modified )* -   … +   …    `super` `(` *ArgumentListopt* `)`    `super` `.` *IdentifierName* @@ -2276,7 +2275,7 @@ Function expressions are extended from JavaScript to optionally include paramete    `function` *Identifieropt* *CallSignature* `{` *FunctionBody* `}`   *AssignmentExpression:* *( Modified )* -   … +   …    *ArrowFunctionExpression*   *ArrowFunctionExpression:* @@ -2289,7 +2288,7 @@ Function expressions are extended from JavaScript to optionally include paramete The terms ***standard function expression*** and ***arrow function expression*** are used to refer to the *FunctionExpression* and *ArrowFunctionExpression* forms respectively. When referring to either, the generic term ***function expression*** is used. -The type of a function expression is an object type containing a single call signature with parameter and return types inferred from the function expression’s signature and body. +The type of a function expression is an object type containing a single call signature with parameter and return types inferred from the function expression's signature and body. The descriptions of function declarations provided in section [6.1](#6.1) apply to function expressions as well, except that function expressions do not support overloading. @@ -2354,7 +2353,7 @@ var messenger = new Messenger(); messenger.start(); ``` -the use of an arrow function expression causes the callback to have the same `this` as the surrounding ‘start’ method. Writing the callback as a standard function expression it becomes necessary to manually arrange access to the surrounding `this`, for example by copying it into a local variable: +the use of an arrow function expression causes the callback to have the same `this` as the surrounding 'start' method. Writing the callback as a standard function expression it becomes necessary to manually arrange access to the surrounding `this`, for example by copying it into a local variable: ```TypeScript class Messenger { @@ -2389,13 +2388,13 @@ Function expressions with no type parameters and no parameter type annotations ( When a function expression is contextually typed by a function type *T*, the function expression is processed as if it had explicitly specified parameter type annotations as they exist in *T*. Parameters are matched by position and need not have matching names. If the function expression has fewer parameters than *T*, the additional parameters in *T* are ignored. If the function expression has more parameters than *T*, the additional parameters are all considered to have type Any. -Furthermore, when a function expression has no return type annotation and is contextually typed by a function type *T*, expressions in contained return statements (section [5.7](#5.7)) are contextually typed by *T*’s return type. +Furthermore, when a function expression has no return type annotation and is contextually typed by a function type *T*, expressions in contained return statements (section [5.7](#5.7)) are contextually typed by *T*'s return type. ## 4.10 Property Access A property access uses either dot notation or bracket notation. A property access expression is always classified as a reference. -A property access uses an object’s apparent type (section [3.8.1](#3.8.1)) to determine its properties. Furthermore, in a property access, an object’s apparent type includes the properties that originate in the ‘Object’ or ‘Function’ global interface types, as described in section [3.3](#3.3). +A property access uses an object's apparent type (section [3.8.1](#3.8.1)) to determine its properties. Furthermore, in a property access, an object's apparent type includes the properties that originate in the 'Object' or 'Function' global interface types, as described in section [3.3](#3.3). A dot notation property access of the form @@ -2417,9 +2416,9 @@ object [ index ] where *object* and *index* are expressions, is used to access the property with the name computed by the index expression on the given object. A bracket notation property access is processed as follows at compile-time: -* If *index* is a string literal or a numeric literal and *object*’s apparent type has a property with the name given by that literal (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. -* Otherwise, if *object*’s apparent type has a numeric index signature and *index* is of type Any, the Number primitive type, or an enum type, the property access is of the type of that index signature. -* Otherwise, if *object*’s apparent type has a string index signature and *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature. +* If *index* is a string literal or a numeric literal and *object*'s apparent type has a property with the name given by that literal (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. +* Otherwise, if *object*'s apparent type has a numeric index signature and *index* is of type Any, the Number primitive type, or an enum type, the property access is of the type of that index signature. +* Otherwise, if *object*'s apparent type has a string index signature and *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature. * Otherwise, if *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. * Otherwise, the property access is invalid and a compile-time error occurs. @@ -2456,8 +2455,8 @@ new C < ... > ( ... ) where *C* is an expression. The first form is equivalent to supplying an empty argument list. *C* must be of type Any or of an object type with one or more construct or call signatures. The operation is processed as follows at compile-time: * If *C* is of type Any, any argument list is permitted and the result of the operation is of type Any. -* If *C*’s apparent type (section [3.8.1](#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 the result type of the operation. -* If *C*’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. +* If *C*'s apparent type (section [3.8.1](#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 the result type of the operation. +* If *C*'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. ## 4.12 Function Calls @@ -2477,11 +2476,11 @@ where *func* is an expression of a function type or of type Any. The function ex If *func* is of type Any, or of an object type that has no call or construct signatures but is a subtype of the Function interface, the call is an ***untyped function call***. In an untyped function call no type arguments are permitted, argument expressions can be of any type and number, no contextual types are provided for the argument expressions, and the result is always of type Any. -If *func*’s apparent type (section [3.8.1](#3.8.1)) is a function type, the call is a ***typed function call***. TypeScript employs ***overload resolution*** in typed function calls in order to support functions with multiple call signatures. Furthermore, TypeScript may perform ***type argument inference*** to automatically determine type arguments in generic function calls. +If *func*'s apparent type (section [3.8.1](#3.8.1)) is a function type, the call is a ***typed function call***. TypeScript employs ***overload resolution*** in typed function calls in order to support functions with multiple call signatures. Furthermore, TypeScript may perform ***type argument inference*** to automatically determine type arguments in generic function calls. ### 4.12.1 Overload Resolution -The purpose of overload resolution in a function call is to ensure that at least one signature is applicable, to provide contextual types for the arguments, and to determine the result type of the function call, which could differ between the multiple applicable signatures. Overload resolution has no impact on the run-time behavior of a function call. Since JavaScript doesn’t support function overloading, all that matters at run-time is the name of the function. +The purpose of overload resolution in a function call is to ensure that at least one signature is applicable, to provide contextual types for the arguments, and to determine the result type of the function call, which could differ between the multiple applicable signatures. Overload resolution has no impact on the run-time behavior of a function call. Since JavaScript doesn't support function overloading, all that matters at run-time is the name of the function. The compile-time processing of a typed function call consists of the following steps: @@ -2508,12 +2507,12 @@ A signature is said to be an ***applicable signature*** with respect to an argum ### 4.12.2 Type Argument Inference -Given a signature < *T1* , *T2* , … , *Tn* > ( *p1* : *P1* , *p2* : *P2* , … , *pm* : *Pm* ), where each parameter type *P* references zero or more of the type parameters *T*, and an argument list ( *e1* , *e2* , … , *em* ), the task of type argument inference is to find a set of type arguments *A1*…*An* to substitute for *T1*…*Tn* such that the argument list becomes an applicable signature. +Given a signature < *T1* , *T2* , … , *Tn* > ( *p1* : *P1* , *p2* : *P2* , … , *pm* : *Pm* ), where each parameter type *P* references zero or more of the type parameters *T*, and an argument list ( *e1* , *e2* , … , *em* ), the task of type argument inference is to find a set of type arguments *A1*…*An* to substitute for *T1*…*Tn* such that the argument list becomes an applicable signature. Type argument inference produces a set of candidate types for each type parameter. Given a type parameter *T* and set of candidate types, the actual inferred type argument is determined as follows: -* If the set of candidate argument types is empty, the inferred type argument for *T* is *T*’s constraint. -* Otherwise, if at least one of the candidate types is a supertype of all of the other candidate types, let *C* denote the first such candidate type. If *C* satisfies *T*’s constraint, the inferred type argument for *T* is *C*. Otherwise, the inferred type argument for *T* is *T*’s constraint. +* If the set of candidate argument types is empty, the inferred type argument for *T* is *T*'s constraint. +* Otherwise, if at least one of the candidate types is a supertype of all of the other candidate types, let *C* denote the first such candidate type. If *C* satisfies *T*'s constraint, the inferred type argument for *T* is *C*. Otherwise, the inferred type argument for *T* is *T*'s constraint. * Otherwise, if no candidate type is a supertype of all of the other candidate types, type inference has fails and no type argument is inferred for *T*. In order to compute candidate types, the argument list is processed as follows: @@ -2525,7 +2524,7 @@ The process of inferentially typing an expression *e* by a type *T* is the same * Where expressions contained within *e* would be contextually typed, they are instead inferentially typed. * When a function expression is inferentially typed (section [4.9.3](#4.9.3)) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, the corresponding inferred type arguments to become ***fixed*** and no further candidate inferences are made for them. -* If *e* is an expression of a function type that contains exactly one generic call signature and no other members, and *T* is a function type with exactly one non-generic call signature and no other members, then any inferences made for type parameters referenced by the parameters of *T*’s call signature are ***fixed***, and *e*’s type is changed to a function type with *e*’s call signature instantiated in the context of *T*’s call signature (section [3.8.5](#3.8.5)). +* If *e* is an expression of a function type that contains exactly one generic call signature and no other members, and *T* is a function type with exactly one non-generic call signature and no other members, then any inferences made for type parameters referenced by the parameters of *T*'s call signature are ***fixed***, and *e*'s type is changed to a function type with *e*'s call signature instantiated in the context of *T*'s call signature (section [3.8.5](#3.8.5)). An example: @@ -2538,13 +2537,13 @@ var x = choose(10, 20); // Ok, x of type number var y = choose("Five", 5); // Error ``` -In the first call to ‘choose’, two inferences are made from ‘number’ to ‘T’, one for each parameter. Thus, ‘number’ is inferred for ‘T’ and the call is equivalent to +In the first call to 'choose', two inferences are made from 'number' to 'T', one for each parameter. Thus, 'number' is inferred for 'T' and the call is equivalent to ```TypeScript var x = choose(10, 20); ``` -In the second call to ‘choose’, an inference is made from type ‘string’ to ‘T’ for the first parameter and an inference is made from type ‘number’ to ‘T’ for the second parameter. Since neither ‘string’ nor ‘number’ is a supertype of the other, type inference fails. That in turn means there are no applicable signatures and the function call is an error. +In the second call to 'choose', an inference is made from type 'string' to 'T' for the first parameter and an inference is made from type 'number' to 'T' for the second parameter. Since neither 'string' nor 'number' is a supertype of the other, type inference fails. That in turn means there are no applicable signatures and the function call is an error. In the example @@ -2559,13 +2558,13 @@ var names = ["Peter", "Paul", "Mary"]; var lengths = map(names, s => s.length); ``` -inferences for ‘T’ and ‘U’ in the call to ‘map’ are made as follows: For the first parameter, inferences are made from the type ‘string[]’ (the type of ‘names’) to the type ‘T[]’, inferring ‘string’ for ‘T’. For the second parameter, inferential typing of the arrow expression ‘s => s.length’ causes ‘T’ to become fixed such that the inferred type ‘string’ can be used for the parameter ‘s’. The return type of the arrow expression can then be determined, and inferences are made from the type ‘(s: string) => number’ to the type ‘(x: T) => U’, inferring ‘number’ for ‘U’. Thus the call to ‘map’ is equivalent to +inferences for 'T' and 'U' in the call to 'map' are made as follows: For the first parameter, inferences are made from the type 'string[]' (the type of 'names') to the type 'T[]', inferring 'string' for 'T'. For the second parameter, inferential typing of the arrow expression 's => s.length' causes 'T' to become fixed such that the inferred type 'string' can be used for the parameter 's'. The return type of the arrow expression can then be determined, and inferences are made from the type '(s: string) => number' to the type '(x: T) => U', inferring 'number' for 'U'. Thus the call to 'map' is equivalent to ```TypeScript var lengths = map(names, s => s.length); ``` -and the resulting type of ‘lengths’ is therefore ‘number[]’. +and the resulting type of 'lengths' is therefore 'number[]'. In the example @@ -2582,14 +2581,14 @@ var ages = [7, 9, 12]; var pairs = zip(names, ages, s => n => ({ name: s, age: n })); ``` -inferences for ‘S’, ‘T’ and ‘U’ in the call to ‘zip’ are made as follows: Using the first two parameters, inferences of ‘string’ for ‘S’ and ‘number’ for ‘T’ are made. For the third parameter, inferential typing of the outer arrow expression causes ‘S’ to become fixed such that the inferred type ‘string’ can be used for the parameter ‘s’. When a function expression is inferentially typed, its return expression(s) are also inferentially typed. Thus, the inner arrow function is inferentially typed, causing ‘T’ to become fixed such that the inferred type ‘number’ can be used for the parameter ‘n’. The return type of the inner arrow function can then be determined, which in turn determines the return type of the function returned from the outer arrow function, and inferences are made from the type ‘(s: string) => (n: number) => { name: string; age: number }’ to the type ‘(x: S) => (y: T) => R’, inferring ‘{ name: string; age: number }’ for ‘R’. Thus the call to ‘zip’ is equivalent to +inferences for 'S', 'T' and 'U' in the call to 'zip' are made as follows: Using the first two parameters, inferences of 'string' for 'S' and 'number' for 'T' are made. For the third parameter, inferential typing of the outer arrow expression causes 'S' to become fixed such that the inferred type 'string' can be used for the parameter 's'. When a function expression is inferentially typed, its return expression(s) are also inferentially typed. Thus, the inner arrow function is inferentially typed, causing 'T' to become fixed such that the inferred type 'number' can be used for the parameter 'n'. The return type of the inner arrow function can then be determined, which in turn determines the return type of the function returned from the outer arrow function, and inferences are made from the type '(s: string) => (n: number) => { name: string; age: number }' to the type '(x: S) => (y: T) => R', inferring '{ name: string; age: number }' for 'R'. Thus the call to 'zip' is equivalent to ```TypeScript var pairs = zip( names, ages, s => n => ({ name: s, age: n })); ``` -and the resulting type of ‘pairs’ is therefore ‘{ name: string; age: number }[]’. +and the resulting type of 'pairs' is therefore '{ name: string; age: number }[]'. ### 4.12.3 Grammar Ambiguities @@ -2599,32 +2598,32 @@ The inclusion of type arguments in the *Arguments* production (section [4.12](#4 f(g(7)); ``` -could be interpreted as a call to ‘f’ with two arguments, ‘g < A’ and ‘B > (7)’. Alternatively, it could be interpreted as a call to ‘f’ with one argument, which is a call to a generic function ‘g’ with two type arguments and one regular argument. +could be interpreted as a call to 'f' with two arguments, 'g < A' and 'B > (7)'. Alternatively, it could be interpreted as a call to 'f' with one argument, which is a call to a generic function 'g' with two type arguments and one regular argument. -The grammar ambiguity is resolved as follows: In a context where one possible interpretation of a sequence of tokens is an *Arguments* production, if the initial sequence of tokens forms a syntactically correct *TypeArguments* production and is followed by a ‘`(`‘ token, then the sequence of tokens is processed an *Arguments* production, and any other possible interpretation is discarded. Otherwise, the sequence of tokens is not considered an *Arguments* production. +The grammar ambiguity is resolved as follows: In a context where one possible interpretation of a sequence of tokens is an *Arguments* production, if the initial sequence of tokens forms a syntactically correct *TypeArguments* production and is followed by a '`(`' token, then the sequence of tokens is processed an *Arguments* production, and any other possible interpretation is discarded. Otherwise, the sequence of tokens is not considered an *Arguments* production. -This rule means that the call to ‘f’ above is interpreted as a call with one argument, which is a call to a generic function ‘g’ with two type arguments and one regular argument. However, the statements +This rule means that the call to 'f' above is interpreted as a call with one argument, which is a call to a generic function 'g' with two type arguments and one regular argument. However, the statements ```TypeScript f(g < A, B > 7); f(g < A, B > +(7)); ``` -are both interpreted as calls to ‘f’ with two arguments. +are both interpreted as calls to 'f' with two arguments. ## 4.13 Type Assertions TypeScript extends the JavaScript expression grammar with the ability to assert a type for an expression:   *UnaryExpression:* *( Modified )* -   … +   …    `<` *Type* `>` *UnaryExpression* A type assertion expression consists of a type enclosed in `<` and `>` followed by a unary expression. Type assertion expressions are purely a compile-time construct. Type assertions are *not* checked at run-time and have no impact on the emitted JavaScript (and therefore no run-time cost). The type and the enclosing `<` and `>` are simply removed from the generated code. In a type assertion expression of the form `<` *T* `>` *e*, *e* is contextually typed (section [4.19](#4.19)) by *T* and the resulting type of* e* is required to be assignable to *T*, or *T* is required to be assignable to the widened form of the resulting type of *e*, or otherwise a compile-time error occurs. The type of the result is *T*. -Type assertions check for assignment compatibility in both directions. Thus, type assertions allow type conversions that *might* be correct, but aren’t *known* to be correct. In the example +Type assertions check for assignment compatibility in both directions. Thus, type assertions allow type conversions that *might* be correct, but aren't *known* to be correct. In the example ```TypeScript class Shape { ... } @@ -2639,7 +2638,7 @@ function createShape(kind: string): Shape { var circle = createShape("circle"); ``` -the type annotations indicate that the ‘createShape’ function *might* return a ‘Circle’ (because ‘Circle’ is a subtype of ‘Shape’), but isn’t *known* to do so (because its return type is ‘Shape’). Therefore, a type assertion is needed to treat the result as a ‘Circle’. +the type annotations indicate that the 'createShape' function *might* return a 'Circle' (because 'Circle' is a subtype of 'Shape'), but isn't *known* to do so (because its return type is 'Shape'). Therefore, a type assertion is needed to treat the result as a 'Circle'. As mentioned above, type assertions are not checked at run-time and it is up to the programmer to guard against errors, for example using the `instanceof` operator: @@ -2659,7 +2658,7 @@ The subsections that follow specify the compile-time processing rules of the una These operators, in prefix or postfix form, require their operand to be of type Any, the Number primitive type, or an enum type, and classified as a reference (section [4.1](#4.1)). They produce a result of the Number primitive type. -### 4.14.2 The +, –, and ~ operators +### 4.14.2 The +, –, and ~ operators These operators permit their operand to be of any type and produce a result of the Number primitive type. @@ -2671,7 +2670,7 @@ function getValue() { ... } var n = +getValue(); ``` -The example above converts the result of ‘getValue()’ to a number if it isn’t a number already. The type inferred for ‘n’ is the Number primitive type regardless of the return type of ‘getValue’. +The example above converts the result of 'getValue()' to a number if it isn't a number already. The type inferred for 'n' is the Number primitive type regardless of the return type of 'getValue'. ### 4.14.3 The ! operator @@ -2685,19 +2684,19 @@ function getValue() { ... } var b = !!getValue(); ``` -The example above converts the result of ‘getValue()’ to a Boolean if it isn’t a Boolean already. The type inferred for ‘b’ is the Boolean primitive type regardless of the return type of ‘getValue’. +The example above converts the result of 'getValue()' to a Boolean if it isn't a Boolean already. The type inferred for 'b' is the Boolean primitive type regardless of the return type of 'getValue'. ### 4.14.4 The delete Operator -The ‘delete’ operator takes an operand of any type and produces a result of the Boolean primitive type. +The 'delete' operator takes an operand of any type and produces a result of the Boolean primitive type. ### 4.14.5 The void Operator -The ‘void’ operator takes an operand of any type and produces the value ‘undefined’. The type of the result is the Undefined type ([3.2.6](#3.2.6)). +The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type ([3.2.6](#3.2.6)). ### 4.14.6 The typeof Operator -The ‘typeof’ operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, ‘typeof’ can also be used in a type query (section [3.6.9](#3.6.9)) to produce the type of an expression. +The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query (section [3.6.9](#3.6.9)) to produce the type of an expression. ```TypeScript var x = 5; @@ -2705,13 +2704,13 @@ var y = typeof x; // Use in an expression var z: typeof x; // Use in a type query ``` -In the example above, ‘x’ is of type ‘number’, ‘y’ is of type ‘string’ because when used in an expression, ‘typeof’ produces a value of type string (in this case the string “number”), and ‘z’ is of type ‘number’ because when used in a type query, ‘typeof’ obtains the type of an expression. +In the example above, 'x' is of type 'number', 'y' is of type 'string' because when used in an expression, 'typeof' produces a value of type string (in this case the string "number"), and 'z' is of type 'number' because when used in a type query, 'typeof' obtains the type of an expression. ## 4.15 Binary Operators The subsections that follow specify the compile-time processing rules of the binary operators. In general, if the operands of a binary operator do not meet the stated requirements, a compile-time error occurs and the result of the operation defaults to type any in further processing. Tables that summarize the compile-time processing rules for operands of the Any type, the Boolean, Number, and String primitive types, and all object types and type parameters (the Object column in the tables) are provided. -### 4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators +### 4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators These operators require their operands to be of type Any, the Number primitive type, or an enum type. Operands of an enum type are treated as having the primitive type Number. If one operand is the `null` or `undefined` value, it is treated as having the type of the other operand. The result is always of the Number primitive type. @@ -2743,7 +2742,7 @@ function getValue() { ... } var s = getValue() + ""; ``` -The example above converts the result of ‘getValue()’ to a string if it isn’t a string already. The type inferred for ‘s’ is the String primitive type regardless of the return type of ‘getValue’. +The example above converts the result of 'getValue()' to a string if it isn't a string already. The type inferred for 's' is the String primitive type regardless of the return type of 'getValue'. ### 4.15.3 The <, >, <=, >=, ==, !=, ===, and !== operators @@ -2759,9 +2758,9 @@ These operators require one operand type to be identical to or a subtype of the ### 4.15.4 The instanceof operator -The `instanceof` operator requires the left operand to be of type Any, an object type, or a type parameter type, and the right operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the Boolean primitive type. +The `instanceof` operator requires the left operand to be of type Any, an object type, or a type parameter type, and the right operand to be of type Any or a subtype of the 'Function' interface type. The result is always of the Boolean primitive type. -Note that object types containing one or more call or construct signatures are automatically subtypes of the ‘Function’ interface type, as described in section [3.3](#3.3). +Note that object types containing one or more call or construct signatures are automatically subtypes of the 'Function' interface type, as described in section [3.3](#3.3). ### 4.15.5 The in operator @@ -2851,10 +2850,10 @@ the assignment f = function(s) { return s.toLowerCase(); } ``` -infers the type of the ‘s’ parameter to be the String primitive type even though there is no type annotation to that effect. The function expression is said to be ***contextually typed*** by the variable to which it is being assigned. Contextual typing occurs in the following situations: +infers the type of the 's' parameter to be the String primitive type even though there is no type annotation to that effect. The function expression is said to be ***contextually typed*** by the variable to which it is being assigned. Contextual typing occurs in the following situations: * In variable, parameter, and member declarations with a type annotation and an initializer, the initializer expression is contextually typed by the type of the variable, parameter, or property. -* In return statements, if the containing function includes a return type annotation, return expressions are contextually typed by that return type. Otherwise, if the containing function is contextually typed by a type *T*, return expressions are contextually typed by *T*’s return type. +* In return statements, if the containing function includes a return type annotation, return expressions are contextually typed by that return type. Otherwise, if the containing function is contextually typed by a type *T*, return expressions are contextually typed by *T*'s return type. * In typed function calls, argument expressions are contextually typed by their parameter types. * In type assertions, the expression is contextually typed by the indicated type. * In || operator expressions without a contextual type, the right hand expression is contextually typed by the type of the left hand expression. @@ -2868,24 +2867,24 @@ Contextual typing of an expression *e* by a type *T* proceeds as follows: * If *e* is an *ObjectLiteral* and *T* is an object type, *e* is processed with the contextual type *T*, as described in section [4.5](#4.5). * If *e* is an *ArrayLiteral* and *T* is an object type with a numeric index signature, *e* is processed with the contextual type *T*, as described in section [4.6](#4.6). -* If *e* is a *FunctionExpression* or *ArrowFunctionExpression* with no type parameters and no parameter type annotations, *T* is a function type with exactly one call signature and *T*’s call signature is non-generic, then any inferences made for type parameters referenced by the parameters of *T*’s call signature are fixed (section [4.12.2](#4.12.2)) and *e* is processed with the contextual type *T*, as described in section [4.9.3](#4.9.3). +* If *e* is a *FunctionExpression* or *ArrowFunctionExpression* with no type parameters and no parameter type annotations, *T* is a function type with exactly one call signature and *T*'s call signature is non-generic, then any inferences made for type parameters referenced by the parameters of *T*'s call signature are fixed (section [4.12.2](#4.12.2)) and *e* is processed with the contextual type *T*, as described in section [4.9.3](#4.9.3). * If *e* is a || operator expression and *T* is an object type, *e* is processed with the contextual type *T*, as described in section [4.15.7](#4.15.7). * If *e* is a conditional operator expression and *T* is an object type, *e* is processed with the contextual type *T*, as described in section [4.16](#4.16). * Otherwise, *e* is processed without a contextual type. -The rules above require expressions be of the exact syntactic forms specified in order to be processed as contextually typed constructs. For example, given the declaration of the variable ‘f’ above, the assignment +The rules above require expressions be of the exact syntactic forms specified in order to be processed as contextually typed constructs. For example, given the declaration of the variable 'f' above, the assignment ```TypeScript f = s => s.toLowerCase(); ``` -causes the function expression to be contextually typed, inferring the String primitive type for ‘s’. However, simply enclosing the construct in parentheses +causes the function expression to be contextually typed, inferring the String primitive type for 's'. However, simply enclosing the construct in parentheses ```TypeScript f = (s => s.toLowerCase()); ``` -causes the function expression to be processed without a contextual type, now inferring ‘s’ and the result of the function to be of type Any as no type annotations are present. +causes the function expression to be processed without a contextual type, now inferring 's' and the result of the function to be of type Any as no type annotations are present. In the following example @@ -2909,11 +2908,11 @@ setEventHandlers({ }); ``` -the object literal passed to ‘setEventHandlers’ is contextually typed to the ‘EventHandlers’ type. This causes the two property assignments to be contextually typed to the unnamed function type ‘(event: EventObject) => void’, which in turn causes the ‘e’ parameters in the arrow function expressions to automatically be typed as ‘EventObject’. +the object literal passed to 'setEventHandlers' is contextually typed to the 'EventHandlers' type. This causes the two property assignments to be contextually typed to the unnamed function type '(event: EventObject) => void', which in turn causes the 'e' parameters in the arrow function expressions to automatically be typed as 'EventObject'. ## 4.20 Type Guards -Type guards are particular expression patterns involving the ‘typeof’ and ‘instanceof’ operators that cause the types of variables or parameters to be ***narrowed*** to more specific types. For example, in the code below, knowledge of the static type of ‘x’ in combination with a ‘typeof’ check makes it safe to narrow the type of ‘x’ to string in the first branch of the ‘if’ statement and number in the second branch of the ‘if’ statement. +Type guards are particular expression patterns involving the 'typeof' and 'instanceof' operators that cause the types of variables or parameters to be ***narrowed*** to more specific types. For example, in the code below, knowledge of the static type of 'x' in combination with a 'typeof' check makes it safe to narrow the type of 'x' to string in the first branch of the 'if' statement and number in the second branch of the 'if' statement. ```TypeScript function foo(x: number | string) { @@ -2928,8 +2927,8 @@ function foo(x: number | string) { The type of a variable or parameter is narrowed in the following situations: -* In the true branch statement of an ‘if’ statement, the type of a variable or parameter is *narrowed* by any type guard in the ‘if’ condition *when true*, provided the true branch statement contains no assignments to the variable or parameter. -* In the false branch statement of an ‘if’ statement, the type of a variable or parameter is *narrowed* by any type guard in the ‘if’ condition *when false*, provided the false branch statement contains no assignments to the variable or parameter. +* In the true branch statement of an 'if' statement, the type of a variable or parameter is *narrowed* by any type guard in the 'if' condition *when true*, provided the true branch statement contains no assignments to the variable or parameter. +* In the false branch statement of an 'if' statement, the type of a variable or parameter is *narrowed* by any type guard in the 'if' condition *when false*, provided the false branch statement contains no assignments to the variable or parameter. * In the true expression of a conditional expression, the type of a variable or parameter is *narrowed* by any type guard in the condition *when true*, provided the true expression contains no assignments to the variable or parameter. * In the false expression of a conditional expression, the type of a variable or parameter is *narrowed* by any type guard in the condition *when false*, provided the false expression contains no assignments to the variable or parameter. * In the right operand of a && operation, the type of a variable or parameter is *narrowed* by any type guard in the left operand *when true*, provided the right operand contains no assignments to the variable or parameter. @@ -2937,13 +2936,13 @@ The type of a variable or parameter is narrowed in the following situations: A type guard is simply an expression that follows a particular pattern. The process of narrowing the type of a variable *x* by a type guard *when true* or *when false* depends on the type guard as follows: -* A type guard of the form `x instanceof C`, where *C* is of a subtype of the global type ‘Function’ and *C* has a property named ‘prototype’ - * *when true*, narrows the type of *x* to the type of the ‘prototype’ property in *C* provided it is a subtype of the type of *x*, or +* A type guard of the form `x instanceof C`, where *C* is of a subtype of the global type 'Function' and *C* has a property named 'prototype' + * *when true*, narrows the type of *x* to the type of the 'prototype' property in *C* provided it is a subtype of the type of *x*, or * *when false*, has no effect on the type of *x*. -* A type guard of the form `typeof x === s`, where *s* is a string literal with the value ‘string’, ‘number’, or ‘boolean’, +* A type guard of the form `typeof x === s`, where *s* is a string literal with the value 'string', 'number', or 'boolean', * *when true*, narrows the type of *x* to the given primitive type, or * *when false*, removes the primitive type from the type of *x*. -* A type guard of the form `typeof x === s`, where *s* is a string literal with any value but ‘string’, ‘number’, or ‘boolean’, +* A type guard of the form `typeof x === s`, where *s* is a string literal with any value but 'string', 'number', or 'boolean', * *when true*, removes the primitive types string, number, and boolean from the type of *x*, or * *when false*, has no effect on the type of *x*. * A type guard of the form `typeof x !== s`, where *s* is a string literal, @@ -2962,7 +2961,7 @@ A type guard is simply an expression that follows a particular pattern. The proc A primitive type *P* is removed from a type *T* as follows: -* If *T* is a union type *P* | *T1* | *T2* | … | *Tn*, the result is the type *T1* | *T2* | … | *Tn*. +* If *T* is a union type *P* | *T1* | *T2* | … | *Tn*, the result is the type *T1* | *T2* | … | *Tn*. * Otherwise, the result is *T*. Note that type guards affect types of variables and parameters only and have no effect on members of objects such as properties. Also note that it is possible to defeat a type guard by calling a function that changes the type of the guarded variable. @@ -2975,7 +2974,7 @@ function isLongString(obj: any) { } ``` -the ‘obj’ parameter has type string in the right operand of the && operator. +the 'obj' parameter has type string in the right operand of the && operator. In the example @@ -2990,7 +2989,7 @@ function f(x: string | number | boolean) { } ``` -the type of ‘x’ is string | number | boolean in left operand of the || operator, number | boolean in the right operand of the || operator, string | number in the first branch of the ‘if’ statement, and boolean in the second branch of the ‘if’ statement. +the type of 'x' is string | number | boolean in left operand of the || operator, number | boolean in the right operand of the || operator, string | number in the first branch of the 'if' statement, and boolean in the second branch of the 'if' statement. In the example @@ -3001,7 +3000,7 @@ function processData(data: string | { (): string }) { } ``` -the inferred type of ‘d’ is string. +the inferred type of 'd' is string. In the example @@ -3015,7 +3014,7 @@ function getName(obj: any) { } ``` -the inferred type of the ‘getName’ function is string. +the inferred type of the 'getName' function is string.
@@ -3039,7 +3038,7 @@ Variable statements are extended to include optional type annotations. A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable is determined as follows: * If the declaration includes a type annotation, the stated type becomes the type of the variable. If an initializer is present, the initializer expression is contextually typed (section [4.19](#4.19)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. -* If the declaration includes an initializer but no type annotation, and if the initializer doesn’t directly or indirectly reference the variable, the widened type (section [3.9](#3.9)) of the initializer expression becomes the type of the variable. If the initializer directly or indirectly references the variable, the type of the variable becomes the Any type. +* If the declaration includes an initializer but no type annotation, and if the initializer doesn't directly or indirectly reference the variable, the widened type (section [3.9](#3.9)) of the initializer expression becomes the type of the variable. If the initializer directly or indirectly references the variable, the type of the variable becomes the Any type. * If the declaration includes neither a type annotation nor an initializer, the type of the variable becomes the Any type. Multiple declarations for the same variable name in the same declaration space are permitted, provided that each declaration associates the same type with the variable. @@ -3054,7 +3053,7 @@ var d = { x: 1, y: "hello" }; // { x: number; y: string; } var e: any = "test"; // any ``` -The following is permitted because all declarations of the single variable ‘x’ associate the same type (Number) with ‘x’. +The following is permitted because all declarations of the single variable 'x' associate the same type (Number) with 'x'. ```TypeScript var x = 1; @@ -3064,7 +3063,7 @@ if (x == 1) { } ``` -In the following example, all five variables are of the same type, ‘{ x: number; y: number; }’. +In the following example, all five variables are of the same type, '{ x: number; y: number; }'. ```TypeScript interface Point { x: number; y: number; } @@ -3078,15 +3077,15 @@ var e = <{ x: number; y: number; }> { x: 0, y: undefined }; ##
5.2 If, Do, and While Statements -Expressions controlling ‘if’, ‘do’, and ‘while’ statements can be of any type (and not just type Boolean). +Expressions controlling 'if', 'do', and 'while' statements can be of any type (and not just type Boolean). ## 5.3 For Statements -Variable declarations in ‘for’ statements are extended in the same manner as variable declarations in variable statements (section [5.1](#5.1)). +Variable declarations in 'for' statements are extended in the same manner as variable declarations in variable statements (section [5.1](#5.1)). ## 5.4 For-In Statements -In a ‘for-in’ statement of the form +In a 'for-in' statement of the form ```TypeScript for (v in expr) statement @@ -3094,7 +3093,7 @@ for (v in expr) statement *v* must be an expression classified as a reference of type Any or the String primitive type, and *expr* must be an expression of type Any, an object type, or a type parameter type. -In a ‘for-in’ statement of the form +In a 'for-in' statement of the form ```TypeScript for (var v in expr) statement @@ -3104,21 +3103,21 @@ for (var v in expr) statement ## 5.5 Continue Statements -A ‘continue’ statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration (‘do’, ‘while’, ‘for’, or ‘for-in’) statement. When a ‘continue’ statement includes a target label, that target label must appear in the label set of an enclosing (but not crossing function boundaries) iteration statement. +A 'continue' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') statement. When a 'continue' statement includes a target label, that target label must appear in the label set of an enclosing (but not crossing function boundaries) iteration statement. ## 5.6 Break Statements -A ‘break’ statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration (‘do’, ‘while’, ‘for’, or ‘for-in’) or ‘switch’ statement. When a ‘break’ statement includes a target label, that target label must appear in the label set of an enclosing (but not crossing function boundaries) statement. +A 'break' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') or 'switch' statement. When a 'break' statement includes a target label, that target label must appear in the label set of an enclosing (but not crossing function boundaries) statement. ## 5.7 Return Statements -It is an error for a ‘return’ statement to occur outside a function body. Specifically, ‘return’ statements are not permitted at the global level or in module bodies. +It is an error for a 'return' statement to occur outside a function body. Specifically, 'return' statements are not permitted at the global level or in module bodies. -A ‘return’ statement without an expression returns the value ‘undefined’ and is permitted in the body of any function, regardless of the return type of the function. +A 'return' statement without an expression returns the value 'undefined' and is permitted in the body of any function, regardless of the return type of the function. -When a ‘return’ statement includes an expression, if the containing function includes a return type annotation, the return expression is contextually typed (section [4.19](#4.19)) by that return type and must be of a type that is assignable to the return type. Otherwise, if the containing function is contextually typed by a type *T*, *Expr* is contextually typed by *T*’s return type. +When a 'return' statement includes an expression, if the containing function includes a return type annotation, the return expression is contextually typed (section [4.19](#4.19)) by that return type and must be of a type that is assignable to the return type. Otherwise, if the containing function is contextually typed by a type *T*, *Expr* is contextually typed by *T*'s return type. -In a function implementation without a return type annotation, the return type is inferred from the ‘return’ statements in the function body, as described in section [6.3](#6.3). +In a function implementation without a return type annotation, the return type is inferred from the 'return' statements in the function body, as described in section [6.3](#6.3). In the example @@ -3128,23 +3127,23 @@ function f(): (x: string) => number { } ``` -the arrow expression in the ‘return’ statement is contextually typed by the return type of ‘f’, thus giving type ‘string’ to ‘s’. +the arrow expression in the 'return' statement is contextually typed by the return type of 'f', thus giving type 'string' to 's'. ## 5.8 With Statements -Use of the ‘with’ statement in TypeScript is an error, as is the case in ECMAScript 5’s strict mode. Furthermore, within the body of a ‘with’ statement, TypeScript considers every identifier occurring in an expression (section [4.3](#4.3)) to be of the Any type regardless of its declared type. Because the ‘with’ statement puts a statically unknown set of identifiers in scope in front of those that are statically known, it is not possible to meaningfully assign a static type to any identifier. +Use of the 'with' statement in TypeScript is an error, as is the case in ECMAScript 5's strict mode. Furthermore, within the body of a 'with' statement, TypeScript considers every identifier occurring in an expression (section [4.3](#4.3)) to be of the Any type regardless of its declared type. Because the 'with' statement puts a statically unknown set of identifiers in scope in front of those that are statically known, it is not possible to meaningfully assign a static type to any identifier. ## 5.9 Switch Statements -In a ‘switch’ statement, each ‘case’ expression must be of a type that is assignable to or from (section [3.8.4](#3.8.4)) the type of the ‘switch’ expression. +In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section [3.8.4](#3.8.4)) the type of the 'switch' expression. ## 5.10 Throw Statements -The expression specified in a ‘throw’ statement can be of any type. +The expression specified in a 'throw' statement can be of any type. ## 5.11 Try Statements -The variable introduced by a ‘catch’ clause of a ‘try’ statement is always of type Any. It is not possible to include a type annotation in a ‘catch’ clause. +The variable introduced by a 'catch' clause of a 'try' statement is always of type Any. It is not possible to include a type annotation in a 'catch' clause.
@@ -3173,7 +3172,7 @@ A function declaration introduces a function with the given name in the containi ##
6.2 Function Overloads -Function overloads allow a more accurate specification of the patterns of invocation supported by a function than is possible with a single signature. The compile-time processing of a call to an overloaded function chooses the best candidate overload for the particular arguments and the return type of that overload becomes the result type the function call expression. Thus, using overloads it is possible to statically describe the manner in which a function’s return type varies based on its arguments. Overload resolution in function calls is described further in section [4.12](#4.12). +Function overloads allow a more accurate specification of the patterns of invocation supported by a function than is possible with a single signature. The compile-time processing of a call to an overloaded function chooses the best candidate overload for the particular arguments and the return type of that overload becomes the result type the function call expression. Thus, using overloads it is possible to statically describe the manner in which a function's return type varies based on its arguments. Overload resolution in function calls is described further in section [4.12](#4.12). Function overloads are purely a compile-time construct. They have no impact on the emitted JavaScript and thus no run-time cost. @@ -3195,7 +3194,7 @@ function attr(nameOrMap: any, value?: string): any { } ``` -Note that each overload and the final implementation specify the same identifier. The type of the local variable ‘attr’ introduced by this declaration is +Note that each overload and the final implementation specify the same identifier. The type of the local variable 'attr' introduced by this declaration is ```TypeScript var attr: { @@ -3211,8 +3210,8 @@ Note that the signature of the actual function implementation is not included in A function implementation without a return type annotation is said to be an ***implicitly typed function***. The return type of an implicitly typed function *f* is inferred from its function body as follows: -* If there are no return statements with expressions in *f*’s function body, the inferred return type is Void. -* Otherwise, if *f*’s function body directly references *f* or references any implicitly typed functions that through this same analysis reference *f*, the inferred return type is Any. +* If there are no return statements with expressions in *f*'s function body, the inferred return type is Void. +* Otherwise, if *f*'s function body directly references *f* or references any implicitly typed functions that through this same analysis reference *f*, the inferred return type is Any. * Otherwise, if *f* is a contextually typed function expression (section [4.9.3](#4.9.3)), the inferred return type is the union type (section [3.3.4](#3.3.4)) of the types of the return statement expressions in the function body, ignoring return statements with no expressions. * Otherwise, the inferred return type is the first of the types of the return statement expressions in the function body that is a supertype (section [3.8.3](#3.8.3)) of each of the others, ignoring return statements with no expressions. A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. @@ -3229,11 +3228,11 @@ function g(x: number) { } ``` -the inferred return type for ‘f’ and ‘g’ is Any because the functions reference themselves through a cycle with no return type annotations. Adding an explicit return type ‘number’ to either breaks the cycle and causes the return type ‘number’ to be inferred for the other. +the inferred return type for 'f' and 'g' is Any because the functions reference themselves through a cycle with no return type annotations. Adding an explicit return type 'number' to either breaks the cycle and causes the return type 'number' to be inferred for the other. -An explicitly typed function whose return type isn’t the Void or the Any type must have at least one return statement somewhere in its body. An exception to this rule is if the function implementation consists of a single ‘throw’ statement. +An explicitly typed function whose return type isn't the Void or the Any type must have at least one return statement somewhere in its body. An exception to this rule is if the function implementation consists of a single 'throw' statement. -The type of ‘this’ in a function implementation is the Any type. +The type of 'this' in a function implementation is the Any type. In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed (section [4.19](#4.19)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. When a parameter declaration has no type annotation but includes an initializer, the type of the parameter is the widened form (section [3.9](#3.9)) of the type of the initializer expression. @@ -3266,11 +3265,11 @@ function f(a = x) { } ``` -the local variable ‘x’ is in scope in the parameter initializer (thus hiding the outer ‘x’), but it is an error to reference it because it will always be uninitialized at the time the parameter initializer is evaluated. +the local variable 'x' is in scope in the parameter initializer (thus hiding the outer 'x'), but it is an error to reference it because it will always be uninitialized at the time the parameter initializer is evaluated. ## 6.4 Generic Functions -A function implementation may include type parameters in its signature (section [3.7.2.1](#3.7.2.1)) and is then called a ***generic function***. Type parameters provide a mechanism for expressing relationships between parameter and return types in call operations. Type parameters have no run-time representation—they are purely a compile-time construct. +A function implementation may include type parameters in its signature (section [3.7.2.1](#3.7.2.1)) and is then called a ***generic function***. Type parameters provide a mechanism for expressing relationships between parameter and return types in call operations. Type parameters have no run-time representation—they are purely a compile-time construct. Type parameters declared in the signature of a function implementation are in scope in the signature and body of that function implementation. @@ -3288,7 +3287,7 @@ function compare(x: T, y: T): number { } ``` -Note that the ‘x’ and ‘y’ parameters are known to be subtypes of the constraint ‘Comparable’ and therefore have a ‘compareTo’ member. This is described further in section [3.4.1](#3.4.1). +Note that the 'x' and 'y' parameters are known to be subtypes of the constraint 'Comparable' and therefore have a 'compareTo' member. This is described further in section [3.4.1](#3.4.1). The type arguments of a call to a generic function may be explicitly specified in a call operation or may, when possible, be inferred (section [4.12.2](#4.12.2)) from the types of the regular arguments in the call. In the example @@ -3301,7 +3300,7 @@ class Person { } ``` -the type argument to ‘compare’ is automatically inferred to be the String type because the two arguments are strings. +the type argument to 'compare' is automatically inferred to be the String type because the two arguments are strings. ## 6.5 Code Generation @@ -3316,7 +3315,7 @@ function () { *FunctionName* is the name of the function (or nothing in the case of a function expression). -*FunctionParameters* is a comma separated list of the function’s parameter names. +*FunctionParameters* is a comma separated list of the function's parameter names. *DefaultValueAssignments* is a sequence of default property value assignments, one for each parameter with a default value, in the order they are declared, of the form @@ -3334,7 +3333,7 @@ where *Parameter* is the parameter name and *Default* is the default value expre Interfaces provide the ability to name and parameterize object types and to compose existing named object types into new ones. -Interfaces have no run-time representation—they are purely a compile-time construct. Interfaces are particularly useful for documenting and validating the required shape of properties, objects passed as parameters, and objects returned from functions. +Interfaces have no run-time representation—they are purely a compile-time construct. Interfaces are particularly useful for documenting and validating the required shape of properties, objects passed as parameters, and objects returned from functions. Because TypeScript has a structural type system, an interface type with a particular set of members is considered identical to, and can be substituted for, another interface type or object type literal with an identical set of members (see section [3.8.2](#3.8.2)). @@ -3363,7 +3362,7 @@ An interface may optionally have type parameters (section [3.4.1](#3.4.1)) that An interface can inherit from zero or more ***base types*** which are specified in the *InterfaceExtendsClause*. The base types must be type references to class or interface types. -An interface has the members specified in the *ObjectType* of its declaration and furthermore inherits all base type members that aren’t hidden by declarations in the interface: +An interface has the members specified in the *ObjectType* of its declaration and furthermore inherits all base type members that aren't hidden by declarations in the interface: * A property declaration hides a public base type property with the same name. * A string index signature declaration hides a base type string index signature. @@ -3393,7 +3392,7 @@ interface Shaker { } ``` -An interface that extends ‘Mover’ and ‘Shaker’ must declare a new ‘getStatus’ property as it would otherwise inherit two ‘getStatus’ properties with different types. The new ‘getStatus’ property must be declared such that the resulting ‘MoverShaker’ is a subtype of both ‘Mover’ and ‘Shaker’: +An interface that extends 'Mover' and 'Shaker' must declare a new 'getStatus' property as it would otherwise inherit two 'getStatus' properties with different types. The new 'getStatus' property must be declared such that the resulting 'MoverShaker' is a subtype of both 'Mover' and 'Shaker': ```TypeScript interface MoverShaker extends Mover, Shaker { @@ -3407,11 +3406,11 @@ Since function and constructor types are just object types containing call and c interface StringComparer { (a: string, b: string): number; } ``` -This declares type ‘StringComparer’ to be a function type taking two strings and returning a number. +This declares type 'StringComparer' to be a function type taking two strings and returning a number. ## 7.2 Declaration Merging -Interfaces are “open-ended” and interface declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) contribute to a single interface. +Interfaces are "open-ended" and interface declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) contribute to a single interface. When a generic interface has multiple declarations, all declarations must have identical type parameter lists, i.e. identical type parameter names with identical constraints in identical order. @@ -3478,13 +3477,13 @@ class Location { } ``` -In the above example, ‘SelectableControl’ contains all of the members of ‘Control’, including the private ‘state’ property. Since ‘state’ is a private member it is only possible for descendants of ‘Control’ to implement ‘SelectableControl’. This is because only descendants of ‘Control’ will have a ‘state’ private member that originates in the same declaration, which is a requirement for private members to be compatible (section [3.8](#3.8)). +In the above example, 'SelectableControl' contains all of the members of 'Control', including the private 'state' property. Since 'state' is a private member it is only possible for descendants of 'Control' to implement 'SelectableControl'. This is because only descendants of 'Control' will have a 'state' private member that originates in the same declaration, which is a requirement for private members to be compatible (section [3.8](#3.8)). -Within the ‘Control’ class it is possible to access the ‘state’ private member through an instance of ‘SelectableControl’. Effectively, a ‘SelectableControl’ acts like a ‘Control’ that is known to have a ‘select’ method. The ‘Button’ and ‘TextBox’ classes are subtypes of ‘SelectableControl’ (because they both inherit from ‘Control’ and have a ‘select’ method), but the ‘Image’ and ‘Location’ classes are not. +Within the 'Control' class it is possible to access the 'state' private member through an instance of 'SelectableControl'. Effectively, a 'SelectableControl' acts like a 'Control' that is known to have a 'select' method. The 'Button' and 'TextBox' classes are subtypes of 'SelectableControl' (because they both inherit from 'Control' and have a 'select' method), but the 'Image' and 'Location' classes are not. ## 7.4 Dynamic Type Checks -TypeScript does not provide a direct mechanism for dynamically testing whether an object implements a particular interface. Instead, TypeScript code can use the JavaScript technique of checking whether an appropriate set of members are present on the object. For example, given the declarations in section [7.1](#7.1), the following is a dynamic check for the ‘MoverShaker’ interface: +TypeScript does not provide a direct mechanism for dynamically testing whether an object implements a particular interface. Instead, TypeScript code can use the JavaScript technique of checking whether an appropriate set of members are present on the object. For example, given the declarations in section [7.1](#7.1), the following is a dynamic check for the 'MoverShaker' interface: ```TypeScript var obj: any = getSomeObject(); @@ -3508,7 +3507,7 @@ function asMoverShaker(obj: any): MoverShaker { TypeScript supports classes that are closely aligned with those proposed for ECMAScript 6, and includes extensions for instance and static member declarations and properties declared and initialized from constructor parameters. -*NOTE: TypeScript currently doesn’t support class expressions or nested class declarations from the ECMAScript 6 proposal*. +*NOTE: TypeScript currently doesn't support class expressions or nested class declarations from the ECMAScript 6 proposal*. ## 8.1 Class Declarations @@ -3523,7 +3522,7 @@ The *Identifier* of a class declaration may not be one of the predefined type na A class may optionally have type parameters (section [3.4.1](#3.4.1)) that serve as placeholders for actual types to be provided when the class is referenced in type references. A class with type parameters is called a ***generic class***. The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the *ClassHeritage* and *ClassBody*. -The following example introduces both a named type called ‘Point’ (the class type) and a member called ‘Point’ (the constructor function) in the containing module. +The following example introduces both a named type called 'Point' (the class type) and a member called 'Point' (the constructor function) in the containing module. ```TypeScript class Point { @@ -3533,7 +3532,7 @@ class Point { } ``` -The ‘Point’ type is exactly equivalent to +The 'Point' type is exactly equivalent to ```TypeScript interface Point { @@ -3543,7 +3542,7 @@ interface Point { } ``` -The ‘Point’ member is a constructor function whose type corresponds to the declaration +The 'Point' member is a constructor function whose type corresponds to the declaration ```TypeScript var Point: { @@ -3558,7 +3557,7 @@ The context in which a class is referenced distinguishes between the class insta var p: Point = new Point(10, 20); ``` -the identifier ‘Point’ in the type annotation refers to the class instance type, whereas the identifier ‘Point’ in the `new` expression refers to the constructor function object. +the identifier 'Point' in the type annotation refers to the class instance type, whereas the identifier 'Point' in the `new` expression refers to the constructor function object. ### 8.1.1 Class Heritage Specification @@ -3576,7 +3575,7 @@ The heritage specification of a class consists of optional `extends` and `implem   *ImplementsClause:*    `implements` *ClassOrInterfaceTypeList* -A class that includes an `extends` clause is called a ***derived class***, and the class specified in the `extends` clause is called the ***base class*** of the derived class. When a class heritage specification omits the `extends` clause, the class does not have a base class. However, as is the case with every object type, type references (section [3.3.1](#3.3.1)) to the class will appear to have the members of the global interface type named ‘Object’ unless those members are hidden by members with the same name in the class. +A class that includes an `extends` clause is called a ***derived class***, and the class specified in the `extends` clause is called the ***base class*** of the derived class. When a class heritage specification omits the `extends` clause, the class does not have a base class. However, as is the case with every object type, type references (section [3.3.1](#3.3.1)) to the class will appear to have the members of the global interface type named 'Object' unless those members are hidden by members with the same name in the class. The following constraints must be satisfied by the class heritage specification or otherwise a compile-time error occurs: @@ -3596,15 +3595,15 @@ module Foo { } ``` -When evaluated as an expression, the type reference ‘A’ in the `extends` clause doesn’t reference the class constructor function of ‘A’ (instead it references the local variable ‘A’). +When evaluated as an expression, the type reference 'A' in the `extends` clause doesn't reference the class constructor function of 'A' (instead it references the local variable 'A'). The only situation in which the last two constraints above are violated is when a class overrides one or more base class members with incompatible new members. -Note that because TypeScript has a structural type system, a class doesn’t need to explicitly state that it implements an interface—it suffices for the class to simply contain the appropriate set of instance members. The `implements` clause of a class provides a mechanism to assert and validate that the class contains the appropriate sets of instance members, but otherwise it has no effect on the class type. +Note that because TypeScript has a structural type system, a class doesn't need to explicitly state that it implements an interface—it suffices for the class to simply contain the appropriate set of instance members. The `implements` clause of a class provides a mechanism to assert and validate that the class contains the appropriate sets of instance members, but otherwise it has no effect on the class type. ### 8.1.2 Class Body -The class body consists of zero or more constructor or member declarations. Statements are not allowed in the body of a class—they must be placed in the constructor or in members. +The class body consists of zero or more constructor or member declarations. Statements are not allowed in the body of a class—they must be placed in the constructor or in members.   *ClassBody:*    *ClassElementsopt* @@ -3646,7 +3645,7 @@ Private property members can be accessed only within their declaring class. Spec Protected property members can be accessed only within their declaring class and classes derived from their declaring class, and a protected instance property member must be accessed *through* an instance of the enclosing class. Specifically, a protected member *M* declared in a class *C* can be accessed only within the class body of *C* or the class body of a class derived from *C*. Furthermore, when a protected instance member *M* is accessed in a property access *E*`.`*M* within the body of a class *D*, the type of *E* is required to be *D* or a type that directly or indirectly has *D* as a base type, regardless of type arguments. -Private and protected accessibility is enforced only at compile-time and serves as no more than an *indication of intent*. Since JavaScript provides no mechanism to create private and protected properties on an object, it is not possible to enforce the private and protected modifiers in dynamic code at run-time. For example, private and protected accessibility can be defeated by changing an object’s static type to Any and accessing the member dynamically. +Private and protected accessibility is enforced only at compile-time and serves as no more than an *indication of intent*. Since JavaScript provides no mechanism to create private and protected properties on an object, it is not possible to enforce the private and protected modifiers in dynamic code at run-time. For example, private and protected accessibility can be defeated by changing an object's static type to Any and accessing the member dynamically. The following example demonstrates private and protected accessibility: @@ -3672,11 +3671,11 @@ class B extends A { } ``` -In class ‘A’, the accesses to ‘x’ are permitted because ‘x’ is declared in ‘A’, and the accesses to ‘y’ are permitted because both take place through an instance of ‘A’ or a type derived from ‘A’. In class ‘B’, access to ‘x’ is not permitted, and the first access to ‘y’ is an error because it takes place through an instance of ‘A’, which is not derived from the enclosing class ‘B’. +In class 'A', the accesses to 'x' are permitted because 'x' is declared in 'A', and the accesses to 'y' are permitted because both take place through an instance of 'A' or a type derived from 'A'. In class 'B', access to 'x' is not permitted, and the first access to 'y' is an error because it takes place through an instance of 'A', which is not derived from the enclosing class 'B'. ### 8.2.3 Inheritance and Overriding -A derived class ***inherits*** all members from its base class it doesn’t ***override***. Inheritance means that a derived class implicitly contains all non-overridden members of the base class. Only public and protected property members can be overridden. +A derived class ***inherits*** all members from its base class it doesn't ***override***. Inheritance means that a derived class implicitly contains all non-overridden members of the base class. Only public and protected property members can be overridden. A property member in a derived class is said to override a property member in a base class when the derived class property member has the same name and kind (instance or static) as the base class property member. The type of an overriding property member must be assignable (section [3.8.4](#3.8.4)) to the type of the overridden property member, or otherwise a compile-time error occurs. @@ -3717,7 +3716,7 @@ class B extends A { } ``` -the instance type of ‘A’ is +the instance type of 'A' is ```TypeScript interface A { @@ -3727,7 +3726,7 @@ interface A { } ``` -and the instance type of ‘B’ is +and the instance type of 'B' is ```TypeScript interface B { @@ -3738,7 +3737,7 @@ interface B { } ``` -Note that static declarations in a class do not contribute to the class type and its instance type—rather, static declarations introduce properties on the constructor function object. Also note that the declaration of ‘g’ in ‘B’ overrides the member inherited from ‘A’. +Note that static declarations in a class do not contribute to the class type and its instance type—rather, static declarations introduce properties on the constructor function object. Also note that the declaration of 'g' in 'B' overrides the member inherited from 'A'. ### 8.2.5 Constructor Function Types @@ -3751,10 +3750,10 @@ The type of the constructor function introduced by a class declaration is called * A property for each static member variable declaration in the class body. * A property of a function type for each static member function declaration in the class body. * A property for each uniquely named static member accessor declaration in the class body. -* A property named ‘prototype’, the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. +* A property named 'prototype', the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. * All base class constructor function type properties that are not overridden in the class. -Every class automatically contains a static property member named ‘prototype’, the type of which is the containing class with type Any substituted for each type parameter. +Every class automatically contains a static property member named 'prototype', the type of which is the containing class with type Any substituted for each type parameter. The example @@ -3792,7 +3791,7 @@ var TwoArrays: { } ``` -Note that the construct signatures in the constructor function types have the same type parameters as their class and return the instance type of their class. Also note that when a derived class doesn’t declare a constructor, type arguments from the base class reference are substituted before construct signatures are propagated from the base constructor function type to the derived constructor function type. +Note that the construct signatures in the constructor function types have the same type parameters as their class and return the instance type of their class. Also note that when a derived class doesn't declare a constructor, type arguments from the base class reference are substituted before construct signatures are propagated from the base constructor function type to the derived constructor function type. ## 8.3 Constructor Declarations @@ -3903,7 +3902,7 @@ Note that the declaration spaces of instance and static property members are sep Except for overrides, as described in section [8.2.3](#8.2.3), it is an error for a derived class to declare a property member with the same name and kind (instance or static) as a base class member. -Every class automatically contains a static property member named ‘prototype’, the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. It is an error to explicitly declare a static property member with the name ‘prototype’. +Every class automatically contains a static property member named 'prototype', the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. It is an error to explicitly declare a static property member with the name 'prototype'. Below is an example of a class containing both instance and static property member declarations: @@ -3920,7 +3919,7 @@ class Point { } ``` -The class instance type ‘Point’ has the members: +The class instance type 'Point' has the members: ```TypeScript interface Point { @@ -3930,7 +3929,7 @@ interface Point { } ``` -and the constructor function ‘Point’ has a type corresponding to the declaration: +and the constructor function 'Point' has a type corresponding to the declaration: ```TypeScript var Point: { @@ -4029,7 +4028,7 @@ class ColoredPoint extends Point { } ``` -In a static member function, `this` represents the constructor function object on which the static member function was invoked. Thus, a call to ‘new this()’ may actually invoke a derived class constructor: +In a static member function, `this` represents the constructor function object on which the static member function was invoked. Thus, a call to 'new this()' may actually invoke a derived class constructor: ```TypeScript class A { @@ -4047,7 +4046,7 @@ var x = A.create(); // new A() var y = B.create(); // new B() ``` -Note that TypeScript doesn’t require or verify that derived constructor functions are subtypes of base constructor functions. In other words, changing the declaration of ‘B’ to +Note that TypeScript doesn't require or verify that derived constructor functions are subtypes of base constructor functions. In other words, changing the declaration of 'B' to ```TypeScript class B extends A { @@ -4057,7 +4056,7 @@ class B extends A { } ``` -does not cause errors in the example, even though the call to the constructor from the ‘create’ function doesn’t specify an argument (thus giving the value ‘undefined’ to ‘b’). +does not cause errors in the example, even though the call to the constructor from the 'create' function doesn't specify an argument (thus giving the value 'undefined' to 'b'). ### 8.4.3 Member Accessor Declarations @@ -4075,7 +4074,7 @@ An instance member accessor declaration declares a property in the class instanc A static member accessor declaration declares a property in the constructor function type and defines a property on the constructor function object of the class with a get or set accessor. In the body of a static member accessor declaration, the type of `this` is the constructor function type. -Get and set accessors are emitted as calls to ‘Object.defineProperty’ in the generated JavaScript, as described in section [8.6.1](#8.6.1). +Get and set accessors are emitted as calls to 'Object.defineProperty' in the generated JavaScript, as described in section [8.6.1](#8.6.1). ## 8.5 Index Member Declarations @@ -4116,7 +4115,7 @@ var = (function () { *ClassName* is the name of the class. -*ConstructorParameters* is a comma separated list of the constructor’s parameter names. +*ConstructorParameters* is a comma separated list of the constructor's parameter names. *DefaultValueAssignments* is a sequence of default property value assignments corresponding to those generated for a regular function declaration, as described in section [6.5](#6.5). @@ -4190,7 +4189,7 @@ Object.defineProperty(, "", { }; ``` -where *MemberName* is the name of the member accessor, *GetAccessorStatements* is the code generated for the statements in the get acessor’s function body, *ParameterName* is the name of the set accessor parameter, and *SetAccessorStatements* is the code generated for the statements in the set accessor’s function body. The ‘get’ property is included only if a get accessor is declared and the ‘set’ property is included only if a set accessor is declared. +where *MemberName* is the name of the member accessor, *GetAccessorStatements* is the code generated for the statements in the get acessor's function body, *ParameterName* is the name of the set accessor parameter, and *SetAccessorStatements* is the code generated for the statements in the set accessor's function body. The 'get' property is included only if a get accessor is declared and the 'set' property is included only if a set accessor is declared. *StaticVariableAssignments* is a sequence of statements, one for each static member variable declaration with an initializer, in the order they are declared, of the form @@ -4220,7 +4219,7 @@ var = (function (_super) { })(); ``` -In addition, the ‘__extends’ function below is emitted at the beginning of the JavaScript source file. It copies all properties from the base constructor function object to the derived constructor function object (in order to inherit static members), and appropriately establishes the ‘prototype’ property of the derived constructor function object. +In addition, the '__extends' function below is emitted at the beginning of the JavaScript source file. It copies all properties from the base constructor function object to the derived constructor function object (in order to inherit static members), and appropriately establishes the 'prototype' property of the derived constructor function object. ```TypeScript var __extends = this.__extends || function(d, b) { @@ -4288,7 +4287,7 @@ An enum declaration declares an ***enum type*** and an ***enum object*** in the   *EnumDeclaration:*    `enum` *Identifier* `{` *EnumBodyopt* `}` -The enum type and enum object declared by an *EnumDeclaration* both have the name given by the *Identifier* of the declaration. The enum type is a distinct subtype of the Number primitive type. The enum object is a variable of an anonymous object type containing a set of properties, all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. The enum object’s type furthermore includes a numeric index signature with the signature ‘[x: number]: string’. +The enum type and enum object declared by an *EnumDeclaration* both have the name given by the *Identifier* of the declaration. The enum type is a distinct subtype of the Number primitive type. The enum object is a variable of an anonymous object type containing a set of properties, all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. The *Identifier* of an enum declaration may not be one of the predefined type names (section [3.6.1](#3.6.1)). @@ -4298,7 +4297,7 @@ The example enum Color { Red, Green, Blue } ``` -declares a subtype of the Number primitive type called ‘Color’ and introduces a variable ‘Color’ with a type that corresponds to the declaration +declares a subtype of the Number primitive type called 'Color' and introduces a variable 'Color' with a type that corresponds to the declaration ```TypeScript var Color: { @@ -4309,7 +4308,7 @@ var Color: { }; ``` -The numeric index signature reflects a “reverse mapping” that is automatically generated in every enum object, as described in section [9.4](#9.4). The reverse mapping provides a convenient way to obtain the string representation of an enum value. For example +The numeric index signature reflects a "reverse mapping" that is automatically generated in every enum object, as described in section [9.4](#9.4). The reverse mapping provides a convenient way to obtain the string representation of an enum value. For example ```TypeScript var c = Color.Red; @@ -4370,7 +4369,7 @@ enum Test { } ``` -‘A’, ‘B’, ‘D’, and ‘E’ are constant members with values 0, 1, 10, and 11 respectively, and ‘C’ is a computed member. +'A', 'B', 'D', and 'E' are constant members with values 0, 1, 10, and 11 respectively, and 'C' is a computed member. In the example @@ -4389,9 +4388,9 @@ the first four members are constant members and the last two are computed member ## 9.3 Declaration Merging -Enums are “open-ended” and enum declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) define a single enum type and contribute to a single enum object. +Enums are "open-ended" and enum declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) define a single enum type and contribute to a single enum object. -It isn’t possible for one enum declaration to continue the automatic numbering sequence of another, and when an enum type has multiple declarations, only one declaration is permitted to omit a value for the first member. +It isn't possible for one enum declaration to continue the automatic numbering sequence of another, and when an enum type has multiple declarations, only one declaration is permitted to omit a value for the first member. ## 9.4 Code Generation @@ -4414,7 +4413,7 @@ var ; where *MemberName* is the name of the enum member and *Value* is the assigned constant value or the code generated for the computed value expression. -For example, the ‘Color’ enum example from section [9.1](#9.1) generates the following JavaScript: +For example, the 'Color' enum example from section [9.1](#9.1) generates the following JavaScript: ```TypeScript var Color; @@ -4429,7 +4428,7 @@ var Color; # 10 Internal Modules -An internal module is a named container of statements and declarations. An internal module represents both a namespace and a singleton module instance. The namespace contains named types and other namespaces, and the singleton module instance contains properties for the module’s exported members. The body of an internal module corresponds to a function that is executed once, thereby providing a mechanism for maintaining local state with assured isolation. +An internal module is a named container of statements and declarations. An internal module represents both a namespace and a singleton module instance. The namespace contains named types and other namespaces, and the singleton module instance contains properties for the module's exported members. The body of an internal module corresponds to a function that is executed once, thereby providing a mechanism for maintaining local state with assured isolation. ## 10.1 Module Declarations @@ -4442,7 +4441,7 @@ An internal module declaration declares a namespace name and, in the case of an    *Identifier*    *IdentifierPath* `.` *Identifier* -Internal modules are either ***instantiated*** or ***non-instantiated***. A non-instantiated module is an internal module containing only interface types and other non-instantiated modules. An instantiated module is an internal module that doesn’t meet this definition. In intuitive terms, an instantiated module is one for which a module object instance is created, whereas a non-instantiated module is one for which no code is generated. +Internal modules are either ***instantiated*** or ***non-instantiated***. A non-instantiated module is an internal module containing only interface types and other non-instantiated modules. An instantiated module is an internal module that doesn't meet this definition. In intuitive terms, an instantiated module is one for which a module object instance is created, whereas a non-instantiated module is one for which no code is generated. When a module identifier is referenced as a *ModuleName* (section [3.6.2](#3.6.2)) it denotes a container of module and type names, and when a module identifier is referenced as a *PrimaryExpression* (section [4.3](#4.3)) it denotes the singleton module instance. For example: @@ -4459,9 +4458,9 @@ var x2 = m.a; // Same as M.a var q: m.P; // Error ``` -Above, when ‘M’ is used as a *PrimaryExpression* it denotes an object instance with a single member ‘a’ and when ‘M’ is used as a *ModuleName* it denotes a container with a single type member ‘P’. The final line in the example is an error because ‘m’ is a variable which cannot be referenced in a type name. +Above, when 'M' is used as a *PrimaryExpression* it denotes an object instance with a single member 'a' and when 'M' is used as a *ModuleName* it denotes a container with a single type member 'P'. The final line in the example is an error because 'm' is a variable which cannot be referenced in a type name. -If the declaration of ‘M’ above had excluded the exported variable ‘a’, ‘M’ would be a non-instantiated module and it would be an error to reference ‘M’ as a *PrimaryExpression*. +If the declaration of 'M' above had excluded the exported variable 'a', 'M' would be a non-instantiated module and it would be an error to reference 'M' as a *PrimaryExpression*. An internal module declaration that specifies an *IdentifierPath* with more than one identifier is equivalent to a series of nested single-identifier internal module declarations where all but the outermost are automatically exported. For example: @@ -4520,7 +4519,7 @@ Import declarations are used to create local aliases for entities in other modul An *EntityName* consisting of a single identifier is resolved as a *ModuleName* and is thus required to reference an internal module. The resulting local alias references the given internal module and is itself classified as an internal module. -An *EntityName* consisting of more than one identifier is resolved as a *ModuleName* followed by an identifier that names one or more exported entities in the given module. The resulting local alias has all the meanings and classifications of the referenced entity or entities. (As many as three distinct meanings are possible for an entity name—namespace, type, and member.) In effect, it is as if the imported entity or entities were declared locally with the local alias name. +An *EntityName* consisting of more than one identifier is resolved as a *ModuleName* followed by an identifier that names one or more exported entities in the given module. The resulting local alias has all the meanings and classifications of the referenced entity or entities. (As many as three distinct meanings are possible for an entity name—namespace, type, and member.) In effect, it is as if the imported entity or entities were declared locally with the local alias name. In the example @@ -4538,7 +4537,7 @@ module B { } ``` -within ‘B’, ‘Y’ is an alias only for module ‘A’ and not the local interface ‘A’, whereas ‘Z’ is an alias for all exported meanings of ‘A.X’, thus denoting both an interface type and a variable. +within 'B', 'Y' is an alias only for module 'A' and not the local interface 'A', whereas 'Z' is an alias for all exported meanings of 'A.X', thus denoting both an interface type and a variable. If the *ModuleName* portion of an *EntityName* references an instantiated module, the *ModuleName* is required to reference the module instance when evaluated as an expression. In the example @@ -4553,7 +4552,7 @@ module B { } ``` -‘Y’ is a local alias for the non-instantiated module ‘A’. If the declaration of ‘A’ is changed such that ‘A’ becomes an instantiated module, for example by including a variable declaration in ‘A’, the import statement in ‘B’ above would be an error because the expression ‘A’ doesn’t reference the module instance of module ‘A’. +'Y' is a local alias for the non-instantiated module 'A'. If the declaration of 'A' is changed such that 'A' becomes an instantiated module, for example by including a variable declaration in 'A', the import statement in 'B' above would be an error because the expression 'A' doesn't reference the module instance of module 'A'. When an import statement includes an export modifier, all meanings of the local alias are exported. @@ -4563,7 +4562,7 @@ An export declaration declares an externally accessible module member. An export Exported class, interface, and enum types can be accessed as a *TypeName* (section [3.6.2](#3.6.2)) of the form *M.T*, where *M* is a reference to the containing module and *T* is the exported type name. Likewise, as part of a *TypeName*, exported modules can be accessed as a *ModuleName* of the form *M.N*, where *M* is a reference to the containing module and *N* is the exported module. -Exported variable, function, class, enum, module, and import alias declarations become properties on the module instance and together establish the module’s ***instance type***. This unnamed type has the following members: +Exported variable, function, class, enum, module, and import alias declarations become properties on the module instance and together establish the module's ***instance type***. This unnamed type has the following members: * A property for each exported variable declaration. * A property of a function type for each exported function declaration. @@ -4597,15 +4596,15 @@ interface A { x: string; } module M { export interface B { x: A; } export interface C { x: B; } - export function foo(c: C) { … } + export function foo(c: C) { … } } ``` -the ‘foo’ function depends upon the named types ‘A’, ‘B’, and ‘C’. In order to export ‘foo’ it is necessary to also export ‘B’ and ‘C’ as they otherwise would not be at least as accessible as ‘foo’. The ‘A’ interface is already at least as accessible as ‘foo’ because it is declared in a parent module of foo’s module. +the 'foo' function depends upon the named types 'A', 'B', and 'C'. In order to export 'foo' it is necessary to also export 'B' and 'C' as they otherwise would not be at least as accessible as 'foo'. The 'A' interface is already at least as accessible as 'foo' because it is declared in a parent module of foo's module. ## 10.5 Declaration Merging -Internal modules are “open-ended” and internal module declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) contribute to a single module. For example, the following two declarations of a module outer might be located in separate source files. +Internal modules are "open-ended" and internal module declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) contribute to a single module. For example, the following two declarations of a module outer might be located in separate source files. File a.ts: @@ -4652,7 +4651,7 @@ Declaration merging also extends to internal module declarations with the same q * When merging a class and an internal module, the type of the constructor function object is merged with the instance type of the module. In effect, the overloads or implementation of the class constructor provide the construct signatures, and the static members of the class and exported members of the module provide the properties of the combined type. It is an error to have static class members and exported module members with the same name. * When merging an enum and an internal module, the type of the enum object is merged with the instance type of the module. In effect, the members of the enum and the exported members of the module provide the properties of the combined type. It is an error to have enum members and exported module members with the same name. -When merging a non-ambient function or class declaration and a non-ambient internal module declaration, the function or class declaration must be located prior to the internal module declaration in the same source file. This ensures that the shared object instance is created as a function object. (While it is possible to add properties to an object after its creation, it is not possible to make an object “callable” after the fact.) +When merging a non-ambient function or class declaration and a non-ambient internal module declaration, the function or class declaration must be located prior to the internal module declaration in the same source file. This ensures that the shared object instance is created as a function object. (While it is possible to add properties to an object after its creation, it is not possible to make an object "callable" after the fact.) The example @@ -4678,7 +4677,7 @@ var p2 = point.origin; var b = point.equals(p1, p2); ``` -declares ‘point’ as a function object with two properties, ‘origin’ and ‘equals’. Note that the module declaration for ‘point’ is located after the function declaration. +declares 'point' as a function object with two properties, 'origin' and 'equals'. Note that the module declaration for 'point' is located after the function declaration. ## 10.6 Code Generation @@ -4691,7 +4690,7 @@ var ; })(||(={})); ``` -where *ModuleName* is the name of the module and *ModuleStatements* is the code generated for the statements in the module body. The *ModuleName* function parameter may be prefixed with one or more underscore characters to ensure the name is unique within the function body. Note that the entire module is emitted as an anonymous function that is immediately executed. This ensures that local variables are in their own lexical environment isolated from the surrounding context. Also note that the generated function doesn’t create and return a module instance, but rather it extends the existing instance (which may have just been created in the function call). This ensures that internal modules can extend each other. +where *ModuleName* is the name of the module and *ModuleStatements* is the code generated for the statements in the module body. The *ModuleName* function parameter may be prefixed with one or more underscore characters to ensure the name is unique within the function body. Note that the entire module is emitted as an anonymous function that is immediately executed. This ensures that local variables are in their own lexical environment isolated from the surrounding context. Also note that the generated function doesn't create and return a module instance, but rather it extends the existing instance (which may have just been created in the function call). This ensures that internal modules can extend each other. An import statement generates code of the form @@ -4723,11 +4722,11 @@ This copies a reference to the entity into a property on the module instance. TypeScript implements external modules that are closely aligned with those proposed for ECMAScript 6 and supports code generation targeting CommonJS and AMD module systems. -*NOTE: TypeScript currently doesn’t support the full proposed capabilities of the ECMAScript 6 import and export syntax. We expect to align more closely on the syntax as the ECMAScript 6 specification evolves*. +*NOTE: TypeScript currently doesn't support the full proposed capabilities of the ECMAScript 6 import and export syntax. We expect to align more closely on the syntax as the ECMAScript 6 specification evolves*. ## 11.1 Source Files -A TypeScript ***program*** consists of one or more source files that are either ***implementation source files*** or ***declaration source files***. Source files with extension ‘.ts’ are *ImplementationSourceFiles* containing statements and declarations. Source files with extension ‘.d.ts’ are *DeclarationSourceFiles* containing declarations only. Declaration source files are a strict subset of implementation source files. +A TypeScript ***program*** consists of one or more source files that are either ***implementation source files*** or ***declaration source files***. Source files with extension '.ts' are *ImplementationSourceFiles* containing statements and declarations. Source files with extension '.d.ts' are *DeclarationSourceFiles* containing declarations only. Declaration source files are a strict subset of implementation source files.   *SourceFile:*    *ImplementationSourceFile* @@ -4761,9 +4760,9 @@ A TypeScript ***program*** consists of one or more source files that are either    `export`*opt* *AmbientDeclaration*    `export`*opt* *ExternalImportDeclaration* -When a TypeScript program is compiled, all of the program’s source files are processed together. Statements and declarations in different source files can depend on each other, possibly in a circular fashion. By default, a JavaScript output file is generated for each implementation source file in a compilation, but no output is generated from declaration source files. +When a TypeScript program is compiled, all of the program's source files are processed together. Statements and declarations in different source files can depend on each other, possibly in a circular fashion. By default, a JavaScript output file is generated for each implementation source file in a compilation, but no output is generated from declaration source files. -The source elements permitted in a TypeScript implementation source file are a superset of those supported by JavaScript. Specifically, TypeScript extends the JavaScript grammar’s existing *VariableDeclaration* (section [5.1](#5.1)) and *FunctionDeclaration* (section [6.1](#6.1)) productions, and adds *InterfaceDeclaration* (section [7.1](#7.1)), *ClassDeclaration* (section [8.1](#8.1)), *EnumDeclaration* (section [9.1](#9.1)), *ModuleDeclaration* (section [10.1](#10.1)), *ImportDeclaration* (section [10.3](#10.3)), *ExternalImportDeclaration* (section [11.2.2](#11.2.2)), *ExportAssignment* (section [11.2.4](#11.2.4)), *AmbientDeclaration* (section [12.1](#12.1)), and *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) productions. +The source elements permitted in a TypeScript implementation source file are a superset of those supported by JavaScript. Specifically, TypeScript extends the JavaScript grammar's existing *VariableDeclaration* (section [5.1](#5.1)) and *FunctionDeclaration* (section [6.1](#6.1)) productions, and adds *InterfaceDeclaration* (section [7.1](#7.1)), *ClassDeclaration* (section [8.1](#8.1)), *EnumDeclaration* (section [9.1](#9.1)), *ModuleDeclaration* (section [10.1](#10.1)), *ImportDeclaration* (section [10.3](#10.3)), *ExternalImportDeclaration* (section [11.2.2](#11.2.2)), *ExportAssignment* (section [11.2.4](#11.2.4)), *AmbientDeclaration* (section [12.1](#12.1)), and *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) productions. Declaration source files are restricted to contain declarations only. Declaration source files can be used to declare the static type information associated with existing JavaScript code in an adjunct manner. They are entirely optional but enable the TypeScript compiler and tools to provide better verification and assistance when integrating existing JavaScript code and libraries in a TypeScript application. @@ -4775,11 +4774,11 @@ External modules can additionally be declared using *AmbientExternalModuleDeclar ### 11.1.1 Source Files Dependencies -The TypeScript compiler automatically determines a source file’s dependencies and includes those dependencies in the program being compiled. The determination is made from “reference comments” and external import declarations as follows: +The TypeScript compiler automatically determines a source file's dependencies and includes those dependencies in the program being compiled. The determination is made from "reference comments" and external import declarations as follows: -* A comment of the form /// <reference path="…"/> adds a dependency on the source file specified in the path argument. The path is resolved relative to the directory of the containing source file. -* An external import declaration that specifies a relative external module name (section [11.2.1](#11.2.1)) resolves the name relative to the directory of the containing source file. If a source file with the resulting path and file extension ‘.ts’ exists, that file is added as a dependency. Otherwise, if a source file with the resulting path and file extension ‘.d.ts’ exists, that file is added as a dependency. -* An external import declaration that specifies a top-level external module name (section [11.2.1](#11.2.1)) resolves the name in a host dependent manner (typically by resolving the name relative to a module name space root or searching for the name in a series of directories). If a source file with extension ‘.ts’ or ‘.d.ts’ corresponding to the reference is located, that file is added as a dependency. +* A comment of the form /// <reference path="…"/> adds a dependency on the source file specified in the path argument. The path is resolved relative to the directory of the containing source file. +* An external import declaration that specifies a relative external module name (section [11.2.1](#11.2.1)) resolves the name relative to the directory of the containing source file. If a source file with the resulting path and file extension '.ts' exists, that file is added as a dependency. Otherwise, if a source file with the resulting path and file extension '.d.ts' exists, that file is added as a dependency. +* An external import declaration that specifies a top-level external module name (section [11.2.1](#11.2.1)) resolves the name in a host dependent manner (typically by resolving the name relative to a module name space root or searching for the name in a series of directories). If a source file with extension '.ts' or '.d.ts' corresponding to the reference is located, that file is added as a dependency. Any files included as dependencies in turn have their references analyzed in a transitive manner until all dependencies have been determined. @@ -4819,7 +4818,7 @@ export function message(s: string) { } ``` -The import declaration in the ‘main’ module references the ‘log’ module and compiling the ‘main.ts’ file causes the ‘log.ts’ file to also be compiled as part of the program. At run-time, the import declaration loads the ‘log’ module and produces a reference to its module instance through which it is possible to reference the exported function. +The import declaration in the 'main' module references the 'log' module and compiling the 'main.ts' file causes the 'log.ts' file to also be compiled as part of the program. At run-time, the import declaration loads the 'log' module and produces a reference to its module instance through which it is possible to reference the exported function. TypeScript supports two patterns of JavaScript code generation for external modules: The CommonJS Modules pattern (section [11.2.5](#11.2.5)), typically used by server frameworks such as node.js, and the Asynchronous Module Definition (AMD) pattern (section [11.2.6](#11.2.6)), an extension to CommonJS Modules that permits asynchronous module loading, as is typical in browsers. The desired module code generation pattern is selected through a compiler option and does not affect the TypeScript source code. Indeed, it is possible to author external modules that can be compiled for use both on the server side (e.g. using node.js) and on the client side (using an AMD compliant loader) with no changes to the TypeScript source code. @@ -4828,16 +4827,16 @@ TypeScript supports two patterns of JavaScript code generation for external modu External modules are identified and referenced using external module names. The following definition is aligned with that provided in the CommonJS Modules 1.0 specification. * An external module name is a string of terms delimited by forward slashes. -* External module names may not have file-name extensions like “.js”. -* External module names may be relative or top-level. An external module name is relative if the first term is “.” or “..”. +* External module names may not have file-name extensions like ".js". +* External module names may be relative or top-level. An external module name is relative if the first term is "." or "..". * Top-level names are resolved off the conceptual module name space root. * Relative names are resolved relative to the name of the module in which they occur. -For purposes of resolving external module references, TypeScript associates a file path with every external module. The file path is simply the path of the module’s source file without the file extension. For example, an external module contained in the source file ‘C:\src\lib\io.ts’ has the file path ‘C:/src/lib/io’ and an external module contained in the source file ‘C:\src\ui\editor.d.ts’ has the file path ‘C:/src/ui/editor’. +For purposes of resolving external module references, TypeScript associates a file path with every external module. The file path is simply the path of the module's source file without the file extension. For example, an external module contained in the source file 'C:\src\lib\io.ts' has the file path 'C:/src/lib/io' and an external module contained in the source file 'C:\src\ui\editor.d.ts' has the file path 'C:/src/ui/editor'. An external module name in an import declaration is resolved as follows: -* If the import declaration specifies a relative external module name, the name is resolved relative to the directory of the referencing module’s file path. The program must contain a module with the resulting file path or otherwise an error occurs. For example, in a module with the file path ‘C:/src/ui/main’, the external module names ‘./editor’ and ‘../lib/io’ reference modules with the file paths ‘C:/src/ui/editor’ and ‘C:/src/lib/io’. +* If the import declaration specifies a relative external module name, the name is resolved relative to the directory of the referencing module's file path. The program must contain a module with the resulting file path or otherwise an error occurs. For example, in a module with the file path 'C:/src/ui/main', the external module names './editor' and '../lib/io' reference modules with the file paths 'C:/src/ui/editor' and 'C:/src/lib/io'. * If the import declaration specifies a top-level external module name and the program contains an *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) with a string literal that specifies that exact name, then the import declaration references that ambient external module. * If the import declaration specifies a top-level external module name and the program contains no *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) with a string literal that specifies that exact name, the name is resolved in a host dependent manner (for example by considering the name relative to a module name space root). If a matching module cannot be found an error occurs. @@ -4874,7 +4873,7 @@ When an external module containing an export assignment is imported, the local a It is an error for an external module to contain more than one export assignment. -Assume the following example resides in the file ‘point.ts’: +Assume the following example resides in the file 'point.ts': ```TypeScript export = Point; @@ -4885,7 +4884,7 @@ class Point { } ``` -When ‘point.ts’ is imported in another external module, the import alias references the exported class and can be used both as a type and as a constructor function: +When 'point.ts' is imported in another external module, the import alias references the exported class and can be used both as a type and as a constructor function: ```TypeScript import Pt = require("./point"); @@ -4898,9 +4897,9 @@ Note that there is no requirement that the import alias use the same name as the ### 11.2.5 CommonJS Modules -The CommonJS Modules definition specifies a methodology for writing JavaScript modules with implied privacy, the ability to import other modules, and the ability to explicitly export members. A CommonJS compliant system provides a ‘require’ function that can be used to synchronously load other external modules to obtain their singleton module instance, as well as an ‘exports’ variable to which a module can add properties to define its external API. +The CommonJS Modules definition specifies a methodology for writing JavaScript modules with implied privacy, the ability to import other modules, and the ability to explicitly export members. A CommonJS compliant system provides a 'require' function that can be used to synchronously load other external modules to obtain their singleton module instance, as well as an 'exports' variable to which a module can add properties to define its external API. -The ‘main’ and ‘log’ example from section [11.2](#11.2) above generates the following JavaScript code when compiled for the CommonJS Modules pattern: +The 'main' and 'log' example from section [11.2](#11.2) above generates the following JavaScript code when compiled for the CommonJS Modules pattern: File main.js: @@ -4917,7 +4916,7 @@ exports.message = function(s) { } ``` -An external import declaration is represented in the generated JavaScript as a variable initialized by a call to the ‘require’ function provided by the module system host. A variable declaration and ‘require’ call is emitted for a particular imported module only if the imported module, or a local alias (section [10.3](#10.3)) that references the imported module, is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *ModuleName* or *TypeQueryExpression*, nothing is emitted. +An external import declaration is represented in the generated JavaScript as a variable initialized by a call to the 'require' function provided by the module system host. A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or a local alias (section [10.3](#10.3)) that references the imported module, is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *ModuleName* or *TypeQueryExpression*, nothing is emitted. An example: @@ -4938,21 +4937,21 @@ import g = require("./geometry"); var p = g.point(10, 20); ``` -The ‘game’ module references the imported ‘geometry’ module in an expression (through its alias ‘g’) and a ‘require’ call is therefore included in the emitted JavaScript: +The 'game' module references the imported 'geometry' module in an expression (through its alias 'g') and a 'require' call is therefore included in the emitted JavaScript: ```TypeScript var g = require("./geometry"); var p = g.point(10, 20); ``` -Had the ‘game’ module instead been written to only reference ‘geometry’ in a type position +Had the 'game' module instead been written to only reference 'geometry' in a type position ```TypeScript import g = require("./geometry"); var p: g.Point = { x: 10, y: 20 }; ``` -the emitted JavaScript would have no dependency on the ‘geometry’ module and would simply be +the emitted JavaScript would have no dependency on the 'geometry' module and would simply be ```TypeScript var p = { x: 10, y: 20 }; @@ -4960,9 +4959,9 @@ var p = { x: 10, y: 20 }; ### 11.2.6 AMD Modules -The Asynchronous Module Definition (AMD) specification extends the CommonJS Modules specification with a pattern for authoring asynchronously loadable modules with associated dependencies. Using the AMD pattern, modules are emitted as calls to a global ‘define’ function taking an array of dependencies, specified as external module names, and a callback function containing the module body. The global ‘define’ function is provided by including an AMD compliant loader in the application. The loader arranges to asynchronously load the module’s dependencies and, upon completion, calls the callback function passing resolved module instances as arguments in the order they were listed in the dependency array. +The Asynchronous Module Definition (AMD) specification extends the CommonJS Modules specification with a pattern for authoring asynchronously loadable modules with associated dependencies. Using the AMD pattern, modules are emitted as calls to a global 'define' function taking an array of dependencies, specified as external module names, and a callback function containing the module body. The global 'define' function is provided by including an AMD compliant loader in the application. The loader arranges to asynchronously load the module's dependencies and, upon completion, calls the callback function passing resolved module instances as arguments in the order they were listed in the dependency array. -The “main” and “log” example from above generates the following JavaScript code when compiled for the AMD pattern. +The "main" and "log" example from above generates the following JavaScript code when compiled for the AMD pattern. File main.js: @@ -4982,13 +4981,13 @@ define(["require", "exports"], function(require, exports) { } ``` -The special ‘require’ and ‘exports’ dependencies are always present. Additional entries are added to the dependencies array and the parameter list as required to represent imported external modules. Similar to the code generation for CommonJS Modules, a dependency entry is generated for a particular imported module only if the imported module is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *ModuleName*, no dependency is generated for that module. +The special 'require' and 'exports' dependencies are always present. Additional entries are added to the dependencies array and the parameter list as required to represent imported external modules. Similar to the code generation for CommonJS Modules, a dependency entry is generated for a particular imported module only if the imported module is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *ModuleName*, no dependency is generated for that module.
#
12 Ambients -Ambient declarations are used to provide static typing over existing JavaScript code. Ambient declarations differ from regular declarations in that no JavaScript code is emitted for them. Instead of introducing new variables, functions, classes, enums, or modules, ambient declarations provide type information for entities that exist “ambiently” and are included in a program by external means, for example by referencing a JavaScript library in a <script/> tag. +Ambient declarations are used to provide static typing over existing JavaScript code. Ambient declarations differ from regular declarations in that no JavaScript code is emitted for them. Instead of introducing new variables, functions, classes, enums, or modules, ambient declarations provide type information for entities that exist "ambiently" and are included in a program by external means, for example by referencing a JavaScript library in a <script/> tag. ## 12.1 Ambient Declarations @@ -5117,7 +5116,7 @@ An *ExternalImportDeclaration* in an *AmbientExternalModuleDeclaration* may refe If an ambient external module declaration includes an export assignment, it is an error for any of the declarations within the module to specify an `export` modifier. If an ambient external module declaration contains no export assignment, entities declared in the module are exported regardless of whether their declarations include the optional `export` modifier. -Ambient external modules are “open-ended” and ambient external module declarations with the same string literal name contribute to a single external module. For example, the following two declarations of an external module ‘io’ might be located in separate source files. +Ambient external modules are "open-ended" and ambient external module declarations with the same string literal name contribute to a single external module. For example, the following two declarations of an external module 'io' might be located in separate source files. ```TypeScript declare module "io" { @@ -5170,16 +5169,26 @@ This appendix contains a summary of the grammar found in the main document. As d    *Type*   *Type:* +   *PrimaryOrUnionType* +   *FunctionType* +   *ConstructorType* + +  *PrimaryOrUnionType:* +   *PrimaryType* +   *UnionType* + +  *PrimaryType:* +   *ParenthesizedType*    *PredefinedType*    *TypeReference*    *ObjectType*    *ArrayType*    *TupleType* -   *UnionType* -   *FunctionType* -   *ConstructorType*    *TypeQuery* +  *ParenthesizedType:* +   `(` *Type* `)` +   *PredefinedType:*    `any`    `number` @@ -5216,15 +5225,7 @@ This appendix contains a summary of the grammar found in the main document. As d    *MethodSignature*   *ArrayType:* -   *ElementType* *[no LineTerminator here]* `[` `]` - -  *ElementType:* -   *PredefinedType* -   *TypeReference* -   *ObjectType* -   *ArrayType* -   *TupleType* -   *TypeQuery* +   *PrimaryType* *[no LineTerminator here]* `[` `]`   *TupleType:*    `[` *TupleElementTypes* `]` @@ -5237,11 +5238,7 @@ This appendix contains a summary of the grammar found in the main document. As d    *Type*   *UnionType:* -   *ElementType* `|` *UnionOrElementType* - -  *UnionOrElementType:* -   *UnionType* -   *ElementType* +   *PrimaryOrUnionType* `|` *PrimaryType*   *FunctionType:*    *TypeParametersopt* `(` *ParameterListopt* `)` `=>` *Type* @@ -5326,7 +5323,7 @@ This appendix contains a summary of the grammar found in the main document. As d    `set` *PropertyName* `(` *Identifier* *TypeAnnotationopt* `)` `{` *FunctionBody* `}`   *CallExpression:* *( Modified )* -   … +   …    `super` `(` *ArgumentListopt* `)`    `super` `.` *IdentifierName* @@ -5334,7 +5331,7 @@ This appendix contains a summary of the grammar found in the main document. As d    `function` *Identifieropt* *CallSignature* `{` *FunctionBody* `}`   *AssignmentExpression:* *( Modified )* -   … +   …    *ArrowFunctionExpression*   *ArrowFunctionExpression:* @@ -5349,7 +5346,7 @@ This appendix contains a summary of the grammar found in the main document. As d    *TypeArgumentsopt* `(` *ArgumentListopt* `)`   *UnaryExpression:* *( Modified )* -   … +   …    `<` *Type* `>` *UnaryExpression* ## A.3 Statements diff --git a/scripts/ior.ts b/scripts/ior.ts new file mode 100644 index 00000000000..f0c142a266c --- /dev/null +++ b/scripts/ior.ts @@ -0,0 +1,123 @@ +/// + +import fs = require('fs'); +import path = require('path'); + +interface IOLog { + filesRead: { + path: string; + result: { contents: string; }; + }[]; + arguments: string[]; +} + +module Commands { + export function dir(obj: IOLog) { + obj.filesRead.filter(f => f.result !== undefined).forEach(f => { + console.log(f.path); + }); + } + dir['description'] = ': displays a list of files'; + + export function find(obj: IOLog, str: string) { + obj.filesRead.filter(f => f.result !== undefined).forEach(f => { + var lines = f.result.contents.split('\n'); + var printedHeader = false; + lines.forEach(line => { + if (line.indexOf(str) >= 0) { + if (!printedHeader) { + console.log(' === ' + f.path + ' ==='); + printedHeader = true; + } + console.log(line); + } + }); + }); + } + find['description'] = ' string: finds text in files'; + + export function grab(obj: IOLog, filename: string) { + obj.filesRead.filter(f => f.result !== undefined).forEach(f => { + if (path.basename(f.path) === filename) { + fs.writeFile(filename, f.result.contents); + } + }); + } + grab['description'] = ' filename.ts: writes out the specified file to disk'; + + export function extract(obj: IOLog, outputFolder: string) { + var directorySeparator = "/"; + function directoryExists(path: string): boolean { + return fs.existsSync(path) && fs.statSync(path).isDirectory(); + } + function getDirectoryPath(path: string) { + return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator))); + } + function getRootLength(path: string): number { + if (path.charAt(0) === directorySeparator) { + if (path.charAt(1) !== directorySeparator) return 1; + var p1 = path.indexOf(directorySeparator, 2); + if (p1 < 0) return 2; + var p2 = path.indexOf(directorySeparator, p1 + 1); + if (p2 < 0) return p1 + 1; + return p2 + 1; + } + if (path.charAt(1) === ":") { + if (path.charAt(2) === directorySeparator) return 3; + return 2; + } + return 0; + } + function ensureDirectoriesExist(directoryPath: string) { + if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + console.log("creating directory: " + directoryPath); + fs.mkdirSync(directoryPath); + } + } + function transalatePath(outputFolder:string, path: string): string { + return outputFolder + directorySeparator + path.replace(":", ""); + } + function fileExists(path: string): boolean { + return fs.existsSync(path); + } + obj.filesRead.forEach(f => { + var filename = transalatePath(outputFolder, f.path); + ensureDirectoriesExist(getDirectoryPath(filename)); + console.log("writing filename: " + filename); + fs.writeFile(filename, f.result.contents, (err) => { }); + }); + + console.log("Command: tsc "); + obj.arguments.forEach(a => { + if (getRootLength(a) > 0) { + console.log(transalatePath(outputFolder, a)); + } + else { + console.log(a); + } + console.log(" "); + }); + } + extract['description'] = ' outputFolder: extract all input files to '; +} + +var args = process.argv.slice(2); +if (args.length < 2) { + console.log('Usage: node ior.js path_to_file.json [command]'); + console.log('List of commands: '); + Object.keys(Commands).forEach(k => console.log(' ' + k + Commands[k]['description'])); +} else { + var cmd: Function = Commands[args[1]]; + if (cmd === undefined) { + console.log('Unknown command ' + args[1]); + } else { + fs.readFile(args[0], 'utf-8', (err, data) => { + if (err) throw err; + var json = JSON.parse(data); + cmd.apply(undefined, [json].concat(args.slice(2))); + }); + } +} + diff --git a/scripts/word2md.js b/scripts/word2md.js index 8f9cd276f95..0645acbb143 100644 --- a/scripts/word2md.js +++ b/scripts/word2md.js @@ -1,4 +1,8 @@ var sys = (function () { + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1; var args = []; for (var i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); @@ -6,7 +10,24 @@ var sys = (function () { return { args: args, createObject: function (typeName) { return new ActiveXObject(typeName); }, - write: function (s) { return WScript.StdOut.Write(s); } + write: function (s) { + WScript.StdOut.Write(s); + }, + writeFile: function (fileName, data) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + fileStream.Position = 3; + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } }; })(); function convertDocumentToMarkdown(doc) { @@ -149,6 +170,10 @@ function convertDocumentToMarkdown(doc) { lastInTable = inTable; } function writeDocument() { + var title = doc.builtInDocumentProperties.item(1) + ""; + if (title.length) { + write("# " + title + "\n\n"); + } for (var p = doc.paragraphs.first; p; p = p.next()) { writeParagraph(p); } @@ -168,16 +193,19 @@ function convertDocumentToMarkdown(doc) { findReplace("^19 REF", {}, "[^&](#^&)", {}); doc.fields.toggleShowCodes(); writeDocument(); + result = result.replace(/\x85/g, "\u2026"); + result = result.replace(/\x96/g, "\u2013"); + result = result.replace(/\x97/g, "\u2014"); return result; } function main(args) { - if (args.length !== 1) { - sys.write("Syntax: word2md \n"); + if (args.length !== 2) { + sys.write("Syntax: word2md \n"); return; } var app = sys.createObject("Word.Application"); var doc = app.documents.open(args[0]); - sys.write(convertDocumentToMarkdown(doc)); + sys.writeFile(args[1], convertDocumentToMarkdown(doc)); doc.close(false); app.quit(); } diff --git a/scripts/word2md.ts b/scripts/word2md.ts index b1bc50b0cb9..65b39d6e4f6 100644 --- a/scripts/word2md.ts +++ b/scripts/word2md.ts @@ -103,6 +103,7 @@ module Word { export interface Document { fields: Fields; paragraphs: Paragraphs; + builtInDocumentProperties: Collection; close(saveChanges: boolean): void; range(): Range; } @@ -118,6 +119,10 @@ module Word { } var sys = (function () { + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2 /*text*/; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1 /*binary*/; var args: string[] = []; for (var i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); @@ -125,7 +130,26 @@ var sys = (function () { return { args: args, createObject: (typeName: string) => new ActiveXObject(typeName), - write: (s: string) => WScript.StdOut.Write(s) + write(s: string): void { + WScript.StdOut.Write(s); + }, + writeFile: (fileName: string, data: string): void => { + fileStream.Open(); + binaryStream.Open(); + try { + // Write characters in UTF-8 encoding + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + // We don't want the BOM, skip it by setting the starting location to 3 (size of BOM). + fileStream.Position = 3; + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2 /*overwrite*/); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } }; })(); @@ -298,6 +322,10 @@ function convertDocumentToMarkdown(doc: Word.Document): string { } function writeDocument() { + var title = doc.builtInDocumentProperties.item(1) + ""; + if (title.length) { + write("# " + title + "\n\n"); + } for (var p = doc.paragraphs.first; p; p = p.next()) { writeParagraph(p); } @@ -321,17 +349,21 @@ function convertDocumentToMarkdown(doc: Word.Document): string { writeDocument(); + result = result.replace(/\x85/g, "\u2026"); + result = result.replace(/\x96/g, "\u2013"); + result = result.replace(/\x97/g, "\u2014"); + return result; } function main(args: string[]) { - if (args.length !== 1) { - sys.write("Syntax: word2md \n"); + if (args.length !== 2) { + sys.write("Syntax: word2md \n"); return; } var app: Word.Application = sys.createObject("Word.Application"); var doc = app.documents.open(args[0]); - sys.write(convertDocumentToMarkdown(doc)); + sys.writeFile(args[1], convertDocumentToMarkdown(doc)); doc.close(false); app.quit(); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5caf4acd02e..d9225269145 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -96,9 +96,8 @@ module ts { getTypeOfNode: getTypeOfNode, getApparentType: getApparentType, typeToString: typeToString, - writeType: writeType, + getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, - writeSymbol: writeSymbol, getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType, getRootSymbols: getRootSymbols, getContextualType: getContextualType, @@ -107,9 +106,6 @@ module ts { getEnumMemberValue: getEnumMemberValue, isValidPropertyAccess: isValidPropertyAccess, getSignatureFromDeclaration: getSignatureFromDeclaration, - writeSignature: writeSignature, - writeTypeParameter: writeTypeParameter, - writeTypeParametersOfSymbol: writeTypeParametersOfSymbol, isImplementationOfOverload: isImplementationOfOverload, getAliasedSymbol: resolveImport, isUndefinedSymbol: symbol => symbol === undefinedSymbol, @@ -636,6 +632,12 @@ module ts { } function symbolIsValue(symbol: Symbol): boolean { + // If it is an instantiated symbol, then it is a value if the symbol it is an + // instantiation of is a value. + if (symbol.flags & SymbolFlags.Instantiated) { + return symbolIsValue(getSymbolLinks(symbol).target); + } + // If the symbol has the value flag, it is trivially a value. if (symbol.flags & SymbolFlags.Value) { return true; @@ -646,12 +648,6 @@ module ts { return (resolveImport(symbol).flags & SymbolFlags.Value) !== 0; } - // If it is an instantiated symbol, then it is a value if the symbol it is an - // instantiation of is a value. - if (symbol.flags & SymbolFlags.Instantiated) { - return (getSymbolLinks(symbol).target.flags & SymbolFlags.Value) !== 0; - } - return false; } @@ -992,7 +988,7 @@ module ts { function symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string { var writer = getSingleLineStringWriter(); - writeSymbol(symbol, writer, enclosingDeclaration, meaning); + getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); var result = writer.string(); releaseStringWriter(writer); @@ -1000,93 +996,9 @@ module ts { return result; } - // Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope - // Meaning needs to be specified if the enclosing declaration is given - function writeSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void { - var parentSymbol: Symbol; - function writeSymbolName(symbol: Symbol): void { - if (parentSymbol) { - // Write type arguments of instantiated class/interface here - if (flags & SymbolFormatFlags.WriteTypeParametersOrArguments) { - if (symbol.flags & SymbolFlags.Instantiated) { - writeTypeArguments(getTypeParametersOfClassOrInterface(parentSymbol), - (symbol).mapper, writer, enclosingDeclaration); - } - else { - writeTypeParametersOfSymbol(parentSymbol, writer, enclosingDeclaration); - } - } - writePunctuation(writer, SyntaxKind.DotToken); - } - parentSymbol = symbol; - if (symbol.declarations && symbol.declarations.length > 0) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - writer.writeSymbol(identifierToString(declaration.name), symbol); - return; - } - } - - writer.writeSymbol(symbol.name, symbol); - } - - // Let the writer know we just wrote out a symbol. The declaration emitter writer uses - // this to determine if an import it has previously seen (and not written out) needs - // to be written to the file once the walk of the tree is complete. - // - // NOTE(cyrusn): This approach feels somewhat unfortunate. A simple pass over the tree - // up front (for example, during checking) could determine if we need to emit the imports - // and we could then access that data during declaration emit. - writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { - if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); - - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - - // Go up and add our parent. - walkSymbol( - getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), - getQualifiedLeftMeaning(meaning)); - } - - if (accessibleSymbolChain) { - for (var i = 0, n = accessibleSymbolChain.length; i < n; i++) { - writeSymbolName(accessibleSymbolChain[i]); - } - } - else { - // If we didn't find accessible symbol chain for this symbol, break if this is external module - if (!parentSymbol && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) { - return; - } - - // if this is anonymous type break - if (symbol.flags & SymbolFlags.TypeLiteral || symbol.flags & SymbolFlags.ObjectLiteral) { - return; - } - - writeSymbolName(symbol); - } - } - } - - // Get qualified name - if (enclosingDeclaration && - // TypeParameters do not need qualification - !(symbol.flags & SymbolFlags.TypeParameter)) { - - walkSymbol(symbol, meaning); - return; - } - - return writeSymbolName(symbol); - } - function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { var writer = getSingleLineStringWriter(); - writeType(type, writer, enclosingDeclaration, flags); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); var result = writer.string(); releaseStringWriter(writer); @@ -1099,316 +1011,453 @@ module ts { return result; } - function writeType(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { - return writeType(type, flags | TypeFormatFlags.WriteArrowStyleSignature); - - function writeType(type: Type, flags: TypeFormatFlags) { - // Write undefined/null type as any - if (type.flags & TypeFlags.Intrinsic) { - // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving - writer.writeKeyword(!(flags & TypeFormatFlags.WriteOwnNameForAnyLike) && - (type.flags & TypeFlags.Any) ? "any" : (type).intrinsicName); - } - else if (type.flags & TypeFlags.Reference) { - writeTypeReference(type); - } - else if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) { - writeSymbol(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type); - } - else if (type.flags & TypeFlags.Tuple) { - writeTupleType(type); - } - else if (type.flags & TypeFlags.Union) { - writeUnionType(type); - } - else if (type.flags & TypeFlags.Anonymous) { - writeAnonymousType(type, flags); - } - else if (type.flags & TypeFlags.StringLiteral) { - writer.writeStringLiteral((type).text); - } - else { - // Should never get here - // { ... } - writePunctuation(writer, SyntaxKind.OpenBraceToken); - writeSpace(writer); - writePunctuation(writer, SyntaxKind.DotDotDotToken); - writeSpace(writer); - writePunctuation(writer, SyntaxKind.CloseBraceToken); - } - } - - function writeTypeList(types: Type[], union: boolean) { - for (var i = 0; i < types.length; i++) { - if (i > 0) { - if (union) { - writeSpace(writer); - } - writePunctuation(writer, union ? SyntaxKind.BarToken : SyntaxKind.CommaToken); - writeSpace(writer); - } - // Don't output function type literals in unions because '() => string | () => number' would be parsed - // as a function type that returns a union type. Instead output '{ (): string; } | { (): number; }'. - writeType(types[i], union ? flags & ~TypeFormatFlags.WriteArrowStyleSignature : flags | TypeFormatFlags.WriteArrowStyleSignature); - } - } - - function writeTypeReference(type: TypeReference) { - if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType) && !(type.typeArguments[0].flags & TypeFlags.Union)) { - // If we are writing array element type the arrow style signatures are not allowed as - // we need to surround it by curlies, e.g. { (): T; }[]; as () => T[] would mean something different - writeType(type.typeArguments[0], flags & ~TypeFormatFlags.WriteArrowStyleSignature); - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - } - else { - writeSymbol(type.target.symbol, writer, enclosingDeclaration, SymbolFlags.Type); - writePunctuation(writer, SyntaxKind.LessThanToken); - writeTypeList(type.typeArguments, /*union*/ false); - writePunctuation(writer, SyntaxKind.GreaterThanToken); - } - } - - function writeTupleType(type: TupleType) { - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes, /*union*/ false); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - } - - function writeUnionType(type: UnionType) { - writeTypeList(type.types, /*union*/ true); - } - - function writeAnonymousType(type: ObjectType, flags: TypeFormatFlags) { - // Always use 'typeof T' for type of class, enum, and module objects - if (type.symbol && type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) { - writeTypeofSymbol(type); - } - // Use 'typeof T' for types of functions and methods that circularly reference themselves - else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeofSymbol(type); - } - else if (typeStack && contains(typeStack, type)) { - // Recursive usage, use any - writeKeyword(writer, SyntaxKind.AnyKeyword); - } - else { - if (!typeStack) { - typeStack = []; - } - typeStack.push(type); - writeLiteralType(type, flags); - typeStack.pop(); - } - - function shouldWriteTypeOfFunctionSymbol() { - if (type.symbol) { - var isStaticMethodSymbol = !!(type.symbol.flags & SymbolFlags.Method && // typeof static method - ts.forEach(type.symbol.declarations, declaration => declaration.flags & NodeFlags.Static)); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & SymbolFlags.Function) && - (type.symbol.parent || // is exported function symbol - ts.forEach(type.symbol.declarations, declaration => - declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); - - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - // typeof is allowed only for static/non local functions - return !!(flags & TypeFormatFlags.UseTypeOfFunction) || // use typeof if format flags specify it - (typeStack && contains(typeStack, type)); // it is type of the symbol uses itself recursively - } - } - } - } - - function writeTypeofSymbol(type: ObjectType) { - writeKeyword(writer, SyntaxKind.TypeOfKeyword); - writeSpace(writer); - writeSymbol(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value); - } - - function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { - var resolved = resolveObjectTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, SyntaxKind.OpenBraceToken); - writePunctuation(writer, SyntaxKind.CloseBraceToken); + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder: SymbolDisplayBuilder; + function getSymbolDisplayBuilder(): SymbolDisplayBuilder { + /** + * Writes only the name of the symbol out to the writer. Uses the original source text + * for the name of the symbol if it is available to match how the user inputted the name. + */ + function appendSymbolNameOnly(symbol: Symbol, writer: SymbolWriter): void { + if (symbol.declarations && symbol.declarations.length > 0) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + writer.writeSymbol(identifierToString(declaration.name), symbol); return; } + } + + writer.writeSymbol(symbol.name, symbol); + } + + /** + * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope + * Meaning needs to be specified if the enclosing declaration is given + */ + function buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void { + var parentSymbol: Symbol; + function appendParentTypeArgumentsAndSymbolName(symbol: Symbol): void { + if (parentSymbol) { + // Write type arguments of instantiated class/interface here + if (flags & SymbolFormatFlags.WriteTypeParametersOrArguments) { + if (symbol.flags & SymbolFlags.Instantiated) { + buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), + (symbol).mapper, writer, enclosingDeclaration); + } + else { + buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, SyntaxKind.DotToken); + } + parentSymbol = symbol; + appendSymbolNameOnly(symbol, writer); + } + + // Let the writer know we just wrote out a symbol. The declaration emitter writer uses + // this to determine if an import it has previously seen (and not written out) needs + // to be written to the file once the walk of the tree is complete. + // + // NOTE(cyrusn): This approach feels somewhat unfortunate. A simple pass over the tree + // up front (for example, during checking) could determine if we need to emit the imports + // and we could then access that data during declaration emit. + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); + + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + + // Go up and add our parent. + walkSymbol( + getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), + getQualifiedLeftMeaning(meaning)); + } + + if (accessibleSymbolChain) { + for (var i = 0, n = accessibleSymbolChain.length; i < n; i++) { + appendParentTypeArgumentsAndSymbolName(accessibleSymbolChain[i]); + } + } + else { + // If we didn't find accessible symbol chain for this symbol, break if this is external module + if (!parentSymbol && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) { + return; + } + + // if this is anonymous type break + if (symbol.flags & SymbolFlags.TypeLiteral || symbol.flags & SymbolFlags.ObjectLiteral) { + return; + } + + appendParentTypeArgumentsAndSymbolName(symbol); + } + } + } + + // Get qualified name + if (enclosingDeclaration && + // TypeParameters do not need qualification + !(symbol.flags & SymbolFlags.TypeParameter)) { + + walkSymbol(symbol, meaning); + return; + } + + return appendParentTypeArgumentsAndSymbolName(symbol); + } + + function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, typeStack?: Type[]) { + var globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; + return writeType(type, globalFlags); + + function writeType(type: Type, flags: TypeFormatFlags) { + // Write undefined/null type as any + if (type.flags & TypeFlags.Intrinsic) { + // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving + writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && + (type.flags & TypeFlags.Any) ? "any" : (type).intrinsicName); + } + else if (type.flags & TypeFlags.Reference) { + writeTypeReference(type, flags); + } + else if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) { + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type); + } + else if (type.flags & TypeFlags.Tuple) { + writeTupleType(type); + } + else if (type.flags & TypeFlags.Union) { + writeUnionType(type, flags); + } + else if (type.flags & TypeFlags.Anonymous) { + writeAnonymousType(type, flags); + } + else if (type.flags & TypeFlags.StringLiteral) { + writer.writeStringLiteral((type).text); + } + else { + // Should never get here + // { ... } + writePunctuation(writer, SyntaxKind.OpenBraceToken); + writeSpace(writer); + writePunctuation(writer, SyntaxKind.DotDotDotToken); + writeSpace(writer); + writePunctuation(writer, SyntaxKind.CloseBraceToken); + } + } + + function writeTypeList(types: Type[], union: boolean) { + for (var i = 0; i < types.length; i++) { + if (i > 0) { + if (union) { + writeSpace(writer); + } + writePunctuation(writer, union ? SyntaxKind.BarToken : SyntaxKind.CommaToken); + writeSpace(writer); + } + writeType(types[i], union ? TypeFormatFlags.InElementType : TypeFormatFlags.None); + } + } + + function writeTypeReference(type: TypeReference, flags: TypeFormatFlags) { + if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) { + writeType(type.typeArguments[0], TypeFormatFlags.InElementType); + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } + else { + buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, SymbolFlags.Type); + writePunctuation(writer, SyntaxKind.LessThanToken); + writeTypeList(type.typeArguments, /*union*/ false); + writePunctuation(writer, SyntaxKind.GreaterThanToken); + } + } + + function writeTupleType(type: TupleType) { + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writeTypeList(type.elementTypes, /*union*/ false); + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } + + function writeUnionType(type: UnionType, flags: TypeFormatFlags) { + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.OpenParenToken); + } + writeTypeList(type.types, /*union*/ true); + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.CloseParenToken); + } + } + + function writeAnonymousType(type: ObjectType, flags: TypeFormatFlags) { + // Always use 'typeof T' for type of class, enum, and module objects + if (type.symbol && type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) { + writeTypeofSymbol(type); + } + // Use 'typeof T' for types of functions and methods that circularly reference themselves + else if (shouldWriteTypeOfFunctionSymbol()) { + writeTypeofSymbol(type); + } + else if (typeStack && contains(typeStack, type)) { + // Recursive usage, use any + writeKeyword(writer, SyntaxKind.AnyKeyword); + } + else { + if (!typeStack) { + typeStack = []; + } + typeStack.push(type); + writeLiteralType(type, flags); + typeStack.pop(); + } + + function shouldWriteTypeOfFunctionSymbol() { + if (type.symbol) { + var isStaticMethodSymbol = !!(type.symbol.flags & SymbolFlags.Method && // typeof static method + ts.forEach(type.symbol.declarations, declaration => declaration.flags & NodeFlags.Static)); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & SymbolFlags.Function) && + (type.symbol.parent || // is exported function symbol + ts.forEach(type.symbol.declarations, declaration => + declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); + + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return !!(flags & TypeFormatFlags.UseTypeOfFunction) || // use typeof if format flags specify it + (typeStack && contains(typeStack, type)); // it is type of the symbol uses itself recursively + } + } + } + } + + function writeTypeofSymbol(type: ObjectType) { + writeKeyword(writer, SyntaxKind.TypeOfKeyword); + writeSpace(writer); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value); + } + + function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { + var resolved = resolveObjectTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + writePunctuation(writer, SyntaxKind.OpenBraceToken); + writePunctuation(writer, SyntaxKind.CloseBraceToken); + return; + } - if (flags & TypeFormatFlags.WriteArrowStyleSignature) { if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - writeSignature(resolved.callSignatures[0], writer, enclosingDeclaration, flags, typeStack); + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.OpenParenToken); + } + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature , typeStack); + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.CloseParenToken); + } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.OpenParenToken); + } writeKeyword(writer, SyntaxKind.NewKeyword); writeSpace(writer); - writeSignature(resolved.constructSignatures[0], writer, enclosingDeclaration, flags, typeStack); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, typeStack); + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.CloseParenToken); + } return; } } - } - writePunctuation(writer, SyntaxKind.OpenBraceToken); - writer.writeLine(); - writer.increaseIndent(); - for (var i = 0; i < resolved.callSignatures.length; i++) { - writeSignature(resolved.callSignatures[i], writer, enclosingDeclaration, flags & ~TypeFormatFlags.WriteArrowStyleSignature, typeStack); - writePunctuation(writer, SyntaxKind.SemicolonToken); + writePunctuation(writer, SyntaxKind.OpenBraceToken); writer.writeLine(); - } - for (var i = 0; i < resolved.constructSignatures.length; i++) { - writeKeyword(writer, SyntaxKind.NewKeyword); - writeSpace(writer); + writer.increaseIndent(); + for (var i = 0; i < resolved.callSignatures.length; i++) { + buildSignatureDisplay(resolved.callSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + for (var i = 0; i < resolved.constructSignatures.length; i++) { + writeKeyword(writer, SyntaxKind.NewKeyword); + writeSpace(writer); - writeSignature(resolved.constructSignatures[i], writer, enclosingDeclaration, flags & ~TypeFormatFlags.WriteArrowStyleSignature, typeStack); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeParameter("x"); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeKeyword(writer, SyntaxKind.StringKeyword); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeType(resolved.stringIndexType, flags | TypeFormatFlags.WriteArrowStyleSignature); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeParameter("x"); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeKeyword(writer, SyntaxKind.NumberKeyword); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeType(resolved.numberIndexType, flags | TypeFormatFlags.WriteArrowStyleSignature); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - for (var i = 0; i < resolved.properties.length; i++) { - var p = resolved.properties[i]; - var t = getTypeOfSymbol(p); - if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfType(t).length) { - var signatures = getSignaturesOfType(t, SignatureKind.Call); - for (var j = 0; j < signatures.length; j++) { - writeSymbol(p, writer); + buildSignatureDisplay(resolved.constructSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + if (resolved.stringIndexType) { + // [x: string]: + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writer.writeParameter("x"); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + writeKeyword(writer, SyntaxKind.StringKeyword); + writePunctuation(writer, SyntaxKind.CloseBracketToken); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + writeType(resolved.stringIndexType, TypeFormatFlags.None); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + if (resolved.numberIndexType) { + // [x: number]: + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writer.writeParameter("x"); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + writeKeyword(writer, SyntaxKind.NumberKeyword); + writePunctuation(writer, SyntaxKind.CloseBracketToken); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + writeType(resolved.numberIndexType, TypeFormatFlags.None); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + for (var i = 0; i < resolved.properties.length; i++) { + var p = resolved.properties[i]; + var t = getTypeOfSymbol(p); + if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfType(t).length) { + var signatures = getSignaturesOfType(t, SignatureKind.Call); + for (var j = 0; j < signatures.length; j++) { + buildSymbolDisplay(p, writer); + if (isOptionalProperty(p)) { + writePunctuation(writer, SyntaxKind.QuestionToken); + } + buildSignatureDisplay(signatures[j], writer, enclosingDeclaration, globalFlagsToPass, typeStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + } + else { + buildSymbolDisplay(p, writer); if (isOptionalProperty(p)) { writePunctuation(writer, SyntaxKind.QuestionToken); } - writeSignature(signatures[j], writer, enclosingDeclaration, flags & ~TypeFormatFlags.WriteArrowStyleSignature, typeStack); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + writeType(t, TypeFormatFlags.None); writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } } - else { - writeSymbol(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, SyntaxKind.QuestionToken); - } - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeType(t, flags | TypeFormatFlags.WriteArrowStyleSignature); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } + writer.decreaseIndent(); + writePunctuation(writer, SyntaxKind.CloseBraceToken); } - writer.decreaseIndent(); - writePunctuation(writer, SyntaxKind.CloseBraceToken); } - } - function writeTypeParameter(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { - writeSymbol(tp.symbol, writer); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writeSpace(writer); - writeKeyword(writer, SyntaxKind.ExtendsKeyword); - writeSpace(writer); - writeType(constraint, writer, enclosingDeclaration, flags, typeStack); - } - } - - function writeTypeParameters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, SyntaxKind.LessThanToken); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, SyntaxKind.CommaToken); - writeSpace(writer); - } - writeTypeParameter(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); + function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { + var targetSymbol = getTargetSymbol(symbol); + if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) { + buildDisplayForTypeParametersAndDelimiters(getTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); } - writePunctuation(writer, SyntaxKind.GreaterThanToken); } - } - function writeTypeArguments(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, SyntaxKind.LessThanToken); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, SyntaxKind.CommaToken); - writeSpace(writer); - } - writeType(mapper(typeParameters[i]), writer, enclosingDeclaration, TypeFormatFlags.WriteArrowStyleSignature); - } - writePunctuation(writer, SyntaxKind.GreaterThanToken); - } - } - - function writeTypeParametersOfSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { - var rootSymbol = getRootSymbol(symbol); - if (rootSymbol.flags & SymbolFlags.Class || rootSymbol.flags & SymbolFlags.Interface) { - writeTypeParameters(getTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); - } - } - - function writeSignature(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { - if (signature.target && (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature)) { - // Instantiated signature, write type arguments instead - writeTypeArguments(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); - } - else { - writeTypeParameters(signature.typeParameters, writer, enclosingDeclaration, flags, typeStack); - } - writePunctuation(writer, SyntaxKind.OpenParenToken); - for (var i = 0; i < signature.parameters.length; i++) { - if (i > 0) { - writePunctuation(writer, SyntaxKind.CommaToken); + function buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { + appendSymbolNameOnly(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { writeSpace(writer); + writeKeyword(writer, SyntaxKind.ExtendsKeyword); + writeSpace(writer); + buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } - var p = signature.parameters[i]; + } + + function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { if (getDeclarationFlagsFromSymbol(p) & NodeFlags.Rest) { writePunctuation(writer, SyntaxKind.DotDotDotToken); } - writeSymbol(p, writer); + appendSymbolNameOnly(p, writer); if (p.valueDeclaration.flags & NodeFlags.QuestionMark || (p.valueDeclaration).initializer) { writePunctuation(writer, SyntaxKind.QuestionToken); } writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); - writeType(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); + buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, SyntaxKind.CloseParenToken); - if (flags & TypeFormatFlags.WriteArrowStyleSignature) { + function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, SyntaxKind.LessThanToken); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, SyntaxKind.CommaToken); + writeSpace(writer); + } + buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); + } + writePunctuation(writer, SyntaxKind.GreaterThanToken); + } + } + + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, SyntaxKind.LessThanToken); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, SyntaxKind.CommaToken); + writeSpace(writer); + } + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, TypeFormatFlags.None); + } + writePunctuation(writer, SyntaxKind.GreaterThanToken); + } + } + + function buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { + writePunctuation(writer, SyntaxKind.OpenParenToken); + for (var i = 0; i < parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, SyntaxKind.CommaToken); + writeSpace(writer); + } + buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, typeStack); + } + writePunctuation(writer, SyntaxKind.CloseParenToken); + } + + function buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { + if (flags & TypeFormatFlags.WriteArrowStyleSignature) { + writeSpace(writer); + writePunctuation(writer, SyntaxKind.EqualsGreaterThanToken); + } + else { + writePunctuation(writer, SyntaxKind.ColonToken); + } writeSpace(writer); - writePunctuation(writer, SyntaxKind.EqualsGreaterThanToken); + buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); } - else { - writePunctuation(writer, SyntaxKind.ColonToken); - } - writeSpace(writer); + + function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) { + if (signature.target && (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature)) { + // Instantiated signature, write type arguments instead + // This is achieved by passing in the mapper separately + buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, typeStack); + } - writeType(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); + buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, typeStack); + buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack); + } + + return _displayBuilder || (_displayBuilder = { + symbolToString: symbolToString, + typeToString: typeToString, + buildSymbolDisplay: buildSymbolDisplay, + buildTypeDisplay: buildTypeDisplay, + buildTypeParameterDisplay: buildTypeParameterDisplay, + buildParameterDisplay: buildParameterDisplay, + buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, + buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, + buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, + buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, + buildSignatureDisplay: buildSignatureDisplay, + buildReturnTypeDisplay: buildReturnTypeDisplay + }); } function isDeclarationVisible(node: Declaration): boolean { @@ -1768,6 +1817,9 @@ module ts { } function getTypeOfSymbol(symbol: Symbol): Type { + if (symbol.flags & SymbolFlags.Instantiated) { + return getTypeOfInstantiatedSymbol(symbol); + } if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) { return getTypeOfVariableOrParameterOrProperty(symbol); } @@ -1783,9 +1835,6 @@ module ts { if (symbol.flags & SymbolFlags.Import) { return getTypeOfImport(symbol); } - if (symbol.flags & SymbolFlags.Instantiated) { - return getTypeOfInstantiatedSymbol(symbol); - } if (symbol.flags & SymbolFlags.UnionProperty) { return getTypeOfUnionProperty(symbol); } @@ -1943,6 +1992,7 @@ module ts { } function getDeclaredTypeOfSymbol(symbol: Symbol): Type { + Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0); if (symbol.flags & SymbolFlags.Class) { return getDeclaredTypeOfClass(symbol); } @@ -1958,7 +2008,6 @@ module ts { if (symbol.flags & SymbolFlags.Import) { return getDeclaredTypeOfImport(symbol); } - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0); return unknownType; } @@ -2840,6 +2889,8 @@ module ts { return getTypeFromTupleTypeNode(node); case SyntaxKind.UnionType: return getTypeFromUnionTypeNode(node); + case SyntaxKind.ParenType: + return getTypeFromTypeNode((node).type); case SyntaxKind.TypeLiteral: return getTypeFromTypeLiteralNode(node); // This function assumes that an identifier or qualified name is a type expression @@ -2964,7 +3015,7 @@ module ts { // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient, symbol.name); + var result = createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient | symbol.flags, symbol.name); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -3366,7 +3417,7 @@ module ts { var sourceProp = getPropertyOfApparentType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!isOptionalProperty(targetProp)) { + if (relation === subtypeRelation || !isOptionalProperty(targetProp)) { if (reportErrors) { reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } @@ -3655,10 +3706,6 @@ module ts { return forEach(types, t => isSupertypeOfEach(t, types) ? t : undefined); } - function getBestCommonType(types: Type[], contextualType: Type): Type { - return contextualType && isSupertypeOfEach(contextualType, types) ? contextualType : getUnionType(types); - } - function isTypeOfObjectLiteral(type: Type): boolean { return (type.flags & TypeFlags.Anonymous) && type.symbol && (type.symbol.flags & SymbolFlags.ObjectLiteral) ? true : false; } @@ -3714,7 +3761,7 @@ module ts { var members: SymbolTable = {}; var index = 0; forEach(properties, p => { - var symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, p.name); + var symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | p.flags, p.name); symbol.declarations = p.declarations; symbol.parent = p.parent; symbol.type = widenedTypes[index++]; @@ -3767,11 +3814,12 @@ module ts { } } - function createInferenceContext(typeParameters: TypeParameter[]): InferenceContext { + function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext { var inferences: Type[][] = []; for (var i = 0; i < typeParameters.length; i++) inferences.push([]); return { typeParameters: typeParameters, + inferUnionTypes: inferUnionTypes, inferenceCount: 0, inferences: inferences, inferredTypes: new Array(typeParameters.length), @@ -3918,10 +3966,9 @@ module ts { if (!result) { var inferences = context.inferences[index]; if (inferences.length) { - // Find type that is supertype of all others - var supertype = getCommonSupertype(inferences); - // Infer widened supertype, or the undefined type for no common supertype - var inferredType = supertype ? getWidenedType(supertype) : undefinedType; + // Infer widened union or supertype, or the undefined type for no common supertype + var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); + var inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : undefinedType; } else { // Infer the empty object type when no inferences were made @@ -4684,7 +4731,28 @@ module ts { } function isNumericName(name: string) { - return (name !== "") && !isNaN(name); + // The intent of numeric names is that + // - they are names with text in a numeric form, and that + // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit', + // acquired by applying the abstract 'ToNumber' operation on the name's text. + // + // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name. + // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold. + // + // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)' + // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'. + // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names + // because their 'ToString' representation is not equal to their original text. + // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1. + // + // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'. + // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation. + // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number. + // + // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional. + // This is desired behavior, because when indexing with them as numeric entities, you are indexing + // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. + return (+name).toString() === name; } function checkObjectLiteral(node: ObjectLiteral, contextualMapper?: TypeMapper): Type { @@ -4696,7 +4764,7 @@ module ts { var member = members[id]; if (member.flags & SymbolFlags.Property) { var type = checkExpression((member.declarations[0]).initializer, contextualMapper); - var prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, member.name); + var prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) prop.valueDeclaration = member.valueDeclaration; @@ -4734,7 +4802,9 @@ module ts { if (hasProperty(properties, id)) { if (kind === IndexKind.String || isNumericName(id)) { var type = getTypeOfSymbol(properties[id]); - if (!contains(propTypes, type)) propTypes.push(type); + if (!contains(propTypes, type)) { + propTypes.push(type); + } } } } @@ -4962,7 +5032,7 @@ module ts { // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper: TypeMapper): Signature { - var context = createInferenceContext(signature.typeParameters); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -4972,7 +5042,7 @@ module ts { function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument?: boolean[]): Type[] { var typeParameters = signature.typeParameters; - var context = createInferenceContext(typeParameters); + var context = createInferenceContext(typeParameters, /*inferUnionTypes*/ false); var mapper = createInferenceMapper(context); // First infer from arguments that are not context sensitive for (var i = 0; i < args.length; i++) { @@ -5753,7 +5823,7 @@ module ts { case SyntaxKind.GreaterThanToken: case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanEqualsToken: - if (!isTypeSubtypeOf(leftType, rightType) && !isTypeSubtypeOf(rightType, leftType)) { + if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; @@ -7529,6 +7599,8 @@ module ts { return checkTupleType(node); case SyntaxKind.UnionType: return checkUnionType(node); + case SyntaxKind.ParenType: + return checkSourceElement((node).type); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.Block: @@ -8188,10 +8260,6 @@ module ts { } } - function getRootSymbol(symbol: Symbol): Symbol { - return symbol.flags & SymbolFlags.Transient && getSymbolLinks(symbol).target || symbol; - } - function getRootSymbols(symbol: Symbol): Symbol[] { if (symbol.flags & SymbolFlags.UnionProperty) { var symbols: Symbol[] = []; @@ -8359,12 +8427,12 @@ module ts { var symbol = getSymbolOfNode(location); var type = symbol && !(symbol.flags & SymbolFlags.TypeLiteral) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); - writeType(type, writer, enclosingDeclaration, flags); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { var signature = getSignatureFromDeclaration(signatureDeclaration); - writeType(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); + getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } function invokeEmitter(targetSourceFile?: SourceFile) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 951ed857550..5c85bfc1e6a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2899,7 +2899,7 @@ module ts { } return { diagnosticMessage: diagnosticMessage, - errorNode: node.parameters[0], + errorNode: node.parameters[0], typeName: node.name }; } @@ -2920,7 +2920,7 @@ module ts { } return { diagnosticMessage: diagnosticMessage, - errorNode: node.name, + errorNode: node.name, typeName: undefined }; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2ee564c7302..1cc667c5cb9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -227,6 +227,8 @@ module ts { return children((node).elementTypes); case SyntaxKind.UnionType: return children((node).types); + case SyntaxKind.ParenType: + return child((node).type); case SyntaxKind.ArrayLiteral: return children((node).elements); case SyntaxKind.ObjectLiteral: @@ -1078,7 +1080,7 @@ module ts { return isParameter(); case ParsingContext.TypeArguments: case ParsingContext.TupleElementTypes: - return isType(); + return token === SyntaxKind.CommaToken || isType(); } Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -1660,6 +1662,14 @@ module ts { return finishNode(node); } + function parseParenType(): ParenTypeNode { + var node = createNode(SyntaxKind.ParenType); + parseExpected(SyntaxKind.OpenParenToken); + node.type = parseType(); + parseExpected(SyntaxKind.CloseParenToken); + return finishNode(node); + } + function parseFunctionType(signatureKind: SyntaxKind): TypeLiteralNode { var node = createNode(SyntaxKind.TypeLiteral); var member = createNode(signatureKind); @@ -1693,10 +1703,7 @@ module ts { case SyntaxKind.OpenBracketToken: return parseTupleType(); case SyntaxKind.OpenParenToken: - case SyntaxKind.LessThanToken: - return parseFunctionType(SyntaxKind.CallSignature); - case SyntaxKind.NewKeyword: - return parseFunctionType(SyntaxKind.ConstructSignature); + return parseParenType(); default: if (isIdentifier()) { return parseTypeReference(); @@ -1720,18 +1727,18 @@ module ts { case SyntaxKind.NewKeyword: return true; case SyntaxKind.OpenParenToken: - // Only consider an ( as the start of a type if we have () or (id - // We don't want to consider things like (1) as a function type. + // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, + // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(() => { nextToken(); - return token === SyntaxKind.CloseParenToken || isParameter(); + return token === SyntaxKind.CloseParenToken || isParameter() || isType(); }); default: return isIdentifier(); } } - function parseNonUnionType(): TypeNode { + function parsePrimaryType(): TypeNode { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) { parseExpected(SyntaxKind.CloseBracketToken); @@ -1742,13 +1749,13 @@ module ts { return type; } - function parseType(): TypeNode { - var type = parseNonUnionType(); + function parseUnionType(): TypeNode { + var type = parsePrimaryType(); if (token === SyntaxKind.BarToken) { var types = >[type]; types.pos = type.pos; while (parseOptional(SyntaxKind.BarToken)) { - types.push(parseNonUnionType()); + types.push(parsePrimaryType()); } types.end = getNodeEnd(); var node = createNode(SyntaxKind.UnionType, type.pos); @@ -1758,6 +1765,48 @@ module ts { return type; } + function isFunctionType(): boolean { + return token === SyntaxKind.LessThanToken || token === SyntaxKind.OpenParenToken && lookAhead(() => { + nextToken(); + if (token === SyntaxKind.CloseParenToken || token === SyntaxKind.DotDotDotToken) { + // ( ) + // ( ... + return true; + } + if (isIdentifier() || isModifier(token)) { + nextToken(); + if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || + token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken || + isIdentifier() || isModifier(token)) { + // ( id : + // ( id , + // ( id ? + // ( id = + // ( modifier id + return true; + } + if (token === SyntaxKind.CloseParenToken) { + nextToken(); + if (token === SyntaxKind.EqualsGreaterThanToken) { + // ( id ) => + return true; + } + } + } + return false; + }); + } + + function parseType(): TypeNode { + if (isFunctionType()) { + return parseFunctionType(SyntaxKind.CallSignature); + } + if (token === SyntaxKind.NewKeyword) { + return parseFunctionType(SyntaxKind.ConstructSignature); + } + return parseUnionType(); + } + function parseTypeAnnotation(): TypeNode { return parseOptional(SyntaxKind.ColonToken) ? parseType() : undefined; } @@ -2344,13 +2393,29 @@ module ts { function parseTypeArguments(): NodeArray { var typeArgumentListStart = scanner.getTokenPos(); var errorCountBeforeTypeParameterList = file.syntacticErrors.length; - var result = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); + // We pass parseSingleTypeArgument instead of parseType as the element parser + // because parseSingleTypeArgument knows how to parse a missing type argument. + // This is useful for signature help. parseType has the disadvantage that when + // it sees a missing type, it changes the LookAheadMode to Error, and the result + // is a broken binary expression, which breaks signature help. + var result = parseBracketedList(ParsingContext.TypeArguments, parseSingleTypeArgument, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); if (!result.length && file.syntacticErrors.length === errorCountBeforeTypeParameterList) { grammarErrorAtPos(typeArgumentListStart, scanner.getStartPos() - typeArgumentListStart, Diagnostics.Type_argument_list_cannot_be_empty); } return result; } + function parseSingleTypeArgument(): TypeNode { + if (token === SyntaxKind.CommaToken) { + var errorStart = scanner.getTokenPos(); + var errorLength = scanner.getTextPos() - errorStart; + grammarErrorAtPos(errorStart, errorLength, Diagnostics.Type_expected); + return createNode(SyntaxKind.Missing); + } + + return parseType(); + } + function parsePrimaryExpression(): Expression { switch (token) { case SyntaxKind.ThisKeyword: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 32675c554cd..10c9500671e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -155,6 +155,7 @@ module ts { ArrayType, TupleType, UnionType, + ParenType, // Expression ArrayLiteral, ObjectLiteral, @@ -225,7 +226,7 @@ module ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypeReference, - LastTypeNode = UnionType, + LastTypeNode = ParenType, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = EndOfFileToken, @@ -345,6 +346,10 @@ module ts { types: NodeArray; } + export interface ParenTypeNode extends TypeNode { + type: TypeNode; + } + export interface StringLiteralTypeNode extends TypeNode { text: string; } @@ -651,18 +656,14 @@ module ts { getTypeOfNode(node: Node): Type; getApparentType(type: Type): ApparentType; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - writeType(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; - writeSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfApparentType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; getContextualType(node: Node): Type; getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; - writeSignature(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - writeTypeParameter(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - writeTypeParametersOfSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; isImplementationOfOverload(node: FunctionDeclaration): boolean; isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; @@ -675,6 +676,18 @@ module ts { getAliasedSymbol(symbol: Symbol): Symbol; } + export interface SymbolDisplayBuilder { + buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; + buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + export interface SymbolWriter { writeKeyword(text: string): void; writeOperator(text: string): void; @@ -702,6 +715,7 @@ module ts { WriteArrowStyleSignature = 0x00000008, // Write arrow style signature WriteOwnNameForAnyLike = 0x00000010, // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc) WriteTypeArgumentsOfSignature = 0x00000020, // Write the type arguments instead of type parameters of the signature + InElementType = 0x00000040, // Writing an array or union element type } export enum SymbolFormatFlags { @@ -1017,6 +1031,7 @@ module ts { export interface InferenceContext { typeParameters: TypeParameter[]; // Type parameters for which inferences are made + inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType) inferenceCount: number; // Incremented for every inference made (whether new or not) inferences: Type[][]; // Inferences made for each type parameter inferredTypes: Type[]; // Inferred type for each type parameter diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 31d009c4765..6e211892437 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -61,9 +61,11 @@ class CompilerBaselineRunner extends RunnerBase { var otherFiles: { unitName: string; content: string }[]; var harnessCompiler: Harness.Compiler.HarnessCompiler; - var declToBeCompiled: { unitName: string; content: string }[] = []; - var declOtherFiles: { unitName: string; content: string }[] = []; - var declResult: Harness.Compiler.CompilerResult; + var declFileCompilationResult: { + declInputFiles: { unitName: string; content: string }[]; + declOtherFiles: { unitName: string; content: string }[]; + declResult: Harness.Compiler.CompilerResult; + }; var createNewInstance = false; @@ -147,9 +149,7 @@ class CompilerBaselineRunner extends RunnerBase { toBeCompiled = undefined; otherFiles = undefined; harnessCompiler = undefined; - declToBeCompiled = undefined; - declOtherFiles = undefined; - declResult = undefined; + declFileCompilationResult = undefined; }); function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { @@ -173,61 +173,18 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it('Correct sourcemap content for ' + fileName, () => { - if (result.sourceMapRecord) { + if (options.sourceMap) { Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => { - return result.sourceMapRecord; + return result.getSourceMapRecord(); }); } }); // Compile .d.ts files it('Correct compiler generated.d.ts for ' + fileName, () => { - if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) { - throw new Error('There were no errors and declFiles generated did not match number of js files generated'); - } - - // if the .d.ts is non-empty, confirm it compiles correctly as well - if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) { - function addDtsFile(file: { unitName: string; content: string }, dtsFiles: { unitName: string; content: string }[]) { - if (Harness.Compiler.isDTS(file.unitName)) { - dtsFiles.push(file); - } - else { - var declFile = findResultCodeFile(file.unitName); - // Look if there is --out file corresponding to this ts file - if (!declFile && options.out) { - declFile = findResultCodeFile(options.out); - if (!declFile || findUnit(declFile.fileName, declToBeCompiled) || - findUnit(declFile.fileName, declOtherFiles)) { - return; - } - } - - if (declFile) { - dtsFiles.push({ unitName: declFile.fileName, content: declFile.code }); - return; - } - } - - function findResultCodeFile(fileName: string) { - return ts.forEach(result.declFilesCode, - declFile => declFile.fileName === (fileName.substr(0, fileName.length - ".ts".length) + ".d.ts") - ? declFile : undefined); - } - - function findUnit(fileName: string, units: { unitName: string; content: string }[]) { - return ts.forEach(units, unit => unit.unitName === fileName ? unit : undefined); - } - } - - ts.forEach(toBeCompiled, file => addDtsFile(file, declToBeCompiled)); - ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); - harnessCompiler.compileFiles(declToBeCompiled, declOtherFiles, function (compileResult) { - declResult = compileResult; - }, function (settings) { - harnessCompiler.setCompilerSettings(tcSettings); - }); - } + declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { + harnessCompiler.setCompilerSettings(tcSettings); + }, options); }); @@ -267,10 +224,10 @@ class CompilerBaselineRunner extends RunnerBase { } } - if (declResult && declResult.errors.length) { + if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { jsCode += '\r\n\r\n//// [DtsFileErrors]\r\n'; jsCode += '\r\n\r\n'; - jsCode += getErrorBaseline(declToBeCompiled, declOtherFiles, declResult); + jsCode += getErrorBaseline(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles, declFileCompilationResult.declResult); } if (jsCode.length > 0) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index bbabd0462c1..54a9a5184fe 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -139,6 +139,7 @@ module Harness { deleteFile(filename: string): void; listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; + getMemoryUsage? (): number; } module IOImpl { @@ -275,6 +276,13 @@ module Harness { return filesInFolder(path); } + + export var getMemoryUsage: typeof IO.getMemoryUsage = () => { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + } } export module Network { @@ -806,15 +814,81 @@ module Harness { }); this.lastErrors = errors; - var result = new CompilerResult(fileOutputs, errors, []); - // Covert the source Map data into the baseline - result.updateSourceMapRecord(program, emitResult ? emitResult.sourceMaps : undefined); + var result = new CompilerResult(fileOutputs, errors, program, sys.getCurrentDirectory(), emitResult ? emitResult.sourceMaps : undefined); onComplete(result, checker); // reset what newline means in case the last test changed it sys.newLine = '\r\n'; return options; } + + public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[], + otherFiles: { unitName: string; content: string; }[], + result: CompilerResult, + settingsCallback?: (settings: ts.CompilerOptions) => void, + options?: ts.CompilerOptions) { + if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) { + throw new Error('There were no errors and declFiles generated did not match number of js files generated'); + } + + // if the .d.ts is non-empty, confirm it compiles correctly as well + if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) { + var declInputFiles: { unitName: string; content: string }[] = []; + var declOtherFiles: { unitName: string; content: string }[] = []; + var declResult: Harness.Compiler.CompilerResult; + + ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles)); + ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); + this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { + declResult = compileResult; + }, settingsCallback, options); + + return { declInputFiles: declInputFiles, declOtherFiles: declOtherFiles, declResult: declResult }; + } + + function addDtsFile(file: { unitName: string; content: string }, dtsFiles: { unitName: string; content: string }[]) { + if (isDTS(file.unitName)) { + dtsFiles.push(file); + } + else if (isTS(file.unitName)) { + var declFile = findResultCodeFile(file.unitName); + if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) { + dtsFiles.push({ unitName: declFile.fileName, content: declFile.code }); + } + } + + function findResultCodeFile(fileName: string) { + var dTsFileName = ts.forEach(result.program.getSourceFiles(), sourceFile => { + if (sourceFile.filename === fileName) { + // Is this file going to be emitted separately + var sourceFileName: string; + if (ts.isExternalModule(sourceFile) || !options.out) { + if (options.outDir) { + var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, result.currentDirectoryForProgram)); + sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); + sourceFileName = ts.combinePaths(options.outDir, sourceFilePath); + } + else { + sourceFileName = sourceFile.filename; + } + } + else { + // Goes to single --out file + sourceFileName = options.out; + } + + return ts.removeFileExtension(sourceFileName) + ".d.ts"; + } + }); + + return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); + } + + function findUnit(fileName: string, units: { unitName: string; content: string; }[]) { + return ts.forEach(units, unit => unit.unitName === fileName ? unit : undefined); + } + } + } } export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic { @@ -950,10 +1024,6 @@ module Harness { } */ - /** Recreate the harness compiler instance to its default settings */ - export function recreate(options?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; }) { - } - /** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */ var harnessCompiler: HarnessCompiler; @@ -993,6 +1063,10 @@ module Harness { return str.substr(str.length - end.length) === end; } + export function isTS(fileName: string) { + return stringEndsWith(fileName, '.ts'); + } + export function isDTS(fileName: string) { return stringEndsWith(fileName, '.d.ts'); } @@ -1011,10 +1085,10 @@ module Harness { public errors: HarnessDiagnostic[] = []; public declFilesCode: GeneratedFile[] = []; public sourceMaps: GeneratedFile[] = []; - public sourceMapRecord: string; /** @param fileResults an array of strings for the fileName and an ITextWriter with its code */ - constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], sourceMapRecordLines: string[]) { + constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], public program: ts.Program, + public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) { var lines: string[] = []; fileResults.forEach(emittedFile => { @@ -1032,12 +1106,11 @@ module Harness { }); this.errors = errors; - this.sourceMapRecord = sourceMapRecordLines.join('\r\n'); } - public updateSourceMapRecord(program: ts.Program, sourceMapData: ts.SourceMapData[]) { - if (sourceMapData) { - this.sourceMapRecord = Harness.SourceMapRecoder.getSourceMapRecord(sourceMapData, program, this.files); + public getSourceMapRecord() { + if (this.sourceMapData) { + return Harness.SourceMapRecoder.getSourceMapRecord(this.sourceMapData, this.program, this.files); } } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 2886c43f091..797bc12a42b 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -419,6 +419,16 @@ class ProjectRunner extends RunnerBase { // }) //}); } + + after(() => { + // Mocha holds onto the closure environment of the describe callback even after the test is done. + // Therefore we have to clean out large objects after the test is done. + nodeCompilerResult = undefined; + amdCompilerResult = undefined; + testCase = undefined; + testFileText = undefined; + testCaseJustName = undefined; + }); }); } } \ No newline at end of file diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index f7cc699c075..6590344a8dd 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -46,144 +46,171 @@ module RWC { } export function runRWCTest(jsonPath: string) { - var harnessCompiler = Harness.Compiler.getCompiler(); - var opts: ts.ParsedCommandLine; + describe("Testing a RWC project: " + jsonPath, () => { + var inputFiles: { unitName: string; content: string; }[] = []; + var otherFiles: { unitName: string; content: string; }[] = []; + var compilerResult: Harness.Compiler.CompilerResult; + var compilerOptions: ts.CompilerOptions; + var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' }; + var baseName = /(.*)\/(.*).json/.exec(Harness.Path.switchToForwardSlashes(jsonPath))[2]; + // Compile .d.ts files + var declFileCompilationResult: { + declInputFiles: { unitName: string; content: string }[]; + declOtherFiles: { unitName: string; content: string }[]; + declResult: Harness.Compiler.CompilerResult; + }; - var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); - var errors = ''; - - it('has parsable options', () => { - runWithIOLog(ioLog, () => { - opts = ts.parseCommandLine(ioLog.arguments); - assert.equal(opts.errors.length, 0); - }); - }); - - var inputFiles: { unitName: string; content: string; }[] = []; - var otherFiles: { unitName: string; content: string; }[] = []; - var compilerResult: Harness.Compiler.CompilerResult; - it('can compile', () => { - runWithIOLog(ioLog, () => { - harnessCompiler.reset(); - - // Load the files - ts.forEach(opts.filenames, fileName => { - inputFiles.push(getHarnessCompilerInputUnit(fileName)); - }); - - if (!opts.options.noLib) { - // Find the lib.d.ts file in the input file and add it to the input files list - var libFile = ts.forEach(ioLog.filesRead, fileRead=> Harness.isLibraryFile(fileRead.path) ? fileRead.path : undefined); - if (libFile) { - inputFiles.push(getHarnessCompilerInputUnit(libFile)); - } - } - - ts.forEach(ioLog.filesRead, fileRead => { - var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileRead.path)); - var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath); - if (!inInputList) { - // Add the file to other files - otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); - } - }); - - // do not use lib since we already read it in above - opts.options.noLib = true; - - // Emit the results - harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => { - compilerResult = compileResult; - }, /*settingsCallback*/ undefined, opts.options); + after(() => { + // Mocha holds onto the closure environment of the describe callback even after the test is done. + // Therefore we have to clean out large objects after the test is done. + inputFiles = undefined; + otherFiles = undefined; + compilerResult = undefined; + compilerOptions = undefined; + baselineOpts = undefined; + baseName = undefined; + declFileCompilationResult = undefined; }); - function getHarnessCompilerInputUnit(fileName: string) { - var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileName)); - try { - var content = sys.readFile(resolvedPath); + it('can compile', () => { + var harnessCompiler = Harness.Compiler.getCompiler(); + var opts: ts.ParsedCommandLine; + + var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); + runWithIOLog(ioLog, () => { + opts = ts.parseCommandLine(ioLog.arguments); + assert.equal(opts.errors.length, 0); + }); + + runWithIOLog(ioLog, () => { + harnessCompiler.reset(); + + // Load the files + ts.forEach(opts.filenames, fileName => { + inputFiles.push(getHarnessCompilerInputUnit(fileName)); + }); + + if (!opts.options.noLib) { + // Find the lib.d.ts file in the input file and add it to the input files list + var libFile = ts.forEach(ioLog.filesRead, fileRead=> Harness.isLibraryFile(fileRead.path) ? fileRead.path : undefined); + if (libFile) { + inputFiles.push(getHarnessCompilerInputUnit(libFile)); + } + } + + ts.forEach(ioLog.filesRead, fileRead => { + var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileRead.path)); + var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath); + if (!inInputList) { + // Add the file to other files + otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + } + }); + + // do not use lib since we already read it in above + opts.options.noLib = true; + + // Emit the results + compilerOptions = harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => { + compilerResult = compileResult; + }, /*settingsCallback*/ undefined, opts.options); + }); + + function getHarnessCompilerInputUnit(fileName: string) { + var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileName)); + try { + var content = sys.readFile(resolvedPath); + } + catch (e) { + // Leave content undefined. + } + return { unitName: resolvedPath, content: content }; } - catch (e) { - // Leave content undefined. - } - return { unitName: resolvedPath, content: content }; - } - }); + }); - // Baselines - var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' }; - var baseName = /(.*)\/(.*).json/.exec(Harness.Path.switchToForwardSlashes(jsonPath))[2]; + // Baselines + it('Correct compiler generated.d.ts', () => { + declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions); + }); - it('has the expected emitted code', () => { - Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => { - return collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s)); - }, false, baselineOpts); - }); - it('has the expected declaration file content', () => { - Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => { - if (compilerResult.errors.length || !compilerResult.declFilesCode.length) { - return null; - } - return collateOutputs(compilerResult.declFilesCode); - }, false, baselineOpts); - }); - - it('has the expected source maps', () => { - Harness.Baseline.runBaseline('has the expected source maps', baseName + '.map', () => { - if (!compilerResult.sourceMaps.length) { - return null; - } - - return collateOutputs(compilerResult.sourceMaps); - }, false, baselineOpts); - }); - - it('has correct source map record', () => { - if (compilerResult.sourceMapRecord) { - Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => { - return compilerResult.sourceMapRecord; + it('has the expected emitted code', () => { + Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => { + return collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s)); }, false, baselineOpts); - } - }); + }); - it('has the expected errors', () => { - Harness.Baseline.runBaseline('has the expected errors', baseName + '.errors.txt', () => { - if (compilerResult.errors.length === 0) { - return null; + it('has the expected declaration file content', () => { + Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => { + if (compilerResult.errors.length || !compilerResult.declFilesCode.length) { + return null; + } + return collateOutputs(compilerResult.declFilesCode); + }, false, baselineOpts); + }); + + it('has the expected source maps', () => { + Harness.Baseline.runBaseline('has the expected source maps', baseName + '.map', () => { + if (!compilerResult.sourceMaps.length) { + return null; + } + + return collateOutputs(compilerResult.sourceMaps); + }, false, baselineOpts); + }); + + //it('has correct source map record', () => { + // if (compilerOptions.sourceMap) { + // Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => { + // return compilerResult.getSourceMapRecord(); + // }, false, baselineOpts); + // } + //}); + + it('has the expected errors', () => { + Harness.Baseline.runBaseline('has the expected errors', baseName + '.errors.txt', () => { + if (compilerResult.errors.length === 0) { + return null; + } + + return Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors); + }, false, baselineOpts); + }); + + it('has no errors in generated declaration files', () => { + if (compilerOptions.declaration && !compilerResult.errors.length) { + Harness.Baseline.runBaseline('has no errors in generated declaration files', baseName + '.dts.errors.txt', () => { + if (declFileCompilationResult.declResult.errors.length === 0) { + return null; + } + + return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + + sys.newLine + sys.newLine + + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); + }, false, baselineOpts); } + }); - return Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors); - }, false, baselineOpts); + // TODO: Type baselines (need to refactor out from compilerRunner) }); - - // TODO: Type baselines (need to refactor out from compilerRunner) } } class RWCRunner extends RunnerBase { - private runnerPath = "tests/runners/rwc"; - private sourcePath = "tests/cases/rwc/"; - - private harnessCompiler: Harness.Compiler.HarnessCompiler; + private static sourcePath = "tests/cases/rwc/"; /** Setup the runner's tests so that they are ready to be executed by the harness * The first test should be a describe/it block that sets up the harness's compiler instance appropriately */ public initializeTests(): void { - // Recreate the compiler with the default lib - Harness.Compiler.recreate({ useMinimalDefaultLib: false, noImplicitAny: false }); - this.harnessCompiler = Harness.Compiler.getCompiler(); - // Read in and evaluate the test list - var testList = Harness.IO.listFiles(this.sourcePath, /.+\.json$/); + var testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/); for (var i = 0; i < testList.length; i++) { this.runTest(testList[i]); } } private runTest(jsonFilename: string) { - describe("Testing a RWC project: " + jsonFilename, () => { - RWC.runRWCTest(jsonFilename); - }); + RWC.runRWCTest(jsonFilename); } } \ No newline at end of file diff --git a/src/services/services.ts b/src/services/services.ts index fb984c9da87..939d5d534d6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1462,7 +1462,7 @@ module ts { } } - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[] { + export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[] { writeDisplayParts(displayPartWriter); var result = displayPartWriter.displayParts(); displayPartWriter.clear(); @@ -1471,19 +1471,19 @@ module ts { export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[] { return mapToDisplayParts(writer => { - typechecker.writeType(type, writer, enclosingDeclaration, flags); + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); }); } export function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[] { return mapToDisplayParts(writer => { - typeChecker.writeSymbol(symbol, writer, enclosingDeclaration, meaning, flags); + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); }); } function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]{ return mapToDisplayParts(writer => { - typechecker.writeSignature(signature, writer, enclosingDeclaration, flags); + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); } @@ -2694,7 +2694,7 @@ module ts { // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker): string { - var flags = typeInfoResolver.getRootSymbols(symbol)[0].getFlags(); + var flags = symbol.getFlags(); if (flags & SymbolFlags.Class) return ScriptElementKind.classElement; if (flags & SymbolFlags.Enum) return ScriptElementKind.enumElement; @@ -2734,6 +2734,18 @@ module ts { if (flags & SymbolFlags.Property) return ScriptElementKind.memberVariableElement; if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; + if (flags & SymbolFlags.UnionProperty) { + return forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => { + var rootSymbolFlags = rootSymbol.getFlags(); + if (rootSymbolFlags & SymbolFlags.Property) { + return ScriptElementKind.memberVariableElement; + } + if (rootSymbolFlags & SymbolFlags.GetAccessor) return ScriptElementKind.memberVariableElement; + if (rootSymbolFlags & SymbolFlags.SetAccessor) return ScriptElementKind.memberVariableElement; + Debug.assert(rootSymbolFlags & SymbolFlags.Method); + }) || ScriptElementKind.memberFunctionElement; + } + return ScriptElementKind.unknown; } @@ -2785,7 +2797,7 @@ module ts { semanticMeaning = getMeaningFromLocation(location)) { var displayParts: SymbolDisplayPart[] = []; var documentation: SymbolDisplayPart[]; - var symbolFlags = typeResolver.getRootSymbols(symbol)[0].flags; + var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver); var hasAddedSymbolInfo: boolean; // Class at constructor site need to be shown as constructor apart from property,method, vars @@ -3001,7 +3013,7 @@ module ts { // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter) { var typeParameterParts = mapToDisplayParts(writer => { - typeResolver.writeTypeParameter(type, writer, enclosingDeclaration); + typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); displayParts.push.apply(displayParts, typeParameterParts); } @@ -3013,7 +3025,8 @@ module ts { symbolFlags & SymbolFlags.Method || symbolFlags & SymbolFlags.Constructor || symbolFlags & SymbolFlags.Signature || - symbolFlags & SymbolFlags.Accessor) { + symbolFlags & SymbolFlags.Accessor || + symbolKind === ScriptElementKind.memberFunctionElement) { var allSignatures = type.getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -3069,7 +3082,7 @@ module ts { function writeTypeParametersOfSymbol(symbol: Symbol, enclosingDeclaration: Node) { var typeParameterParts = mapToDisplayParts(writer => { - typeResolver.writeTypeParametersOfSymbol(symbol, writer, enclosingDeclaration); + typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); displayParts.push.apply(displayParts, typeParameterParts); } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 273cfda99b8..86e378abb45 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -258,6 +258,13 @@ module ts.SignatureHelp { return undefined; } + function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node { + var children = parent.getChildren(sourceFile); + var indexOfOpenerToken = children.indexOf(openerToken); + Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); + return children[indexOfOpenerToken + 1]; + } + /** * The selectedItemIndex could be negative for several reasons. * 1. There are too many arguments for all of the overloads @@ -287,74 +294,51 @@ module ts.SignatureHelp { function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentInfoOrTypeArgumentInfo: ListItemInfo): SignatureHelpItems { var argumentListOrTypeArgumentList = argumentInfoOrTypeArgumentInfo.list; + var parent = argumentListOrTypeArgumentList.parent; + var isTypeParameterHelp = parent.typeArguments && parent.typeArguments.pos === argumentListOrTypeArgumentList.pos; + Debug.assert(isTypeParameterHelp || parent.arguments.pos === argumentListOrTypeArgumentList.pos); + + var callTargetNode = (argumentListOrTypeArgumentList.parent).func; + var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTargetNode); + var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items: SignatureHelpItem[] = map(candidates, candidateSignature => { - var parameters = candidateSignature.parameters; - var parameterHelpItems: SignatureHelpParameter[] = parameters.length === 0 ? emptyArray : map(parameters, p => { - var displayParts: SymbolDisplayPart[] = []; + var signatureHelpParameters: SignatureHelpParameter[]; + var prefixParts: SymbolDisplayPart[] = []; + var suffixParts: SymbolDisplayPart[] = []; - if (candidateSignature.hasRestParameter && parameters[parameters.length - 1] === p) { - displayParts.push(punctuationPart(SyntaxKind.DotDotDotToken)); - } - - displayParts.push(symbolPart(p.name, p)); - - var isOptional = !!(p.valueDeclaration.flags & NodeFlags.QuestionMark); - if (isOptional) { - displayParts.push(punctuationPart(SyntaxKind.QuestionToken)); - } - - displayParts.push(punctuationPart(SyntaxKind.ColonToken)); - displayParts.push(spacePart()); - - var typeParts = typeToDisplayParts(typeInfoResolver, typeInfoResolver.getTypeOfSymbol(p), argumentListOrTypeArgumentList); - displayParts.push.apply(displayParts, typeParts); - - return { - name: p.name, - documentation: p.getDocumentationComment(), - displayParts: displayParts, - isOptional: isOptional - }; - }); - - var callTargetNode = (argumentListOrTypeArgumentList.parent).func; - var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTargetNode); - - var prefixParts = callTargetSymbol ? symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined) : []; - - var separatorParts = [punctuationPart(SyntaxKind.CommaToken), spacePart()]; - - // TODO(jfreeman): Constraints? - if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { - prefixParts.push(punctuationPart(SyntaxKind.LessThanToken)); - - for (var i = 0, n = candidateSignature.typeParameters.length; i < n; i++) { - if (i) { - prefixParts.push.apply(prefixParts, separatorParts); - } - - var tp = candidateSignature.typeParameters[i].symbol; - prefixParts.push(symbolPart(tp.name, tp)); - } - - prefixParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); + if (callTargetDisplayParts) { + prefixParts.push.apply(prefixParts, callTargetDisplayParts); } - prefixParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + if (isTypeParameterHelp) { + prefixParts.push(punctuationPart(SyntaxKind.LessThanToken)); + var typeParameters = candidateSignature.typeParameters; + signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; + suffixParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); + var parameterParts = mapToDisplayParts(writer => + typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, argumentListOrTypeArgumentList)); + suffixParts.push.apply(suffixParts, parameterParts); + } + else { + var typeParameterParts = mapToDisplayParts(writer => + typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, argumentListOrTypeArgumentList)); + prefixParts.push.apply(prefixParts, typeParameterParts); + prefixParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + var parameters = candidateSignature.parameters; + signatureHelpParameters = parameters.length > 0 ? map(parameters, createSignatureHelpParameterForParameter) : emptyArray; + suffixParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + } - var suffixParts = [punctuationPart(SyntaxKind.CloseParenToken)]; - suffixParts.push(punctuationPart(SyntaxKind.ColonToken)); - suffixParts.push(spacePart()); - - var typeParts = typeToDisplayParts(typeInfoResolver, candidateSignature.getReturnType(), argumentListOrTypeArgumentList); - suffixParts.push.apply(suffixParts, typeParts); + var returnTypeParts = mapToDisplayParts(writer => + typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, argumentListOrTypeArgumentList)); + suffixParts.push.apply(suffixParts, returnTypeParts); return { isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixParts, suffixDisplayParts: suffixParts, - separatorDisplayParts: separatorParts, - parameters: parameterHelpItems, + separatorDisplayParts: [punctuationPart(SyntaxKind.CommaToken), spacePart()], + parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; }); @@ -400,12 +384,32 @@ module ts.SignatureHelp { argumentIndex: argumentIndex, argumentCount: argumentCount }; + + function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter { + var displayParts = mapToDisplayParts(writer => + typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, argumentListOrTypeArgumentList)); + + var isOptional = !!(parameter.valueDeclaration.flags & NodeFlags.QuestionMark); + + return { + name: parameter.name, + documentation: parameter.getDocumentationComment(), + displayParts: displayParts, + isOptional: isOptional + }; + } + + function createSignatureHelpParameterForTypeParameter(typeParameter: TypeParameter): SignatureHelpParameter { + var displayParts = mapToDisplayParts(writer => + typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, argumentListOrTypeArgumentList)); + + return { + name: typeParameter.symbol.name, + documentation: emptyArray, + displayParts: displayParts, + isOptional: false + }; + } } } - - function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node { - var children = parent.getChildren(sourceFile); - var indexOfOpenerToken = children.indexOf(openerToken); - return children[indexOfOpenerToken + 1]; - } } \ No newline at end of file diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index c9d39d5c1e8..5e34380673d 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -557,7 +557,7 @@ module NonEmptyTypes { >x : string >y : base >base : base ->[{ x: undefined, y: new base() }, { x: '', y: new derived() }] : Array<{ x: undefined; y: base; } | { x: string; y: derived; }> +>[{ x: undefined, y: new base() }, { x: '', y: new derived() }] : ({ x: undefined; y: base; } | { x: string; y: derived; })[] >{ x: undefined, y: new base() } : { x: undefined; y: base; } >x : undefined >undefined : undefined diff --git a/tests/baselines/reference/arrayLiteralContextualType.types b/tests/baselines/reference/arrayLiteralContextualType.types index 12d08e986f7..5797999b7df 100644 --- a/tests/baselines/reference/arrayLiteralContextualType.types +++ b/tests/baselines/reference/arrayLiteralContextualType.types @@ -40,7 +40,7 @@ function bar(animals: { [n: number]: IAnimal }) { } foo([ >foo([ new Giraffe(), new Elephant()]) : void >foo : (animals: IAnimal[]) => void ->[ new Giraffe(), new Elephant()] : Array +>[ new Giraffe(), new Elephant()] : (Giraffe | Elephant)[] new Giraffe(), >new Giraffe() : Giraffe @@ -54,7 +54,7 @@ foo([ bar([ >bar([ new Giraffe(), new Elephant()]) : void >bar : (animals: { [x: number]: IAnimal; }) => void ->[ new Giraffe(), new Elephant()] : Array +>[ new Giraffe(), new Elephant()] : (Giraffe | Elephant)[] new Giraffe(), >new Giraffe() : Giraffe @@ -67,8 +67,8 @@ bar([ ]); // Legal because of the contextual type IAnimal provided by the parameter var arr = [new Giraffe(), new Elephant()]; ->arr : Array ->[new Giraffe(), new Elephant()] : Array +>arr : (Giraffe | Elephant)[] +>[new Giraffe(), new Elephant()] : (Giraffe | Elephant)[] >new Giraffe() : Giraffe >Giraffe : typeof Giraffe >new Elephant() : Elephant @@ -77,10 +77,10 @@ var arr = [new Giraffe(), new Elephant()]; foo(arr); // ok because arr is Array not {}[] >foo(arr) : void >foo : (animals: IAnimal[]) => void ->arr : Array +>arr : (Giraffe | Elephant)[] bar(arr); // ok because arr is Array not {}[] >bar(arr) : void >bar : (animals: { [x: number]: IAnimal; }) => void ->arr : Array +>arr : (Giraffe | Elephant)[] diff --git a/tests/baselines/reference/arrayLiteralTypeInference.types b/tests/baselines/reference/arrayLiteralTypeInference.types index c80e5e17030..adcc28c7440 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.types +++ b/tests/baselines/reference/arrayLiteralTypeInference.types @@ -25,7 +25,7 @@ class ActionB extends Action { var x1: Action[] = [ >x1 : Action[] >Action : Action ->[ { id: 2, trueness: false }, { id: 3, name: "three" }] : Array<{ id: number; trueness: boolean; } | { id: number; name: string; }> +>[ { id: 2, trueness: false }, { id: 3, name: "three" }] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[] { id: 2, trueness: false }, >{ id: 2, trueness: false } : { id: number; trueness: boolean; } @@ -42,7 +42,7 @@ var x1: Action[] = [ var x2: Action[] = [ >x2 : Action[] >Action : Action ->[ new ActionA(), new ActionB()] : Array +>[ new ActionA(), new ActionB()] : (ActionA | ActionB)[] new ActionA(), >new ActionA() : ActionA @@ -78,7 +78,7 @@ var z1: { id: number }[] = >id : number [ ->[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : Array<{ id: number; trueness: boolean; } | { id: number; name: string; }> +>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[] { id: 2, trueness: false }, >{ id: 2, trueness: false } : { id: number; trueness: boolean; } @@ -97,7 +97,7 @@ var z2: { id: number }[] = >id : number [ ->[ new ActionA(), new ActionB() ] : Array +>[ new ActionA(), new ActionB() ] : (ActionA | ActionB)[] new ActionA(), >new ActionA() : ActionA diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 49b65a86aa6..bc21ec39073 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -17,27 +17,27 @@ var c: { x: number; a?: number }; >a : number var as = [a, b]; // { x: number; y?: number };[] ->as : { x: number; y?: number; }[] ->[a, b] : { x: number; y?: number; }[] +>as : ({ x: number; y?: number; } | { x: number; z?: number; })[] +>[a, b] : ({ x: number; y?: number; } | { x: number; z?: number; })[] >a : { x: number; y?: number; } >b : { x: number; z?: number; } var bs = [b, a]; // { x: number; z?: number };[] ->bs : { x: number; y?: number; }[] ->[b, a] : { x: number; y?: number; }[] +>bs : ({ x: number; y?: number; } | { x: number; z?: number; })[] +>[b, a] : ({ x: number; y?: number; } | { x: number; z?: number; })[] >b : { x: number; z?: number; } >a : { x: number; y?: number; } var cs = [a, b, c]; // { x: number; y?: number };[] ->cs : { x: number; y?: number; }[] ->[a, b, c] : { x: number; y?: number; }[] +>cs : ({ x: number; y?: number; } | { x: number; z?: number; } | { x: number; a?: number; })[] +>[a, b, c] : ({ x: number; y?: number; } | { x: number; z?: number; } | { x: number; a?: number; })[] >a : { x: number; y?: number; } >b : { x: number; z?: number; } >c : { x: number; a?: number; } var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] ->ds : { (x: Object): number; }[] ->[(x: Object) => 1, (x: string) => 2] : { (x: Object): number; }[] +>ds : ((x: Object) => number)[] +>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object @@ -45,8 +45,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >x : string var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] ->es : { (x: string): number; }[] ->[(x: string) => 2, (x: Object) => 1] : { (x: string): number; }[] +>es : ((x: string) => number)[] +>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] >(x: string) => 2 : (x: string) => number >x : string >(x: Object) => 1 : (x: Object) => number @@ -54,8 +54,8 @@ var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] >Object : Object var fs = [(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => 2]; // (a: { x: number; y?: number }) => number[] ->fs : { (a: { x: number; y?: number; }): number; }[] ->[(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => 2] : { (a: { x: number; y?: number; }): number; }[] +>fs : (((a: { x: number; y?: number; }) => number) | ((b: { x: number; z?: number; }) => number))[] +>[(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => 2] : (((a: { x: number; y?: number; }) => number) | ((b: { x: number; z?: number; }) => number))[] >(a: { x: number; y?: number }) => 1 : (a: { x: number; y?: number; }) => number >a : { x: number; y?: number; } >x : number @@ -66,8 +66,8 @@ var fs = [(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => >z : number var gs = [(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => 1]; // (b: { x: number; z?: number }) => number[] ->gs : { (b: { x: number; z?: number; }): number; }[] ->[(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => 1] : { (b: { x: number; z?: number; }): number; }[] +>gs : (((b: { x: number; z?: number; }) => number) | ((a: { x: number; y?: number; }) => number))[] +>[(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => 1] : (((b: { x: number; z?: number; }) => number) | ((a: { x: number; y?: number; }) => number))[] >(b: { x: number; z?: number }) => 2 : (b: { x: number; z?: number; }) => number >b : { x: number; z?: number; } >x : number diff --git a/tests/baselines/reference/arrayLiterals.types b/tests/baselines/reference/arrayLiterals.types index 8c2fd942c62..62475fa2b4a 100644 --- a/tests/baselines/reference/arrayLiterals.types +++ b/tests/baselines/reference/arrayLiterals.types @@ -2,15 +2,15 @@ // Empty array literal with no contextual type has type Undefined[] var arr1= [[], [1], ['']]; ->arr1 : Array ->[[], [1], ['']] : Array +>arr1 : (string[] | number[])[] +>[[], [1], ['']] : (string[] | number[])[] >[] : undefined[] >[1] : number[] >[''] : string[] var arr2 = [[null], [1], ['']]; ->arr2 : Array ->[[null], [1], ['']] : Array +>arr2 : (string[] | number[])[] +>[[null], [1], ['']] : (string[] | number[])[] >[null] : null[] >[1] : number[] >[''] : string[] @@ -65,7 +65,7 @@ var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: ' >n : number >a : string >b : number ->[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }> +>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] >{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } >a : string >b : number @@ -76,8 +76,8 @@ var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: ' >c : number var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; ->context2 : Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }> ->[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }> +>context2 : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] +>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] >{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } >a : string >b : number @@ -105,7 +105,7 @@ class Derived2 extends Base { private n }; var context3: Base[] = [new Derived1(), new Derived2()]; >context3 : Base[] >Base : Base ->[new Derived1(), new Derived2()] : Array +>[new Derived1(), new Derived2()] : (Derived1 | Derived2)[] >new Derived1() : Derived1 >Derived1 : typeof Derived1 >new Derived2() : Derived2 diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index e99ca18673e..1496e99adca 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -61,8 +61,8 @@ var xs = [list, myList]; // {}[] >myList : MyList var ys = [list, list2]; // {}[] ->ys : Array | List> ->[list, list2] : Array | List> +>ys : (List | List)[] +>[list, list2] : (List | List)[] >list : List >list2 : List diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types index b224ff881e3..3ef5334382c 100644 --- a/tests/baselines/reference/arrayOfFunctionTypes3.types +++ b/tests/baselines/reference/arrayOfFunctionTypes3.types @@ -2,8 +2,8 @@ // valid uses of arrays of function types var x = [() => 1, () => { }]; ->x : { (): void; }[] ->[() => 1, () => { }] : { (): void; }[] +>x : (() => void)[] +>[() => 1, () => { }] : (() => void)[] >() => 1 : () => number >() => { } : () => void @@ -11,7 +11,7 @@ var r2 = x[0](); >r2 : void >x[0]() : void >x[0] : () => void ->x : { (): void; }[] +>x : (() => void)[] class C { >C : C diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 2c3ba8bc7c7..eb94c140883 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -48,14 +48,14 @@ var r3 = true ? 1 : {}; >{} : {} var r4 = true ? a : b; // typeof a ->r4 : { x: number; y?: number; } ->true ? a : b : { x: number; y?: number; } +>r4 : { x: number; y?: number; } | { x: number; z?: number; } +>true ? a : b : { x: number; y?: number; } | { x: number; z?: number; } >a : { x: number; y?: number; } >b : { x: number; z?: number; } var r5 = true ? b : a; // typeof b ->r5 : { x: number; y?: number; } ->true ? b : a : { x: number; y?: number; } +>r5 : { x: number; y?: number; } | { x: number; z?: number; } +>true ? b : a : { x: number; y?: number; } | { x: number; z?: number; } >b : { x: number; z?: number; } >a : { x: number; y?: number; } diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.types b/tests/baselines/reference/bestCommonTypeOfTuple.types index 87624c267aa..0516fc4af2b 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple.types @@ -75,8 +75,8 @@ t4 = [E1.one, E2.two, 20]; >two : E2 var e1 = t1[2]; // {} ->e1 : { (x: number): string; } | { (x: number): number; } ->t1[2] : { (x: number): string; } | { (x: number): number; } +>e1 : ((x: number) => string) | ((x: number) => number) +>t1[2] : ((x: number) => string) | ((x: number) => number) >t1 : [(x: number) => string, (x: number) => number] var e2 = t2[2]; // {} diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.errors.txt b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.errors.txt deleted file mode 100644 index 2e63bf0a795..00000000000 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.errors.txt +++ /dev/null @@ -1,215 +0,0 @@ -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(32,12): error TS2365: Operator '<' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(40,12): error TS2365: Operator '<' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(49,12): error TS2365: Operator '>' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(57,12): error TS2365: Operator '>' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(66,12): error TS2365: Operator '<=' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(74,12): error TS2365: Operator '<=' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(83,12): error TS2365: Operator '>=' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(91,12): error TS2365: Operator '>=' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(100,12): error TS2365: Operator '==' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(108,12): error TS2365: Operator '==' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(117,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(125,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(134,12): error TS2365: Operator '===' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(142,12): error TS2365: Operator '===' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(151,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts(159,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - - -==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts (16 errors) ==== - class Base { - public a: string; - } - - class Derived extends Base { - public b: string; - } - - var a1: { fn(x: T): T }; - var b1: { fn(x: string): string }; - - var a2: { fn(x: T): T }; - var b2: { fn(x: string, y: number): string }; - - var a3: { fn(x: T, y: U): T }; - var b3: { fn(x: string, y: number): string }; - - var a4: { fn(x?: T): T }; - var b4: { fn(x?: string): string }; - - var a5: { fn(...x: T[]): T }; - var b5: { fn(...x: string[]): string }; - - var a6: { fn(x: T, y: T): T }; - var b6: { fn(x: string, y: number): {} }; - - //var a7: { fn(x: T, y: U): T }; - var b7: { fn(x: Base, y: Derived): Base }; - - // operator < - var r1a1 = a1 < b1; - var r1a2 = a2 < b2; - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r1a3 = a3 < b3; - var r1a4 = a4 < b4; - var r1a5 = a5 < b5; - var r1a6 = a6 < b6; - //var r1a7 = a7 < b7; - - var r1b1 = b1 < a1; - var r1b2 = b2 < a2; - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r1b3 = b3 < a3; - var r1b4 = b4 < a4; - var r1b5 = b5 < a5; - var r1b6 = b6 < a6; - //var r1b7 = b7 < a7; - - // operator > - var r2a1 = a1 > b1; - var r2a2 = a2 > b2; - ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r2a3 = a3 > b3; - var r2a4 = a4 > b4; - var r2a5 = a5 > b5; - var r2a6 = a6 > b6; - //var r2a7 = a7 > b7; - - var r2b1 = b1 > a1; - var r2b2 = b2 > a2; - ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r2b3 = b3 > a3; - var r2b4 = b4 > a4; - var r2b5 = b5 > a5; - var r2b6 = b6 > a6; - //var r2b7 = b7 > a7; - - // operator <= - var r3a1 = a1 <= b1; - var r3a2 = a2 <= b2; - ~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r3a3 = a3 <= b3; - var r3a4 = a4 <= b4; - var r3a5 = a5 <= b5; - var r3a6 = a6 <= b6; - //var r3a7 = a7 <= b7; - - var r3b1 = b1 <= a1; - var r3b2 = b2 <= a2; - ~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r3b3 = b3 <= a3; - var r3b4 = b4 <= a4; - var r3b5 = b5 <= a5; - var r3b6 = b6 <= a6; - //var r3b7 = b7 <= a7; - - // operator >= - var r4a1 = a1 >= b1; - var r4a2 = a2 >= b2; - ~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r4a3 = a3 >= b3; - var r4a4 = a4 >= b4; - var r4a5 = a5 >= b5; - var r4a6 = a6 >= b6; - //var r4a7 = a7 >= b7; - - var r4b1 = b1 >= a1; - var r4b2 = b2 >= a2; - ~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r4b3 = b3 >= a3; - var r4b4 = b4 >= a4; - var r4b5 = b5 >= a5; - var r4b6 = b6 >= a6; - //var r4b7 = b7 >= a7; - - // operator == - var r5a1 = a1 == b1; - var r5a2 = a2 == b2; - ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r5a3 = a3 == b3; - var r5a4 = a4 == b4; - var r5a5 = a5 == b5; - var r5a6 = a6 == b6; - //var r5a7 = a7 == b7; - - var r5b1 = b1 == a1; - var r5b2 = b2 == a2; - ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r5b3 = b3 == a3; - var r5b4 = b4 == a4; - var r5b5 = b5 == a5; - var r5b6 = b6 == a6; - //var r5b7 = b7 == a7; - - // operator != - var r6a1 = a1 != b1; - var r6a2 = a2 != b2; - ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r6a3 = a3 != b3; - var r6a4 = a4 != b4; - var r6a5 = a5 != b5; - var r6a6 = a6 != b6; - //var r6a7 = a7 != b7; - - var r6b1 = b1 != a1; - var r6b2 = b2 != a2; - ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r6b3 = b3 != a3; - var r6b4 = b4 != a4; - var r6b5 = b5 != a5; - var r6b6 = b6 != a6; - //var r6b7 = b7 != a7; - - // operator === - var r7a1 = a1 === b1; - var r7a2 = a2 === b2; - ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r7a3 = a3 === b3; - var r7a4 = a4 === b4; - var r7a5 = a5 === b5; - var r7a6 = a6 === b6; - //var r7a7 = a7 === b7; - - var r7b1 = b1 === a1; - var r7b2 = b2 === a2; - ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r7b3 = b3 === a3; - var r7b4 = b4 === a4; - var r7b5 = b5 === a5; - var r7b6 = b6 === a6; - //var r7b7 = b7 === a7; - - // operator !== - var r8a1 = a1 !== b1; - var r8a2 = a2 !== b2; - ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(x: T): T; }' and '{ fn(x: string, y: number): string; }'. - var r8a3 = a3 !== b3; - var r8a4 = a4 !== b4; - var r8a5 = a5 !== b5; - var r8a6 = a6 !== b6; - //var r8a7 = a7 !== b7; - - var r8b1 = b1 !== a1; - var r8b2 = b2 !== a2; - ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(x: string, y: number): string; }' and '{ fn(x: T): T; }'. - var r8b3 = b3 !== a3; - var r8b4 = b4 !== a4; - var r8b5 = b5 !== a5; - var r8b6 = b6 !== a6; - //var r8b7 = b7 !== a7; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.types b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.types new file mode 100644 index 00000000000..c3f0d96e839 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.types @@ -0,0 +1,727 @@ +=== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.ts === +class Base { +>Base : Base + + public a: string; +>a : string +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + public b: string; +>b : string +} + +var a1: { fn(x: T): T }; +>a1 : { fn(x: T): T; } +>fn : (x: T) => T +>T : T +>x : T +>T : T +>T : T + +var b1: { fn(x: string): string }; +>b1 : { fn(x: string): string; } +>fn : (x: string) => string +>x : string + +var a2: { fn(x: T): T }; +>a2 : { fn(x: T): T; } +>fn : (x: T) => T +>T : T +>x : T +>T : T +>T : T + +var b2: { fn(x: string, y: number): string }; +>b2 : { fn(x: string, y: number): string; } +>fn : (x: string, y: number) => string +>x : string +>y : number + +var a3: { fn(x: T, y: U): T }; +>a3 : { fn(x: T, y: U): T; } +>fn : (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T + +var b3: { fn(x: string, y: number): string }; +>b3 : { fn(x: string, y: number): string; } +>fn : (x: string, y: number) => string +>x : string +>y : number + +var a4: { fn(x?: T): T }; +>a4 : { fn(x?: T): T; } +>fn : (x?: T) => T +>T : T +>x : T +>T : T +>T : T + +var b4: { fn(x?: string): string }; +>b4 : { fn(x?: string): string; } +>fn : (x?: string) => string +>x : string + +var a5: { fn(...x: T[]): T }; +>a5 : { fn(...x: T[]): T; } +>fn : (...x: T[]) => T +>T : T +>x : T[] +>T : T +>T : T + +var b5: { fn(...x: string[]): string }; +>b5 : { fn(...x: string[]): string; } +>fn : (...x: string[]) => string +>x : string[] + +var a6: { fn(x: T, y: T): T }; +>a6 : { fn(x: T, y: T): T; } +>fn : (x: T, y: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + +var b6: { fn(x: string, y: number): {} }; +>b6 : { fn(x: string, y: number): {}; } +>fn : (x: string, y: number) => {} +>x : string +>y : number + +//var a7: { fn(x: T, y: U): T }; +var b7: { fn(x: Base, y: Derived): Base }; +>b7 : { fn(x: Base, y: Derived): Base; } +>fn : (x: Base, y: Derived) => Base +>x : Base +>Base : Base +>y : Derived +>Derived : Derived +>Base : Base + +// operator < +var r1a1 = a1 < b1; +>r1a1 : boolean +>a1 < b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r1a2 = a2 < b2; +>r1a2 : boolean +>a2 < b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r1a3 = a3 < b3; +>r1a3 : boolean +>a3 < b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r1a4 = a4 < b4; +>r1a4 : boolean +>a4 < b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r1a5 = a5 < b5; +>r1a5 : boolean +>a5 < b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r1a6 = a6 < b6; +>r1a6 : boolean +>a6 < b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r1a7 = a7 < b7; + +var r1b1 = b1 < a1; +>r1b1 : boolean +>b1 < a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r1b2 = b2 < a2; +>r1b2 : boolean +>b2 < a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r1b3 = b3 < a3; +>r1b3 : boolean +>b3 < a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r1b4 = b4 < a4; +>r1b4 : boolean +>b4 < a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r1b5 = b5 < a5; +>r1b5 : boolean +>b5 < a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r1b6 = b6 < a6; +>r1b6 : boolean +>b6 < a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r1b7 = b7 < a7; + +// operator > +var r2a1 = a1 > b1; +>r2a1 : boolean +>a1 > b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r2a2 = a2 > b2; +>r2a2 : boolean +>a2 > b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r2a3 = a3 > b3; +>r2a3 : boolean +>a3 > b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r2a4 = a4 > b4; +>r2a4 : boolean +>a4 > b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r2a5 = a5 > b5; +>r2a5 : boolean +>a5 > b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r2a6 = a6 > b6; +>r2a6 : boolean +>a6 > b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r2a7 = a7 > b7; + +var r2b1 = b1 > a1; +>r2b1 : boolean +>b1 > a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r2b2 = b2 > a2; +>r2b2 : boolean +>b2 > a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r2b3 = b3 > a3; +>r2b3 : boolean +>b3 > a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r2b4 = b4 > a4; +>r2b4 : boolean +>b4 > a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r2b5 = b5 > a5; +>r2b5 : boolean +>b5 > a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r2b6 = b6 > a6; +>r2b6 : boolean +>b6 > a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r2b7 = b7 > a7; + +// operator <= +var r3a1 = a1 <= b1; +>r3a1 : boolean +>a1 <= b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r3a2 = a2 <= b2; +>r3a2 : boolean +>a2 <= b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r3a3 = a3 <= b3; +>r3a3 : boolean +>a3 <= b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r3a4 = a4 <= b4; +>r3a4 : boolean +>a4 <= b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r3a5 = a5 <= b5; +>r3a5 : boolean +>a5 <= b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r3a6 = a6 <= b6; +>r3a6 : boolean +>a6 <= b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r3a7 = a7 <= b7; + +var r3b1 = b1 <= a1; +>r3b1 : boolean +>b1 <= a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r3b2 = b2 <= a2; +>r3b2 : boolean +>b2 <= a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r3b3 = b3 <= a3; +>r3b3 : boolean +>b3 <= a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r3b4 = b4 <= a4; +>r3b4 : boolean +>b4 <= a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r3b5 = b5 <= a5; +>r3b5 : boolean +>b5 <= a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r3b6 = b6 <= a6; +>r3b6 : boolean +>b6 <= a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r3b7 = b7 <= a7; + +// operator >= +var r4a1 = a1 >= b1; +>r4a1 : boolean +>a1 >= b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r4a2 = a2 >= b2; +>r4a2 : boolean +>a2 >= b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r4a3 = a3 >= b3; +>r4a3 : boolean +>a3 >= b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r4a4 = a4 >= b4; +>r4a4 : boolean +>a4 >= b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r4a5 = a5 >= b5; +>r4a5 : boolean +>a5 >= b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r4a6 = a6 >= b6; +>r4a6 : boolean +>a6 >= b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r4a7 = a7 >= b7; + +var r4b1 = b1 >= a1; +>r4b1 : boolean +>b1 >= a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r4b2 = b2 >= a2; +>r4b2 : boolean +>b2 >= a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r4b3 = b3 >= a3; +>r4b3 : boolean +>b3 >= a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r4b4 = b4 >= a4; +>r4b4 : boolean +>b4 >= a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r4b5 = b5 >= a5; +>r4b5 : boolean +>b5 >= a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r4b6 = b6 >= a6; +>r4b6 : boolean +>b6 >= a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r4b7 = b7 >= a7; + +// operator == +var r5a1 = a1 == b1; +>r5a1 : boolean +>a1 == b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r5a2 = a2 == b2; +>r5a2 : boolean +>a2 == b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r5a3 = a3 == b3; +>r5a3 : boolean +>a3 == b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r5a4 = a4 == b4; +>r5a4 : boolean +>a4 == b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r5a5 = a5 == b5; +>r5a5 : boolean +>a5 == b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r5a6 = a6 == b6; +>r5a6 : boolean +>a6 == b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r5a7 = a7 == b7; + +var r5b1 = b1 == a1; +>r5b1 : boolean +>b1 == a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r5b2 = b2 == a2; +>r5b2 : boolean +>b2 == a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r5b3 = b3 == a3; +>r5b3 : boolean +>b3 == a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r5b4 = b4 == a4; +>r5b4 : boolean +>b4 == a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r5b5 = b5 == a5; +>r5b5 : boolean +>b5 == a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r5b6 = b6 == a6; +>r5b6 : boolean +>b6 == a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r5b7 = b7 == a7; + +// operator != +var r6a1 = a1 != b1; +>r6a1 : boolean +>a1 != b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r6a2 = a2 != b2; +>r6a2 : boolean +>a2 != b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r6a3 = a3 != b3; +>r6a3 : boolean +>a3 != b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r6a4 = a4 != b4; +>r6a4 : boolean +>a4 != b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r6a5 = a5 != b5; +>r6a5 : boolean +>a5 != b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r6a6 = a6 != b6; +>r6a6 : boolean +>a6 != b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r6a7 = a7 != b7; + +var r6b1 = b1 != a1; +>r6b1 : boolean +>b1 != a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r6b2 = b2 != a2; +>r6b2 : boolean +>b2 != a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r6b3 = b3 != a3; +>r6b3 : boolean +>b3 != a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r6b4 = b4 != a4; +>r6b4 : boolean +>b4 != a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r6b5 = b5 != a5; +>r6b5 : boolean +>b5 != a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r6b6 = b6 != a6; +>r6b6 : boolean +>b6 != a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r6b7 = b7 != a7; + +// operator === +var r7a1 = a1 === b1; +>r7a1 : boolean +>a1 === b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r7a2 = a2 === b2; +>r7a2 : boolean +>a2 === b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r7a3 = a3 === b3; +>r7a3 : boolean +>a3 === b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r7a4 = a4 === b4; +>r7a4 : boolean +>a4 === b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r7a5 = a5 === b5; +>r7a5 : boolean +>a5 === b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r7a6 = a6 === b6; +>r7a6 : boolean +>a6 === b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r7a7 = a7 === b7; + +var r7b1 = b1 === a1; +>r7b1 : boolean +>b1 === a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r7b2 = b2 === a2; +>r7b2 : boolean +>b2 === a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r7b3 = b3 === a3; +>r7b3 : boolean +>b3 === a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r7b4 = b4 === a4; +>r7b4 : boolean +>b4 === a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r7b5 = b5 === a5; +>r7b5 : boolean +>b5 === a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r7b6 = b6 === a6; +>r7b6 : boolean +>b6 === a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r7b7 = b7 === a7; + +// operator !== +var r8a1 = a1 !== b1; +>r8a1 : boolean +>a1 !== b1 : boolean +>a1 : { fn(x: T): T; } +>b1 : { fn(x: string): string; } + +var r8a2 = a2 !== b2; +>r8a2 : boolean +>a2 !== b2 : boolean +>a2 : { fn(x: T): T; } +>b2 : { fn(x: string, y: number): string; } + +var r8a3 = a3 !== b3; +>r8a3 : boolean +>a3 !== b3 : boolean +>a3 : { fn(x: T, y: U): T; } +>b3 : { fn(x: string, y: number): string; } + +var r8a4 = a4 !== b4; +>r8a4 : boolean +>a4 !== b4 : boolean +>a4 : { fn(x?: T): T; } +>b4 : { fn(x?: string): string; } + +var r8a5 = a5 !== b5; +>r8a5 : boolean +>a5 !== b5 : boolean +>a5 : { fn(...x: T[]): T; } +>b5 : { fn(...x: string[]): string; } + +var r8a6 = a6 !== b6; +>r8a6 : boolean +>a6 !== b6 : boolean +>a6 : { fn(x: T, y: T): T; } +>b6 : { fn(x: string, y: number): {}; } + +//var r8a7 = a7 !== b7; + +var r8b1 = b1 !== a1; +>r8b1 : boolean +>b1 !== a1 : boolean +>b1 : { fn(x: string): string; } +>a1 : { fn(x: T): T; } + +var r8b2 = b2 !== a2; +>r8b2 : boolean +>b2 !== a2 : boolean +>b2 : { fn(x: string, y: number): string; } +>a2 : { fn(x: T): T; } + +var r8b3 = b3 !== a3; +>r8b3 : boolean +>b3 !== a3 : boolean +>b3 : { fn(x: string, y: number): string; } +>a3 : { fn(x: T, y: U): T; } + +var r8b4 = b4 !== a4; +>r8b4 : boolean +>b4 !== a4 : boolean +>b4 : { fn(x?: string): string; } +>a4 : { fn(x?: T): T; } + +var r8b5 = b5 !== a5; +>r8b5 : boolean +>b5 !== a5 : boolean +>b5 : { fn(...x: string[]): string; } +>a5 : { fn(...x: T[]): T; } + +var r8b6 = b6 !== a6; +>r8b6 : boolean +>b6 !== a6 : boolean +>b6 : { fn(x: string, y: number): {}; } +>a6 : { fn(x: T, y: T): T; } + +//var r8b7 = b7 !== a7; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.errors.txt b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.errors.txt deleted file mode 100644 index 0e352ebcc9d..00000000000 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.errors.txt +++ /dev/null @@ -1,215 +0,0 @@ -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(32,12): error TS2365: Operator '<' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(40,12): error TS2365: Operator '<' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(49,12): error TS2365: Operator '>' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(57,12): error TS2365: Operator '>' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(66,12): error TS2365: Operator '<=' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(74,12): error TS2365: Operator '<=' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(83,12): error TS2365: Operator '>=' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(91,12): error TS2365: Operator '>=' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(100,12): error TS2365: Operator '==' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(108,12): error TS2365: Operator '==' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(117,12): error TS2365: Operator '!=' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(125,12): error TS2365: Operator '!=' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(134,12): error TS2365: Operator '===' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(142,12): error TS2365: Operator '===' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(151,12): error TS2365: Operator '!==' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts(159,12): error TS2365: Operator '!==' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - - -==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts (16 errors) ==== - class Base { - public a: string; - } - - class Derived extends Base { - public b: string; - } - - var a1: { new (x: T): T }; - var b1: { new (x: string): string }; - - var a2: { new (x: T): T }; - var b2: { new (x: string, y: number): string }; - - var a3: { new (x: T, y: U): T }; - var b3: { new (x: string, y: number): string }; - - var a4: { new (x?: T): T }; - var b4: { new (x?: string): string }; - - var a5: { new (...x: T[]): T }; - var b5: { new (...x: string[]): string }; - - var a6: { new (x: T, y: T): T }; - var b6: { new (x: string, y: number): {} }; - - //var a7: { new (x: T, y: U): T }; - var b7: { new (x: Base, y: Derived): Base }; - - // operator < - var r1a1 = a1 < b1; - var r1a2 = a2 < b2; - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r1a3 = a3 < b3; - var r1a4 = a4 < b4; - var r1a5 = a5 < b5; - var r1a6 = a6 < b6; - //var r1a7 = a7 < b7; - - var r1b1 = b1 < a1; - var r1b2 = b2 < a2; - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r1b3 = b3 < a3; - var r1b4 = b4 < a4; - var r1b5 = b5 < a5; - var r1b6 = b6 < a6; - //var r1b7 = b7 < a7; - - // operator > - var r2a1 = a1 > b1; - var r2a2 = a2 > b2; - ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r2a3 = a3 > b3; - var r2a4 = a4 > b4; - var r2a5 = a5 > b5; - var r2a6 = a6 > b6; - //var r2a7 = a7 > b7; - - var r2b1 = b1 > a1; - var r2b2 = b2 > a2; - ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r2b3 = b3 > a3; - var r2b4 = b4 > a4; - var r2b5 = b5 > a5; - var r2b6 = b6 > a6; - //var r2b7 = b7 > a7; - - // operator <= - var r3a1 = a1 <= b1; - var r3a2 = a2 <= b2; - ~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r3a3 = a3 <= b3; - var r3a4 = a4 <= b4; - var r3a5 = a5 <= b5; - var r3a6 = a6 <= b6; - //var r3a7 = a7 <= b7; - - var r3b1 = b1 <= a1; - var r3b2 = b2 <= a2; - ~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r3b3 = b3 <= a3; - var r3b4 = b4 <= a4; - var r3b5 = b5 <= a5; - var r3b6 = b6 <= a6; - //var r3b7 = b7 <= a7; - - // operator >= - var r4a1 = a1 >= b1; - var r4a2 = a2 >= b2; - ~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r4a3 = a3 >= b3; - var r4a4 = a4 >= b4; - var r4a5 = a5 >= b5; - var r4a6 = a6 >= b6; - //var r4a7 = a7 >= b7; - - var r4b1 = b1 >= a1; - var r4b2 = b2 >= a2; - ~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r4b3 = b3 >= a3; - var r4b4 = b4 >= a4; - var r4b5 = b5 >= a5; - var r4b6 = b6 >= a6; - //var r4b7 = b7 >= a7; - - // operator == - var r5a1 = a1 == b1; - var r5a2 = a2 == b2; - ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r5a3 = a3 == b3; - var r5a4 = a4 == b4; - var r5a5 = a5 == b5; - var r5a6 = a6 == b6; - //var r5a7 = a7 == b7; - - var r5b1 = b1 == a1; - var r5b2 = b2 == a2; - ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r5b3 = b3 == a3; - var r5b4 = b4 == a4; - var r5b5 = b5 == a5; - var r5b6 = b6 == a6; - //var r5b7 = b7 == a7; - - // operator != - var r6a1 = a1 != b1; - var r6a2 = a2 != b2; - ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r6a3 = a3 != b3; - var r6a4 = a4 != b4; - var r6a5 = a5 != b5; - var r6a6 = a6 != b6; - //var r6a7 = a7 != b7; - - var r6b1 = b1 != a1; - var r6b2 = b2 != a2; - ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r6b3 = b3 != a3; - var r6b4 = b4 != a4; - var r6b5 = b5 != a5; - var r6b6 = b6 != a6; - //var r6b7 = b7 != a7; - - // operator === - var r7a1 = a1 === b1; - var r7a2 = a2 === b2; - ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r7a3 = a3 === b3; - var r7a4 = a4 === b4; - var r7a5 = a5 === b5; - var r7a6 = a6 === b6; - //var r7a7 = a7 === b7; - - var r7b1 = b1 === a1; - var r7b2 = b2 === a2; - ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r7b3 = b3 === a3; - var r7b4 = b4 === a4; - var r7b5 = b5 === a5; - var r7b6 = b6 === a6; - //var r7b7 = b7 === a7; - - // operator !== - var r8a1 = a1 !== b1; - var r8a2 = a2 !== b2; - ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (x: T) => T' and 'new (x: string, y: number) => string'. - var r8a3 = a3 !== b3; - var r8a4 = a4 !== b4; - var r8a5 = a5 !== b5; - var r8a6 = a6 !== b6; - //var r8a7 = a7 !== b7; - - var r8b1 = b1 !== a1; - var r8b2 = b2 !== a2; - ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (x: string, y: number) => string' and 'new (x: T) => T'. - var r8b3 = b3 !== a3; - var r8b4 = b4 !== a4; - var r8b5 = b5 !== a5; - var r8b6 = b6 !== a6; - //var r8b7 = b7 !== a7; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.types b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.types new file mode 100644 index 00000000000..29d92c25726 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.types @@ -0,0 +1,714 @@ +=== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.ts === +class Base { +>Base : Base + + public a: string; +>a : string +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + public b: string; +>b : string +} + +var a1: { new (x: T): T }; +>a1 : new (x: T) => T +>T : T +>x : T +>T : T +>T : T + +var b1: { new (x: string): string }; +>b1 : new (x: string) => string +>x : string + +var a2: { new (x: T): T }; +>a2 : new (x: T) => T +>T : T +>x : T +>T : T +>T : T + +var b2: { new (x: string, y: number): string }; +>b2 : new (x: string, y: number) => string +>x : string +>y : number + +var a3: { new (x: T, y: U): T }; +>a3 : new (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T + +var b3: { new (x: string, y: number): string }; +>b3 : new (x: string, y: number) => string +>x : string +>y : number + +var a4: { new (x?: T): T }; +>a4 : new (x?: T) => T +>T : T +>x : T +>T : T +>T : T + +var b4: { new (x?: string): string }; +>b4 : new (x?: string) => string +>x : string + +var a5: { new (...x: T[]): T }; +>a5 : new (...x: T[]) => T +>T : T +>x : T[] +>T : T +>T : T + +var b5: { new (...x: string[]): string }; +>b5 : new (...x: string[]) => string +>x : string[] + +var a6: { new (x: T, y: T): T }; +>a6 : new (x: T, y: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + +var b6: { new (x: string, y: number): {} }; +>b6 : new (x: string, y: number) => {} +>x : string +>y : number + +//var a7: { new (x: T, y: U): T }; +var b7: { new (x: Base, y: Derived): Base }; +>b7 : new (x: Base, y: Derived) => Base +>x : Base +>Base : Base +>y : Derived +>Derived : Derived +>Base : Base + +// operator < +var r1a1 = a1 < b1; +>r1a1 : boolean +>a1 < b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r1a2 = a2 < b2; +>r1a2 : boolean +>a2 < b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r1a3 = a3 < b3; +>r1a3 : boolean +>a3 < b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r1a4 = a4 < b4; +>r1a4 : boolean +>a4 < b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r1a5 = a5 < b5; +>r1a5 : boolean +>a5 < b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r1a6 = a6 < b6; +>r1a6 : boolean +>a6 < b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r1a7 = a7 < b7; + +var r1b1 = b1 < a1; +>r1b1 : boolean +>b1 < a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r1b2 = b2 < a2; +>r1b2 : boolean +>b2 < a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r1b3 = b3 < a3; +>r1b3 : boolean +>b3 < a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r1b4 = b4 < a4; +>r1b4 : boolean +>b4 < a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r1b5 = b5 < a5; +>r1b5 : boolean +>b5 < a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r1b6 = b6 < a6; +>r1b6 : boolean +>b6 < a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r1b7 = b7 < a7; + +// operator > +var r2a1 = a1 > b1; +>r2a1 : boolean +>a1 > b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r2a2 = a2 > b2; +>r2a2 : boolean +>a2 > b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r2a3 = a3 > b3; +>r2a3 : boolean +>a3 > b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r2a4 = a4 > b4; +>r2a4 : boolean +>a4 > b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r2a5 = a5 > b5; +>r2a5 : boolean +>a5 > b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r2a6 = a6 > b6; +>r2a6 : boolean +>a6 > b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r2a7 = a7 > b7; + +var r2b1 = b1 > a1; +>r2b1 : boolean +>b1 > a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r2b2 = b2 > a2; +>r2b2 : boolean +>b2 > a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r2b3 = b3 > a3; +>r2b3 : boolean +>b3 > a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r2b4 = b4 > a4; +>r2b4 : boolean +>b4 > a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r2b5 = b5 > a5; +>r2b5 : boolean +>b5 > a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r2b6 = b6 > a6; +>r2b6 : boolean +>b6 > a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r2b7 = b7 > a7; + +// operator <= +var r3a1 = a1 <= b1; +>r3a1 : boolean +>a1 <= b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r3a2 = a2 <= b2; +>r3a2 : boolean +>a2 <= b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r3a3 = a3 <= b3; +>r3a3 : boolean +>a3 <= b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r3a4 = a4 <= b4; +>r3a4 : boolean +>a4 <= b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r3a5 = a5 <= b5; +>r3a5 : boolean +>a5 <= b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r3a6 = a6 <= b6; +>r3a6 : boolean +>a6 <= b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r3a7 = a7 <= b7; + +var r3b1 = b1 <= a1; +>r3b1 : boolean +>b1 <= a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r3b2 = b2 <= a2; +>r3b2 : boolean +>b2 <= a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r3b3 = b3 <= a3; +>r3b3 : boolean +>b3 <= a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r3b4 = b4 <= a4; +>r3b4 : boolean +>b4 <= a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r3b5 = b5 <= a5; +>r3b5 : boolean +>b5 <= a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r3b6 = b6 <= a6; +>r3b6 : boolean +>b6 <= a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r3b7 = b7 <= a7; + +// operator >= +var r4a1 = a1 >= b1; +>r4a1 : boolean +>a1 >= b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r4a2 = a2 >= b2; +>r4a2 : boolean +>a2 >= b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r4a3 = a3 >= b3; +>r4a3 : boolean +>a3 >= b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r4a4 = a4 >= b4; +>r4a4 : boolean +>a4 >= b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r4a5 = a5 >= b5; +>r4a5 : boolean +>a5 >= b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r4a6 = a6 >= b6; +>r4a6 : boolean +>a6 >= b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r4a7 = a7 >= b7; + +var r4b1 = b1 >= a1; +>r4b1 : boolean +>b1 >= a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r4b2 = b2 >= a2; +>r4b2 : boolean +>b2 >= a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r4b3 = b3 >= a3; +>r4b3 : boolean +>b3 >= a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r4b4 = b4 >= a4; +>r4b4 : boolean +>b4 >= a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r4b5 = b5 >= a5; +>r4b5 : boolean +>b5 >= a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r4b6 = b6 >= a6; +>r4b6 : boolean +>b6 >= a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r4b7 = b7 >= a7; + +// operator == +var r5a1 = a1 == b1; +>r5a1 : boolean +>a1 == b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r5a2 = a2 == b2; +>r5a2 : boolean +>a2 == b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r5a3 = a3 == b3; +>r5a3 : boolean +>a3 == b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r5a4 = a4 == b4; +>r5a4 : boolean +>a4 == b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r5a5 = a5 == b5; +>r5a5 : boolean +>a5 == b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r5a6 = a6 == b6; +>r5a6 : boolean +>a6 == b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r5a7 = a7 == b7; + +var r5b1 = b1 == a1; +>r5b1 : boolean +>b1 == a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r5b2 = b2 == a2; +>r5b2 : boolean +>b2 == a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r5b3 = b3 == a3; +>r5b3 : boolean +>b3 == a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r5b4 = b4 == a4; +>r5b4 : boolean +>b4 == a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r5b5 = b5 == a5; +>r5b5 : boolean +>b5 == a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r5b6 = b6 == a6; +>r5b6 : boolean +>b6 == a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r5b7 = b7 == a7; + +// operator != +var r6a1 = a1 != b1; +>r6a1 : boolean +>a1 != b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r6a2 = a2 != b2; +>r6a2 : boolean +>a2 != b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r6a3 = a3 != b3; +>r6a3 : boolean +>a3 != b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r6a4 = a4 != b4; +>r6a4 : boolean +>a4 != b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r6a5 = a5 != b5; +>r6a5 : boolean +>a5 != b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r6a6 = a6 != b6; +>r6a6 : boolean +>a6 != b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r6a7 = a7 != b7; + +var r6b1 = b1 != a1; +>r6b1 : boolean +>b1 != a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r6b2 = b2 != a2; +>r6b2 : boolean +>b2 != a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r6b3 = b3 != a3; +>r6b3 : boolean +>b3 != a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r6b4 = b4 != a4; +>r6b4 : boolean +>b4 != a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r6b5 = b5 != a5; +>r6b5 : boolean +>b5 != a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r6b6 = b6 != a6; +>r6b6 : boolean +>b6 != a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r6b7 = b7 != a7; + +// operator === +var r7a1 = a1 === b1; +>r7a1 : boolean +>a1 === b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r7a2 = a2 === b2; +>r7a2 : boolean +>a2 === b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r7a3 = a3 === b3; +>r7a3 : boolean +>a3 === b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r7a4 = a4 === b4; +>r7a4 : boolean +>a4 === b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r7a5 = a5 === b5; +>r7a5 : boolean +>a5 === b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r7a6 = a6 === b6; +>r7a6 : boolean +>a6 === b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r7a7 = a7 === b7; + +var r7b1 = b1 === a1; +>r7b1 : boolean +>b1 === a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r7b2 = b2 === a2; +>r7b2 : boolean +>b2 === a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r7b3 = b3 === a3; +>r7b3 : boolean +>b3 === a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r7b4 = b4 === a4; +>r7b4 : boolean +>b4 === a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r7b5 = b5 === a5; +>r7b5 : boolean +>b5 === a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r7b6 = b6 === a6; +>r7b6 : boolean +>b6 === a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r7b7 = b7 === a7; + +// operator !== +var r8a1 = a1 !== b1; +>r8a1 : boolean +>a1 !== b1 : boolean +>a1 : new (x: T) => T +>b1 : new (x: string) => string + +var r8a2 = a2 !== b2; +>r8a2 : boolean +>a2 !== b2 : boolean +>a2 : new (x: T) => T +>b2 : new (x: string, y: number) => string + +var r8a3 = a3 !== b3; +>r8a3 : boolean +>a3 !== b3 : boolean +>a3 : new (x: T, y: U) => T +>b3 : new (x: string, y: number) => string + +var r8a4 = a4 !== b4; +>r8a4 : boolean +>a4 !== b4 : boolean +>a4 : new (x?: T) => T +>b4 : new (x?: string) => string + +var r8a5 = a5 !== b5; +>r8a5 : boolean +>a5 !== b5 : boolean +>a5 : new (...x: T[]) => T +>b5 : new (...x: string[]) => string + +var r8a6 = a6 !== b6; +>r8a6 : boolean +>a6 !== b6 : boolean +>a6 : new (x: T, y: T) => T +>b6 : new (x: string, y: number) => {} + +//var r8a7 = a7 !== b7; + +var r8b1 = b1 !== a1; +>r8b1 : boolean +>b1 !== a1 : boolean +>b1 : new (x: string) => string +>a1 : new (x: T) => T + +var r8b2 = b2 !== a2; +>r8b2 : boolean +>b2 !== a2 : boolean +>b2 : new (x: string, y: number) => string +>a2 : new (x: T) => T + +var r8b3 = b3 !== a3; +>r8b3 : boolean +>b3 !== a3 : boolean +>b3 : new (x: string, y: number) => string +>a3 : new (x: T, y: U) => T + +var r8b4 = b4 !== a4; +>r8b4 : boolean +>b4 !== a4 : boolean +>b4 : new (x?: string) => string +>a4 : new (x?: T) => T + +var r8b5 = b5 !== a5; +>r8b5 : boolean +>b5 !== a5 : boolean +>b5 : new (...x: string[]) => string +>a5 : new (...x: T[]) => T + +var r8b6 = b6 !== a6; +>r8b6 : boolean +>b6 !== a6 : boolean +>b6 : new (x: string, y: number) => {} +>a6 : new (x: T, y: T) => T + +//var r8b7 = b7 !== a7; diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index edef88acfc3..f925f7f1db6 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -169,7 +169,7 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2; >result10 : (t: X) => any >t : X >X : X ->true ? (m) => m.propertyX1 : (n) => n.propertyX2 : { (m: X): number; } | { (n: X): string; } +>true ? (m) => m.propertyX1 : (n) => n.propertyX2 : ((m: X) => number) | ((n: X) => string) >(m) => m.propertyX1 : (m: X) => number >m : X >m.propertyX1 : number diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt index fb2c02d1c28..b1dd23fc3e3 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt @@ -4,13 +4,13 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type 'A | B' is not assignable to type 'B': Type 'A' is not assignable to type 'B': Property 'propertyB' is missing in type 'A'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(18,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => number': +tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(18,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number': Type '(n: X) => string' is not assignable to type '(t: X) => number': Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => string': +tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string': Type '(m: X) => number' is not assignable to type '(t: X) => string': Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => boolean': +tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean': Type '(m: X) => number' is not assignable to type '(t: X) => boolean': Type 'number' is not assignable to type 'boolean'. @@ -43,16 +43,16 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2; ~~~~~~~ -!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => number': +!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number': !!! error TS2322: Type '(n: X) => string' is not assignable to type '(t: X) => number': !!! error TS2322: Type 'string' is not assignable to type 'number'. var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2; ~~~~~~~ -!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => string': +!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string': !!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => string': !!! error TS2322: Type 'number' is not assignable to type 'string'. var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2; ~~~~~~~ -!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => boolean': +!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean': !!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => boolean': !!! error TS2322: Type 'number' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstantiation.js b/tests/baselines/reference/contextualSignatureInstantiation.js new file mode 100644 index 00000000000..11e19b3262e --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstantiation.js @@ -0,0 +1,50 @@ +//// [contextualSignatureInstantiation.ts] +// TypeScript Spec, section 4.12.2: +// If e is an expression of a function type that contains exactly one generic call signature and no other members, +// and T is a function type with exactly one non - generic call signature and no other members, then any inferences +// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed +// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). + +declare function foo(cb: (x: number, y: string) => T): T; +declare function bar(x: T, y: U, cb: (x: T, y: U) => V): V; +declare function baz(x: T, y: T, cb: (x: T, y: T) => U): U; + +declare function g(x: T, y: T): T; +declare function h(x: T, y: U): T[] | U[]; + +var a: number; +var a = bar(1, 1, g); // Should be number +var a = baz(1, 1, g); // Should be number + +var b: number | string; +var b = foo(g); // Should be number | string +var b = bar(1, "one", g); // Should be number | string +var b = bar("one", 1, g); // Should be number | string +var b = baz(b, b, g); // Should be number | string + +var d: number[] | string[]; +var d = foo(h); // Should be number[] | string[] +var d = bar(1, "one", h); // Should be number[] | string[] +var d = bar("one", 1, h); // Should be number[] | string[] +var d = baz(d, d, g); // Should be number[] | string[] + + +//// [contextualSignatureInstantiation.js] +// TypeScript Spec, section 4.12.2: +// If e is an expression of a function type that contains exactly one generic call signature and no other members, +// and T is a function type with exactly one non - generic call signature and no other members, then any inferences +// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed +// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). +var a; +var a = bar(1, 1, g); // Should be number +var a = baz(1, 1, g); // Should be number +var b; +var b = foo(g); // Should be number | string +var b = bar(1, "one", g); // Should be number | string +var b = bar("one", 1, g); // Should be number | string +var b = baz(b, b, g); // Should be number | string +var d; +var d = foo(h); // Should be number[] | string[] +var d = bar(1, "one", h); // Should be number[] | string[] +var d = bar("one", 1, h); // Should be number[] | string[] +var d = baz(d, d, g); // Should be number[] | string[] diff --git a/tests/baselines/reference/contextualSignatureInstantiation.types b/tests/baselines/reference/contextualSignatureInstantiation.types new file mode 100644 index 00000000000..4363272622a --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstantiation.types @@ -0,0 +1,142 @@ +=== tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts === +// TypeScript Spec, section 4.12.2: +// If e is an expression of a function type that contains exactly one generic call signature and no other members, +// and T is a function type with exactly one non - generic call signature and no other members, then any inferences +// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed +// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). + +declare function foo(cb: (x: number, y: string) => T): T; +>foo : (cb: (x: number, y: string) => T) => T +>T : T +>cb : (x: number, y: string) => T +>x : number +>y : string +>T : T +>T : T + +declare function bar(x: T, y: U, cb: (x: T, y: U) => V): V; +>bar : (x: T, y: U, cb: (x: T, y: U) => V) => V +>T : T +>U : U +>V : V +>x : T +>T : T +>y : U +>U : U +>cb : (x: T, y: U) => V +>x : T +>T : T +>y : U +>U : U +>V : V +>V : V + +declare function baz(x: T, y: T, cb: (x: T, y: T) => U): U; +>baz : (x: T, y: T, cb: (x: T, y: T) => U) => U +>T : T +>U : U +>x : T +>T : T +>y : T +>T : T +>cb : (x: T, y: T) => U +>x : T +>T : T +>y : T +>T : T +>U : U +>U : U + +declare function g(x: T, y: T): T; +>g : (x: T, y: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + +declare function h(x: T, y: U): T[] | U[]; +>h : (x: T, y: U) => T[] | U[] +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T +>U : U + +var a: number; +>a : number + +var a = bar(1, 1, g); // Should be number +>a : number +>bar(1, 1, g) : number +>bar : (x: T, y: U, cb: (x: T, y: U) => V) => V +>g : (x: T, y: T) => T + +var a = baz(1, 1, g); // Should be number +>a : number +>baz(1, 1, g) : number +>baz : (x: T, y: T, cb: (x: T, y: T) => U) => U +>g : (x: T, y: T) => T + +var b: number | string; +>b : string | number + +var b = foo(g); // Should be number | string +>b : string | number +>foo(g) : string | number +>foo : (cb: (x: number, y: string) => T) => T +>g : (x: T, y: T) => T + +var b = bar(1, "one", g); // Should be number | string +>b : string | number +>bar(1, "one", g) : string | number +>bar : (x: T, y: U, cb: (x: T, y: U) => V) => V +>g : (x: T, y: T) => T + +var b = bar("one", 1, g); // Should be number | string +>b : string | number +>bar("one", 1, g) : string | number +>bar : (x: T, y: U, cb: (x: T, y: U) => V) => V +>g : (x: T, y: T) => T + +var b = baz(b, b, g); // Should be number | string +>b : string | number +>baz(b, b, g) : string | number +>baz : (x: T, y: T, cb: (x: T, y: T) => U) => U +>b : string | number +>b : string | number +>g : (x: T, y: T) => T + +var d: number[] | string[]; +>d : string[] | number[] + +var d = foo(h); // Should be number[] | string[] +>d : string[] | number[] +>foo(h) : string[] | number[] +>foo : (cb: (x: number, y: string) => T) => T +>h : (x: T, y: U) => T[] | U[] + +var d = bar(1, "one", h); // Should be number[] | string[] +>d : string[] | number[] +>bar(1, "one", h) : string[] | number[] +>bar : (x: T, y: U, cb: (x: T, y: U) => V) => V +>h : (x: T, y: U) => T[] | U[] + +var d = bar("one", 1, h); // Should be number[] | string[] +>d : string[] | number[] +>bar("one", 1, h) : string[] | number[] +>bar : (x: T, y: U, cb: (x: T, y: U) => V) => V +>h : (x: T, y: U) => T[] | U[] + +var d = baz(d, d, g); // Should be number[] | string[] +>d : string[] | number[] +>baz(d, d, g) : string[] | number[] +>baz : (x: T, y: T, cb: (x: T, y: T) => U) => U +>d : string[] | number[] +>d : string[] | number[] +>g : (x: T, y: T) => T + diff --git a/tests/baselines/reference/contextualTyping21.errors.txt b/tests/baselines/reference/contextualTyping21.errors.txt index 620b0635d12..c6ca82d87ac 100644 --- a/tests/baselines/reference/contextualTyping21.errors.txt +++ b/tests/baselines/reference/contextualTyping21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type 'Array' is not assignable to type '{ id: number; }[]': +tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]': Type 'number | { id: number; }' is not assignable to type '{ id: number; }': Type 'number' is not assignable to type '{ id: number; }': Property 'id' is missing in type 'Number'. @@ -7,7 +7,7 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type 'Array' is not assignable to type '{ id: number; }[]': +!!! error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]': !!! error TS2322: Type 'number | { id: number; }' is not assignable to type '{ id: number; }': !!! error TS2322: Type 'number' is not assignable to type '{ id: number; }': !!! error TS2322: Property 'id' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping30.errors.txt b/tests/baselines/reference/contextualTyping30.errors.txt index 4c8d87d41b6..f7a9eeead35 100644 --- a/tests/baselines/reference/contextualTyping30.errors.txt +++ b/tests/baselines/reference/contextualTyping30.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. Type 'string | number' is not assignable to type 'number': Type 'string' is not assignable to type 'number'. @@ -6,6 +6,6 @@ tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type ==== tests/cases/compiler/contextualTyping30.ts (1 errors) ==== function foo(param:number[]){}; foo([1, "a"]); ~~~~~~~~ -!!! error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. !!! error TS2345: Type 'string | number' is not assignable to type 'number': !!! error TS2345: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping32.types b/tests/baselines/reference/contextualTyping32.types index 383615aec3c..c273be967e3 100644 --- a/tests/baselines/reference/contextualTyping32.types +++ b/tests/baselines/reference/contextualTyping32.types @@ -5,7 +5,7 @@ function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){ret >i : number >foo([function(){return 1;}, function(){return 4}]) : void >foo : (param: { (): number; (i: number): number; }[]) => void ->[function(){return 1;}, function(){return 4}] : { (): number; }[] +>[function(){return 1;}, function(){return 4}] : (() => number)[] >function(){return 1;} : () => number >function(){return 4} : () => number diff --git a/tests/baselines/reference/contextualTyping33.errors.txt b/tests/baselines/reference/contextualTyping33.errors.txt index 82799037ec6..4aafb6d9645 100644 --- a/tests/baselines/reference/contextualTyping33.errors.txt +++ b/tests/baselines/reference/contextualTyping33.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type 'Array<{ (): number; } | { (): string; }>' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. - Type '{ (): number; } | { (): string; }' is not assignable to type '{ (): number; (i: number): number; }': +tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. + Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }': Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'. ==== tests/cases/compiler/contextualTyping33.ts (1 errors) ==== function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){return 1;}, function(){return "foo"}]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'Array<{ (): number; } | { (): string; }>' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. -!!! error TS2345: Type '{ (): number; } | { (): string; }' is not assignable to type '{ (): number; (i: number): number; }': +!!! error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. +!!! error TS2345: Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }': !!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.types b/tests/baselines/reference/contextualTypingArrayOfLambdas.types index f3bb8bab70f..d3e5b9942e3 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.types +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.types @@ -23,8 +23,8 @@ class C extends A { } var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; ->xs : { (x: A): void; }[] ->[(x: A) => { }, (x: B) => { }, (x: C) => { }] : { (x: A): void; }[] +>xs : ((x: A) => void)[] +>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[] >(x: A) => { } : (x: A) => void >x : A >A : A diff --git a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt index cb3b439681e..92b74829e55 100644 --- a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type 'Array' is not assignable to type 'I': +tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(number | Date)[]' is not assignable to type 'I': Index signatures are incompatible: Type 'number | Date' is not assignable to type 'Date': Type 'number' is not assignable to type 'Date': @@ -12,7 +12,7 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ var x3: I = [new Date(), 1]; ~~ -!!! error TS2322: Type 'Array' is not assignable to type 'I': +!!! error TS2322: Type '(number | Date)[]' is not assignable to type 'I': !!! error TS2322: Index signatures are incompatible: !!! error TS2322: Type 'number | Date' is not assignable to type 'Date': !!! error TS2322: Type 'number' is not assignable to type 'Date': diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt index 574e25c6f45..3bcfb557048 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2322: Type '{ (a: C): number; } | { (b: number): void; }' is not assignable to type '(a: A) => void': +tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2322: Type '((a: C) => number) | ((b: number) => void)' is not assignable to type '(a: A) => void': Type '(b: number) => void' is not assignable to type '(a: A) => void': Types of parameters 'b' and 'a' are incompatible: Type 'number' is not assignable to type 'A': @@ -18,7 +18,7 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { }; ~~ -!!! error TS2322: Type '{ (a: C): number; } | { (b: number): void; }' is not assignable to type '(a: A) => void': +!!! error TS2322: Type '((a: C) => number) | ((b: number) => void)' is not assignable to type '(a: A) => void': !!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void': !!! error TS2322: Types of parameters 'b' and 'a' are incompatible: !!! error TS2322: Type 'number' is not assignable to type 'A': diff --git a/tests/baselines/reference/contextuallyTypingOrOperator.types b/tests/baselines/reference/contextuallyTypingOrOperator.types index 4b47ea763bc..47b78f5691d 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator.types @@ -17,10 +17,10 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; >s : string var v2 = (s: string) => s.length || function (s) { s.length }; ->v2 : (s: string) => number | { (s: any): void; } ->(s: string) => s.length || function (s) { s.length } : (s: string) => number | { (s: any): void; } +>v2 : (s: string) => number | ((s: any) => void) +>(s: string) => s.length || function (s) { s.length } : (s: string) => number | ((s: any) => void) >s : string ->s.length || function (s) { s.length } : number | { (s: any): void; } +>s.length || function (s) { s.length } : number | ((s: any) => void) >s.length : number >s : string >length : number @@ -31,10 +31,10 @@ var v2 = (s: string) => s.length || function (s) { s.length }; >length : any var v3 = (s: string) => s.length || function (s: number) { return 1 }; ->v3 : (s: string) => number | { (s: number): number; } ->(s: string) => s.length || function (s: number) { return 1 } : (s: string) => number | { (s: number): number; } +>v3 : (s: string) => number | ((s: number) => number) +>(s: string) => s.length || function (s: number) { return 1 } : (s: string) => number | ((s: number) => number) >s : string ->s.length || function (s: number) { return 1 } : number | { (s: number): number; } +>s.length || function (s: number) { return 1 } : number | ((s: number) => number) >s.length : number >s : string >length : number @@ -42,10 +42,10 @@ var v3 = (s: string) => s.length || function (s: number) { return 1 }; >s : number var v4 = (s: number) => 1 || function (s: string) { return s.length }; ->v4 : (s: number) => number | { (s: string): number; } ->(s: number) => 1 || function (s: string) { return s.length } : (s: number) => number | { (s: string): number; } +>v4 : (s: number) => number | ((s: string) => number) +>(s: number) => 1 || function (s: string) { return s.length } : (s: number) => number | ((s: string) => number) >s : number ->1 || function (s: string) { return s.length } : number | { (s: string): number; } +>1 || function (s: string) { return s.length } : number | ((s: string) => number) >function (s: string) { return s.length } : (s: string) => number >s : string >s.length : number diff --git a/tests/baselines/reference/contextuallyTypingOrOperator2.types b/tests/baselines/reference/contextuallyTypingOrOperator2.types index c233066d6dc..65ed442d5e9 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator2.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator2.types @@ -17,10 +17,10 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; >s : string var v2 = (s: string) => s.length || function (s) { s.aaa }; ->v2 : (s: string) => number | { (s: any): void; } ->(s: string) => s.length || function (s) { s.aaa } : (s: string) => number | { (s: any): void; } +>v2 : (s: string) => number | ((s: any) => void) +>(s: string) => s.length || function (s) { s.aaa } : (s: string) => number | ((s: any) => void) >s : string ->s.length || function (s) { s.aaa } : number | { (s: any): void; } +>s.length || function (s) { s.aaa } : number | ((s: any) => void) >s.length : number >s : string >length : number diff --git a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.types b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.types index 47b7ed95dc6..36b85d7950c 100644 --- a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.types +++ b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.types @@ -49,7 +49,7 @@ b = d2; var r: Base[] = [d1, d2]; >r : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived | Derived2)[] >d1 : Derived >d2 : Derived2 diff --git a/tests/baselines/reference/enumBasics.types b/tests/baselines/reference/enumBasics.types index 696e68eded2..c0d7fb9bed1 100644 --- a/tests/baselines/reference/enumBasics.types +++ b/tests/baselines/reference/enumBasics.types @@ -157,8 +157,8 @@ enum E9 { // (refer to .js to validate) // Enum constant members are propagated var doNotPropagate = [ ->doNotPropagate : Array ->[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : Array +>doNotPropagate : (E3 | E4 | E7 | E8)[] +>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : (E3 | E4 | E7 | E8)[] E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z >E8.B : E8 @@ -183,8 +183,8 @@ var doNotPropagate = [ ]; // Enum computed members are not propagated var doPropagate = [ ->doPropagate : Array ->[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : Array +>doPropagate : (E5 | E6 | E9)[] +>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E5 | E6 | E9)[] E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C >E9.A : E9 diff --git a/tests/baselines/reference/enumIdentifierLiterals.errors.txt b/tests/baselines/reference/enumIdentifierLiterals.errors.txt index 6327e40289a..60d8ed81f84 100644 --- a/tests/baselines/reference/enumIdentifierLiterals.errors.txt +++ b/tests/baselines/reference/enumIdentifierLiterals.errors.txt @@ -1,11 +1,10 @@ tests/cases/compiler/enumIdentifierLiterals.ts(2,5): error TS1151: An enum member cannot have a numeric name. tests/cases/compiler/enumIdentifierLiterals.ts(3,5): error TS1151: An enum member cannot have a numeric name. tests/cases/compiler/enumIdentifierLiterals.ts(4,5): error TS1151: An enum member cannot have a numeric name. -tests/cases/compiler/enumIdentifierLiterals.ts(5,5): error TS1151: An enum member cannot have a numeric name. tests/cases/compiler/enumIdentifierLiterals.ts(6,5): error TS1151: An enum member cannot have a numeric name. -==== tests/cases/compiler/enumIdentifierLiterals.ts (5 errors) ==== +==== tests/cases/compiler/enumIdentifierLiterals.ts (4 errors) ==== enum Nums { 1.0, ~~~ @@ -17,8 +16,6 @@ tests/cases/compiler/enumIdentifierLiterals.ts(6,5): error TS1151: An enum membe ~~~~~~ !!! error TS1151: An enum member cannot have a numeric name. "13e-1", - ~~~~~~~ -!!! error TS1151: An enum member cannot have a numeric name. 0xF00D ~~~~~~ !!! error TS1151: An enum member cannot have a numeric name. diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 66e8a2a66df..53ecb88363d 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array>'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. for( var arr = [new C(), new C2(), new D()];;){} ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array>'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.js b/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.js index 37bcf84669c..f58b1047b8f 100644 --- a/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.js +++ b/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.js @@ -11,6 +11,4 @@ function foo(args) { //// [functionDeclarationWithArgumentOfTypeFunctionTypeArray.d.ts] -declare function foo(args: { - (x: any): number; -}[]): number; +declare function foo(args: ((x: any) => number)[]): number; diff --git a/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.types b/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.types index af751fbb0e9..a1d32a2a405 100644 --- a/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.types +++ b/tests/baselines/reference/functionDeclarationWithArgumentOfTypeFunctionTypeArray.types @@ -1,12 +1,12 @@ === tests/cases/compiler/functionDeclarationWithArgumentOfTypeFunctionTypeArray.ts === function foo(args: { (x): number }[]) { ->foo : (args: { (x: any): number; }[]) => number ->args : { (x: any): number; }[] +>foo : (args: ((x: any) => number)[]) => number +>args : ((x: any) => number)[] >x : any return args.length; >args.length : number ->args : { (x: any): number; }[] +>args : ((x: any) => number)[] >length : number } diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.types b/tests/baselines/reference/functionSubtypingOfVarArgs2.types index 2f81898c7de..5e2b14ffc7a 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.types +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.types @@ -3,7 +3,7 @@ class EventBase { >EventBase : EventBase private _listeners: { (...args: any[]): void; }[] = []; ->_listeners : { (...args: any[]): void; }[] +>_listeners : ((...args: any[]) => void)[] >args : any[] >[] : undefined[] @@ -14,11 +14,11 @@ class EventBase { this._listeners.push(listener); >this._listeners.push(listener) : number ->this._listeners.push : (...items: { (...args: any[]): void; }[]) => number ->this._listeners : { (...args: any[]): void; }[] +>this._listeners.push : (...items: ((...args: any[]) => void)[]) => number +>this._listeners : ((...args: any[]) => void)[] >this : EventBase ->_listeners : { (...args: any[]): void; }[] ->push : (...items: { (...args: any[]): void; }[]) => number +>_listeners : ((...args: any[]) => void)[] +>push : (...items: ((...args: any[]) => void)[]) => number >listener : (...args: any[]) => void } } diff --git a/tests/baselines/reference/functionTypesLackingReturnTypes.errors.txt b/tests/baselines/reference/functionTypesLackingReturnTypes.errors.txt index a0be6f32df0..84ec6ff1ba5 100644 --- a/tests/baselines/reference/functionTypesLackingReturnTypes.errors.txt +++ b/tests/baselines/reference/functionTypesLackingReturnTypes.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/functionTypesLackingReturnTypes.ts(3,17): error TS1005: '=>' expected. -tests/cases/compiler/functionTypesLackingReturnTypes.ts(7,15): error TS1005: '=>' expected. +tests/cases/compiler/functionTypesLackingReturnTypes.ts(7,9): error TS2304: Cannot find name 'param'. ==== tests/cases/compiler/functionTypesLackingReturnTypes.ts (2 errors) ==== @@ -12,8 +12,8 @@ tests/cases/compiler/functionTypesLackingReturnTypes.ts(7,15): error TS1005: '=> // Error (no '=>') var g: (param); - ~ -!!! error TS1005: '=>' expected. + ~~~~~ +!!! error TS2304: Cannot find name 'param'. // Okay var h: { () } diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt new file mode 100644 index 00000000000..2b14bd97bad --- /dev/null +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt @@ -0,0 +1,112 @@ +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(58,1): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(67,1): error TS2354: No best common type exists among return expressions. + + +==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts (2 errors) ==== + // return type of a function with multiple returns is the BCT of each return statement + // no errors expected here + + function f1() { + if (true) { + return 1; + } else { + return null; + } + } + + function f2() { + if (true) { + return 1; + } else if (false) { + return null; + } else { + return 2; + } + } + + function f4() { + try { + return 1; + } + catch (e) { + return undefined; + } + finally { + return 1; + } + } + + function f5() { + return 1; + return new Object(); + } + + function f6(x: T) { + if (true) { + return x; + } else { + return null; + } + } + + //function f7(x: T, y: U) { + // if (true) { + // return x; + // } else { + // return y; + // } + //} + + var a: { x: number; y?: number }; + var b: { x: number; z?: number }; + // returns typeof a + function f9() { + ~~~~~~~~~~~~~~~ + if (true) { + ~~~~~~~~~~~~~~~ + return a; + ~~~~~~~~~~~~~~~~~ + } else { + ~~~~~~~~~~~~ + return b; + ~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS2354: No best common type exists among return expressions. + + // returns typeof b + function f10() { + ~~~~~~~~~~~~~~~~ + if (true) { + ~~~~~~~~~~~~~~~ + return b; + ~~~~~~~~~~~~~~~~~ + } else { + ~~~~~~~~~~~~ + return a; + ~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS2354: No best common type exists among return expressions. + + // returns number => void + function f11() { + if (true) { + return (x: number) => { } + } else { + return (x: Object) => { } + } + } + + // returns Object => void + function f12() { + if (true) { + return (x: Object) => { } + } else { + return (x: number) => { } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.types b/tests/baselines/reference/functionWithMultipleReturnStatements2.types deleted file mode 100644 index 706aca40c94..00000000000 --- a/tests/baselines/reference/functionWithMultipleReturnStatements2.types +++ /dev/null @@ -1,146 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts === -// return type of a function with multiple returns is the BCT of each return statement -// no errors expected here - -function f1() { ->f1 : () => number - - if (true) { - return 1; - } else { - return null; - } -} - -function f2() { ->f2 : () => number - - if (true) { - return 1; - } else if (false) { - return null; - } else { - return 2; - } -} - -function f4() { ->f4 : () => number - - try { - return 1; - } - catch (e) { ->e : any - - return undefined; ->undefined : undefined - } - finally { - return 1; - } -} - -function f5() { ->f5 : () => Object - - return 1; - return new Object(); ->new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } -} - -function f6(x: T) { ->f6 : (x: T) => T ->T : T ->x : T ->T : T - - if (true) { - return x; ->x : T - - } else { - return null; - } -} - -//function f7(x: T, y: U) { -// if (true) { -// return x; -// } else { -// return y; -// } -//} - -var a: { x: number; y?: number }; ->a : { x: number; y?: number; } ->x : number ->y : number - -var b: { x: number; z?: number }; ->b : { x: number; z?: number; } ->x : number ->z : number - -// returns typeof a -function f9() { ->f9 : () => { x: number; y?: number; } - - if (true) { - return a; ->a : { x: number; y?: number; } - - } else { - return b; ->b : { x: number; z?: number; } - } -} - -// returns typeof b -function f10() { ->f10 : () => { x: number; z?: number; } - - if (true) { - return b; ->b : { x: number; z?: number; } - - } else { - return a; ->a : { x: number; y?: number; } - } -} - -// returns number => void -function f11() { ->f11 : () => (x: number) => void - - if (true) { - return (x: number) => { } ->(x: number) => { } : (x: number) => void ->x : number - - } else { - return (x: Object) => { } ->(x: Object) => { } : (x: Object) => void ->x : Object ->Object : Object - } -} - -// returns Object => void -function f12() { ->f12 : () => (x: Object) => void - - if (true) { - return (x: Object) => { } ->(x: Object) => { } : (x: Object) => void ->x : Object ->Object : Object - - } else { - return (x: number) => { } ->(x: number) => { } : (x: number) => void ->x : number - } -} diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 78fc6f6cfef..79787f6d994 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -34,57 +34,57 @@ var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); var x1: () => Base[] = () => [d1, d2]; >x1 : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x2: () => Base[] = function() { return [d1, d2] }; >x2 : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x3: () => Base[] = function named() { return [d1, d2] }; >x3 : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x4: { (): Base[]; } = () => [d1, d2]; >x4 : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x5: { (): Base[]; } = function() { return [d1, d2] }; >x5 : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x6: { (): Base[]; } = function named() { return [d1, d2] }; >x6 : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x7: Base[] = [d1, d2]; >x7 : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -92,7 +92,7 @@ var x8: Array = [d1, d2]; >x8 : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -100,7 +100,7 @@ var x9: { [n: number]: Base; } = [d1, d2]; >x9 : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -108,9 +108,9 @@ var x10: {n: Base[]; } = { n: [d1, d2] }; >x10 : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -127,11 +127,11 @@ var x12: Genric = { func: n => { return [d1, d2]; } }; >x12 : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -139,8 +139,8 @@ class x13 { member: () => Base[] = () => [d1, d2] } >x13 : x13 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -148,8 +148,8 @@ class x14 { member: () => Base[] = function() { return [d1, d2] } } >x14 : x14 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -157,9 +157,9 @@ class x15 { member: () => Base[] = function named() { return [d1, d2] } } >x15 : x15 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -167,8 +167,8 @@ class x16 { member: { (): Base[]; } = () => [d1, d2] } >x16 : x16 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -176,8 +176,8 @@ class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } >x17 : x17 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -185,9 +185,9 @@ class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } >x18 : x18 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -195,7 +195,7 @@ class x19 { member: Base[] = [d1, d2] } >x19 : x19 >member : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -204,7 +204,7 @@ class x20 { member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -213,7 +213,7 @@ class x21 { member: { [n: number]: Base; } = [d1, d2] } >member : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -222,9 +222,9 @@ class x22 { member: {n: Base[]; } = { n: [d1, d2] } } >member : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -243,11 +243,11 @@ class x24 { member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -255,8 +255,8 @@ class x25 { private member: () => Base[] = () => [d1, d2] } >x25 : x25 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -264,8 +264,8 @@ class x26 { private member: () => Base[] = function() { return [d1, d2] } } >x26 : x26 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -273,9 +273,9 @@ class x27 { private member: () => Base[] = function named() { return [d1, d2] } >x27 : x27 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -283,8 +283,8 @@ class x28 { private member: { (): Base[]; } = () => [d1, d2] } >x28 : x28 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -292,8 +292,8 @@ class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } >x29 : x29 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -301,9 +301,9 @@ class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] >x30 : x30 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -311,7 +311,7 @@ class x31 { private member: Base[] = [d1, d2] } >x31 : x31 >member : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -320,7 +320,7 @@ class x32 { private member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -329,7 +329,7 @@ class x33 { private member: { [n: number]: Base; } = [d1, d2] } >member : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -338,9 +338,9 @@ class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } >member : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -359,11 +359,11 @@ class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -371,8 +371,8 @@ class x37 { public member: () => Base[] = () => [d1, d2] } >x37 : x37 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -380,8 +380,8 @@ class x38 { public member: () => Base[] = function() { return [d1, d2] } } >x38 : x38 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -389,9 +389,9 @@ class x39 { public member: () => Base[] = function named() { return [d1, d2] } } >x39 : x39 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -399,8 +399,8 @@ class x40 { public member: { (): Base[]; } = () => [d1, d2] } >x40 : x40 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -408,8 +408,8 @@ class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } >x41 : x41 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -417,9 +417,9 @@ class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] >x42 : x42 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -427,7 +427,7 @@ class x43 { public member: Base[] = [d1, d2] } >x43 : x43 >member : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -436,7 +436,7 @@ class x44 { public member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -445,7 +445,7 @@ class x45 { public member: { [n: number]: Base; } = [d1, d2] } >member : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -454,9 +454,9 @@ class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } >member : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -475,11 +475,11 @@ class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -487,8 +487,8 @@ class x49 { static member: () => Base[] = () => [d1, d2] } >x49 : x49 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -496,8 +496,8 @@ class x50 { static member: () => Base[] = function() { return [d1, d2] } } >x50 : x50 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -505,9 +505,9 @@ class x51 { static member: () => Base[] = function named() { return [d1, d2] } } >x51 : x51 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -515,8 +515,8 @@ class x52 { static member: { (): Base[]; } = () => [d1, d2] } >x52 : x52 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -524,8 +524,8 @@ class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } >x53 : x53 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -533,9 +533,9 @@ class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] >x54 : x54 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -543,7 +543,7 @@ class x55 { static member: Base[] = [d1, d2] } >x55 : x55 >member : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -552,7 +552,7 @@ class x56 { static member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -561,7 +561,7 @@ class x57 { static member: { [n: number]: Base; } = [d1, d2] } >member : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -570,9 +570,9 @@ class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } >member : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -591,11 +591,11 @@ class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -603,8 +603,8 @@ class x61 { private static member: () => Base[] = () => [d1, d2] } >x61 : x61 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -612,8 +612,8 @@ class x62 { private static member: () => Base[] = function() { return [d1, d2] } >x62 : x62 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -621,9 +621,9 @@ class x63 { private static member: () => Base[] = function named() { return [d1, >x63 : x63 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -631,8 +631,8 @@ class x64 { private static member: { (): Base[]; } = () => [d1, d2] } >x64 : x64 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -640,8 +640,8 @@ class x65 { private static member: { (): Base[]; } = function() { return [d1, d2 >x65 : x65 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -649,9 +649,9 @@ class x66 { private static member: { (): Base[]; } = function named() { return [ >x66 : x66 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -659,7 +659,7 @@ class x67 { private static member: Base[] = [d1, d2] } >x67 : x67 >member : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -668,7 +668,7 @@ class x68 { private static member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -677,7 +677,7 @@ class x69 { private static member: { [n: number]: Base; } = [d1, d2] } >member : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -686,9 +686,9 @@ class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } >member : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -707,11 +707,11 @@ class x72 { private static member: Genric = { func: n => { return [d1, d2] >member : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -719,8 +719,8 @@ class x73 { public static member: () => Base[] = () => [d1, d2] } >x73 : x73 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -728,8 +728,8 @@ class x74 { public static member: () => Base[] = function() { return [d1, d2] } >x74 : x74 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -737,9 +737,9 @@ class x75 { public static member: () => Base[] = function named() { return [d1, >x75 : x75 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -747,8 +747,8 @@ class x76 { public static member: { (): Base[]; } = () => [d1, d2] } >x76 : x76 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -756,8 +756,8 @@ class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] >x77 : x77 >member : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -765,9 +765,9 @@ class x78 { public static member: { (): Base[]; } = function named() { return [d >x78 : x78 >member : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -775,7 +775,7 @@ class x79 { public static member: Base[] = [d1, d2] } >x79 : x79 >member : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -784,7 +784,7 @@ class x80 { public static member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -793,7 +793,7 @@ class x81 { public static member: { [n: number]: Base; } = [d1, d2] } >member : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -802,9 +802,9 @@ class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } >member : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -823,11 +823,11 @@ class x84 { public static member: Genric = { func: n => { return [d1, d2]; >member : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -835,8 +835,8 @@ class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } >x85 : x85 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -844,8 +844,8 @@ class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } >x86 : x86 >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -853,9 +853,9 @@ class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] >x87 : x87 >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -863,8 +863,8 @@ class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } >x88 : x88 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -872,8 +872,8 @@ class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) >x89 : x89 >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -881,9 +881,9 @@ class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d >x90 : x90 >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -891,7 +891,7 @@ class x91 { constructor(parm: Base[] = [d1, d2]) { } } >x91 : x91 >parm : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -900,7 +900,7 @@ class x92 { constructor(parm: Array = [d1, d2]) { } } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -909,7 +909,7 @@ class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } >parm : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -918,9 +918,9 @@ class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } >parm : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -939,11 +939,11 @@ class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } } >parm : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -951,8 +951,8 @@ class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } >x97 : x97 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -960,8 +960,8 @@ class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] >x98 : x98 >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -969,9 +969,9 @@ class x99 { constructor(public parm: () => Base[] = function named() { return [d >x99 : x99 >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -979,8 +979,8 @@ class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } >x100 : x100 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -988,8 +988,8 @@ class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, >x101 : x101 >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -997,9 +997,9 @@ class x102 { constructor(public parm: { (): Base[]; } = function named() { retur >x102 : x102 >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1007,7 +1007,7 @@ class x103 { constructor(public parm: Base[] = [d1, d2]) { } } >x103 : x103 >parm : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1016,7 +1016,7 @@ class x104 { constructor(public parm: Array = [d1, d2]) { } } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1025,7 +1025,7 @@ class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } >parm : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1034,9 +1034,9 @@ class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } >parm : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1055,11 +1055,11 @@ class x108 { constructor(public parm: Genric = { func: n => { return [d1, >parm : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1067,8 +1067,8 @@ class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } >x109 : x109 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1076,8 +1076,8 @@ class x110 { constructor(private parm: () => Base[] = function() { return [d1, d >x110 : x110 >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1085,9 +1085,9 @@ class x111 { constructor(private parm: () => Base[] = function named() { return >x111 : x111 >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1095,8 +1095,8 @@ class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } >x112 : x112 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1104,8 +1104,8 @@ class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1 >x113 : x113 >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1113,9 +1113,9 @@ class x114 { constructor(private parm: { (): Base[]; } = function named() { retu >x114 : x114 >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1123,7 +1123,7 @@ class x115 { constructor(private parm: Base[] = [d1, d2]) { } } >x115 : x115 >parm : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1132,7 +1132,7 @@ class x116 { constructor(private parm: Array = [d1, d2]) { } } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1141,7 +1141,7 @@ class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } >parm : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1150,9 +1150,9 @@ class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } >parm : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1171,11 +1171,11 @@ class x120 { constructor(private parm: Genric = { func: n => { return [d1, >parm : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1183,8 +1183,8 @@ function x121(parm: () => Base[] = () => [d1, d2]) { } >x121 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1192,8 +1192,8 @@ function x122(parm: () => Base[] = function() { return [d1, d2] }) { } >x122 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1201,9 +1201,9 @@ function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } >x123 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1211,8 +1211,8 @@ function x124(parm: { (): Base[]; } = () => [d1, d2]) { } >x124 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1220,8 +1220,8 @@ function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } >x125 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1229,9 +1229,9 @@ function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } >x126 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1239,7 +1239,7 @@ function x127(parm: Base[] = [d1, d2]) { } >x127 : (parm?: Base[]) => void >parm : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1248,7 +1248,7 @@ function x128(parm: Array = [d1, d2]) { } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1257,7 +1257,7 @@ function x129(parm: { [n: number]: Base; } = [d1, d2]) { } >parm : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1266,9 +1266,9 @@ function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } >parm : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1287,68 +1287,68 @@ function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } >parm : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x133(): () => Base[] { return () => [d1, d2]; } >x133 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x134(): () => Base[] { return function() { return [d1, d2] }; } >x134 : () => () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x135(): () => Base[] { return function named() { return [d1, d2] }; } >x135 : () => () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x136(): { (): Base[]; } { return () => [d1, d2]; } >x136 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } >x137 : () => () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } >x138 : () => () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x139(): Base[] { return [d1, d2]; } >x139 : () => Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1356,7 +1356,7 @@ function x140(): Array { return [d1, d2]; } >x140 : () => Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1364,7 +1364,7 @@ function x141(): { [n: number]: Base; } { return [d1, d2]; } >x141 : () => { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1372,9 +1372,9 @@ function x142(): {n: Base[]; } { return { n: [d1, d2] }; } >x142 : () => { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1391,97 +1391,97 @@ function x144(): Genric { return { func: n => { return [d1, d2]; } }; } >x144 : () => Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } >x145 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } >x146 : () => () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } >x147 : () => () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } >x148 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } >x149 : () => () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } >x150 : () => () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 function x151(): Base[] { return [d1, d2]; return [d1, d2]; } >x151 : () => Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1489,10 +1489,10 @@ function x152(): Array { return [d1, d2]; return [d1, d2]; } >x152 : () => Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1500,10 +1500,10 @@ function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } >x153 : () => { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1511,14 +1511,14 @@ function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] } >x154 : () => { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1539,82 +1539,82 @@ function x156(): Genric { return { func: n => { return [d1, d2]; } }; retu >x156 : () => Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x157: () => () => Base[] = () => { return () => [d1, d2]; }; >x157 : () => () => Base[] >Base : Base ->() => { return () => [d1, d2]; } : () => () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; >x158 : () => () => Base[] >Base : Base ->() => { return function() { return [d1, d2] }; } : () => () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>() => { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; >x159 : () => () => Base[] >Base : Base ->() => { return function named() { return [d1, d2] }; } : () => () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>() => { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; >x160 : () => () => Base[] >Base : Base ->() => { return () => [d1, d2]; } : () => () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; >x161 : () => () => Base[] >Base : Base ->() => { return function() { return [d1, d2] }; } : () => () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>() => { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; >x162 : () => () => Base[] >Base : Base ->() => { return function named() { return [d1, d2] }; } : () => () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>() => { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x163: () => Base[] = () => { return [d1, d2]; }; >x163 : () => Base[] >Base : Base ->() => { return [d1, d2]; } : () => Array ->[d1, d2] : Array +>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1622,8 +1622,8 @@ var x164: () => Array = () => { return [d1, d2]; }; >x164 : () => Base[] >Array : T[] >Base : Base ->() => { return [d1, d2]; } : () => Array ->[d1, d2] : Array +>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1631,8 +1631,8 @@ var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; >x165 : () => { [x: number]: Base; } >n : number >Base : Base ->() => { return [d1, d2]; } : () => Array ->[d1, d2] : Array +>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1640,10 +1640,10 @@ var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; >x166 : () => { n: Base[]; } >n : Base[] >Base : Base ->() => { return { n: [d1, d2] }; } : () => { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>() => { return { n: [d1, d2] }; } : () => { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1661,76 +1661,76 @@ var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } >x168 : () => Genric >Genric : Genric >Base : Base ->() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => Array; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x169: () => () => Base[] = function() { return () => [d1, d2]; }; >x169 : () => () => Base[] >Base : Base ->function() { return () => [d1, d2]; } : () => () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>function() { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; >x170 : () => () => Base[] >Base : Base ->function() { return function() { return [d1, d2] }; } : () => () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; >x171 : () => () => Base[] >Base : Base ->function() { return function named() { return [d1, d2] }; } : () => () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function() { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; >x172 : () => () => Base[] >Base : Base ->function() { return () => [d1, d2]; } : () => () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>function() { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; >x173 : () => () => Base[] >Base : Base ->function() { return function() { return [d1, d2] }; } : () => () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; >x174 : () => () => Base[] >Base : Base ->function() { return function named() { return [d1, d2] }; } : () => () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function() { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x175: () => Base[] = function() { return [d1, d2]; }; >x175 : () => Base[] >Base : Base ->function() { return [d1, d2]; } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1738,8 +1738,8 @@ var x176: () => Array = function() { return [d1, d2]; }; >x176 : () => Base[] >Array : T[] >Base : Base ->function() { return [d1, d2]; } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1747,8 +1747,8 @@ var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; >x177 : () => { [x: number]: Base; } >n : number >Base : Base ->function() { return [d1, d2]; } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1756,10 +1756,10 @@ var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; >x178 : () => { n: Base[]; } >n : Base[] >Base : Base ->function() { return { n: [d1, d2] }; } : () => { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>function() { return { n: [d1, d2] }; } : () => { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1777,12 +1777,12 @@ var x180: () => Genric = function() { return { func: n => { return [d1, d2 >x180 : () => Genric >Genric : Genric >Base : Base ->function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => Array; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1790,8 +1790,8 @@ module x181 { var t: () => Base[] = () => [d1, d2]; } >x181 : typeof x181 >t : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1799,8 +1799,8 @@ module x182 { var t: () => Base[] = function() { return [d1, d2] }; } >x182 : typeof x182 >t : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1808,9 +1808,9 @@ module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } >x183 : typeof x183 >t : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1818,8 +1818,8 @@ module x184 { var t: { (): Base[]; } = () => [d1, d2]; } >x184 : typeof x184 >t : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1827,8 +1827,8 @@ module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } >x185 : typeof x185 >t : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1836,9 +1836,9 @@ module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } >x186 : typeof x186 >t : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1846,7 +1846,7 @@ module x187 { var t: Base[] = [d1, d2]; } >x187 : typeof x187 >t : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1855,7 +1855,7 @@ module x188 { var t: Array = [d1, d2]; } >t : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1864,7 +1864,7 @@ module x189 { var t: { [n: number]: Base; } = [d1, d2]; } >t : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1873,9 +1873,9 @@ module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } >t : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1894,11 +1894,11 @@ module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } >t : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1906,8 +1906,8 @@ module x193 { export var t: () => Base[] = () => [d1, d2]; } >x193 : typeof x193 >t : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1915,8 +1915,8 @@ module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } >x194 : typeof x194 >t : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1924,9 +1924,9 @@ module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; >x195 : typeof x195 >t : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1934,8 +1934,8 @@ module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } >x196 : typeof x196 >t : () => Base[] >Base : Base ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1943,8 +1943,8 @@ module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } >x197 : typeof x197 >t : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1952,9 +1952,9 @@ module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] >x198 : typeof x198 >t : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1962,7 +1962,7 @@ module x199 { export var t: Base[] = [d1, d2]; } >x199 : typeof x199 >t : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1971,7 +1971,7 @@ module x200 { export var t: Array = [d1, d2]; } >t : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1980,7 +1980,7 @@ module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } >t : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -1989,9 +1989,9 @@ module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } >t : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2010,11 +2010,11 @@ module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; >t : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2022,8 +2022,8 @@ var x206 = <() => Base[]>function() { return [d1, d2] }; >x206 : () => Base[] ><() => Base[]>function() { return [d1, d2] } : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2031,9 +2031,9 @@ var x207 = <() => Base[]>function named() { return [d1, d2] }; >x207 : () => Base[] ><() => Base[]>function named() { return [d1, d2] } : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2041,8 +2041,8 @@ var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; >x209 : () => Base[] ><{ (): Base[]; }>function() { return [d1, d2] } : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2050,9 +2050,9 @@ var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; >x210 : () => Base[] ><{ (): Base[]; }>function named() { return [d1, d2] } : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2060,7 +2060,7 @@ var x211 = [d1, d2]; >x211 : Base[] >[d1, d2] : Base[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2069,7 +2069,7 @@ var x212 = >[d1, d2]; >>[d1, d2] : Base[] >Array : T[] >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2078,7 +2078,7 @@ var x213 = <{ [n: number]: Base; }>[d1, d2]; ><{ [n: number]: Base; }>[d1, d2] : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2087,9 +2087,9 @@ var x214 = <{n: Base[]; } >{ n: [d1, d2] }; ><{n: Base[]; } >{ n: [d1, d2] } : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2098,11 +2098,11 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >>{ func: n => { return [d1, d2]; } } : Genric >Genric : Genric >Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2113,8 +2113,8 @@ var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ><() => Base[]>undefined : () => Base[] >Base : Base >undefined : undefined ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2125,9 +2125,9 @@ var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ><() => Base[]>undefined : () => Base[] >Base : Base >undefined : undefined ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2138,8 +2138,8 @@ var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ><{ (): Base[]; }>undefined : () => Base[] >Base : Base >undefined : undefined ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2150,9 +2150,9 @@ var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ><{ (): Base[]; }>undefined : () => Base[] >Base : Base >undefined : undefined ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2163,7 +2163,7 @@ var x221 = (undefined) || [d1, d2]; >undefined : Base[] >Base : Base >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2175,7 +2175,7 @@ var x222 = (>undefined) || [d1, d2]; >Array : T[] >Base : Base >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2187,7 +2187,7 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >n : number >Base : Base >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2199,80 +2199,80 @@ var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; >n : Base[] >Base : Base >undefined : undefined ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x225: () => Base[]; x225 = () => [d1, d2]; >x225 : () => Base[] >Base : Base ->x225 = () => [d1, d2] : () => Array +>x225 = () => [d1, d2] : () => (Derived1 | Derived2)[] >x225 : () => Base[] ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x226: () => Base[]; x226 = function() { return [d1, d2] }; >x226 : () => Base[] >Base : Base ->x226 = function() { return [d1, d2] } : () => Array +>x226 = function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >x226 : () => Base[] ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x227: () => Base[]; x227 = function named() { return [d1, d2] }; >x227 : () => Base[] >Base : Base ->x227 = function named() { return [d1, d2] } : () => Array +>x227 = function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >x227 : () => Base[] ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x228: { (): Base[]; }; x228 = () => [d1, d2]; >x228 : () => Base[] >Base : Base ->x228 = () => [d1, d2] : () => Array +>x228 = () => [d1, d2] : () => (Derived1 | Derived2)[] >x228 : () => Base[] ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; >x229 : () => Base[] >Base : Base ->x229 = function() { return [d1, d2] } : () => Array +>x229 = function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >x229 : () => Base[] ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; >x230 : () => Base[] >Base : Base ->x230 = function named() { return [d1, d2] } : () => Array +>x230 = function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >x230 : () => Base[] ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x231: Base[]; x231 = [d1, d2]; >x231 : Base[] >Base : Base ->x231 = [d1, d2] : Array +>x231 = [d1, d2] : (Derived1 | Derived2)[] >x231 : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2280,9 +2280,9 @@ var x232: Array; x232 = [d1, d2]; >x232 : Base[] >Array : T[] >Base : Base ->x232 = [d1, d2] : Array +>x232 = [d1, d2] : (Derived1 | Derived2)[] >x232 : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2290,9 +2290,9 @@ var x233: { [n: number]: Base; }; x233 = [d1, d2]; >x233 : { [x: number]: Base; } >n : number >Base : Base ->x233 = [d1, d2] : Array +>x233 = [d1, d2] : (Derived1 | Derived2)[] >x233 : { [x: number]: Base; } ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2300,11 +2300,11 @@ var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; >x234 : { n: Base[]; } >n : Base[] >Base : Base ->x234 = { n: [d1, d2] } : { n: Array; } +>x234 = { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } >x234 : { n: Base[]; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2323,13 +2323,13 @@ var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; >x236 : Genric >Genric : Genric >Base : Base ->x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } >x236 : Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2337,10 +2337,10 @@ var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; >x237 : { n: () => Base[]; } >n : () => Base[] >Base : Base ->{ n: () => [d1, d2] } : { n: () => Array; } ->n : () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>{ n: () => [d1, d2] } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2348,10 +2348,10 @@ var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; >x238 : { n: () => Base[]; } >n : () => Base[] >Base : Base ->{ n: function() { return [d1, d2] } } : { n: () => Array; } ->n : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>{ n: function() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2359,11 +2359,11 @@ var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; >x239 : { n: () => Base[]; } >n : () => Base[] >Base : Base ->{ n: function named() { return [d1, d2] } } : { n: () => Array; } ->n : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>{ n: function named() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2371,10 +2371,10 @@ var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; >x240 : { n: () => Base[]; } >n : () => Base[] >Base : Base ->{ n: () => [d1, d2] } : { n: () => Array; } ->n : () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>{ n: () => [d1, d2] } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2382,10 +2382,10 @@ var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; >x241 : { n: () => Base[]; } >n : () => Base[] >Base : Base ->{ n: function() { return [d1, d2] } } : { n: () => Array; } ->n : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>{ n: function() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2393,11 +2393,11 @@ var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; >x242 : { n: () => Base[]; } >n : () => Base[] >Base : Base ->{ n: function named() { return [d1, d2] } } : { n: () => Array; } ->n : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>{ n: function named() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2405,9 +2405,9 @@ var x243: { n: Base[]; } = { n: [d1, d2] }; >x243 : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2416,9 +2416,9 @@ var x244: { n: Array; } = { n: [d1, d2] }; >n : Base[] >Array : T[] >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2427,9 +2427,9 @@ var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; >n : { [x: number]: Base; } >n : number >Base : Base ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2438,11 +2438,11 @@ var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; >n : { n: Base[]; } >n : Base[] >Base : Base ->{ n: { n: [d1, d2] } } : { n: { n: Array; }; } ->n : { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: { n: [d1, d2] } } : { n: { n: (Derived1 | Derived2)[]; }; } +>n : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2463,49 +2463,49 @@ var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; >n : Genric >Genric : Genric >Base : Base ->{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => Array; }; } ->n : { func: (n: Base[]) => Array; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => (Derived1 | Derived2)[]; }; } +>n : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x252: { (): Base[]; }[] = [() => [d1, d2]]; ->x252 : { (): Base[]; }[] +>x252 : (() => Base[])[] >Base : Base ->[() => [d1, d2]] : { (): Array; }[] ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>[() => [d1, d2]] : (() => (Derived1 | Derived2)[])[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; ->x253 : { (): Base[]; }[] +>x253 : (() => Base[])[] >Base : Base ->[function() { return [d1, d2] }] : { (): Array; }[] ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>[function() { return [d1, d2] }] : (() => (Derived1 | Derived2)[])[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; ->x254 : { (): Base[]; }[] +>x254 : (() => Base[])[] >Base : Base ->[function named() { return [d1, d2] }] : { (): Array; }[] ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>[function named() { return [d1, d2] }] : (() => (Derived1 | Derived2)[])[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x255: Base[][] = [[d1, d2]]; >x255 : Base[][] >Base : Base ->[[d1, d2]] : Array[] ->[d1, d2] : Array +>[[d1, d2]] : (Derived1 | Derived2)[][] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2513,8 +2513,8 @@ var x256: Array[] = [[d1, d2]]; >x256 : Base[][] >Array : T[] >Base : Base ->[[d1, d2]] : Array[] ->[d1, d2] : Array +>[[d1, d2]] : (Derived1 | Derived2)[][] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2522,8 +2522,8 @@ var x257: { [n: number]: Base; }[] = [[d1, d2]]; >x257 : { [x: number]: Base; }[] >n : number >Base : Base ->[[d1, d2]] : Array[] ->[d1, d2] : Array +>[[d1, d2]] : (Derived1 | Derived2)[][] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2531,10 +2531,10 @@ var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; >x258 : { n: Base[]; }[] >n : Base[] >Base : Base ->[{ n: [d1, d2] }] : { n: Array; }[] ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>[{ n: [d1, d2] }] : { n: (Derived1 | Derived2)[]; }[] +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2542,21 +2542,21 @@ var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; >x260 : Genric[] >Genric : Genric >Base : Base ->[{ func: n => { return [d1, d2]; } }] : { func: (n: Base[]) => Array; }[] ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>[{ func: n => { return [d1, d2]; } }] : { func: (n: Base[]) => (Derived1 | Derived2)[]; }[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x261: () => Base[] = function() { return [d1, d2] } || undefined; >x261 : () => Base[] >Base : Base ->function() { return [d1, d2] } || undefined : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2564,10 +2564,10 @@ var x261: () => Base[] = function() { return [d1, d2] } || undefined; var x262: () => Base[] = function named() { return [d1, d2] } || undefined; >x262 : () => Base[] >Base : Base ->function named() { return [d1, d2] } || undefined : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2575,9 +2575,9 @@ var x262: () => Base[] = function named() { return [d1, d2] } || undefined; var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; >x263 : () => Base[] >Base : Base ->function() { return [d1, d2] } || undefined : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2585,10 +2585,10 @@ var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; >x264 : () => Base[] >Base : Base ->function named() { return [d1, d2] } || undefined : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2596,8 +2596,8 @@ var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; var x265: Base[] = [d1, d2] || undefined; >x265 : Base[] >Base : Base ->[d1, d2] || undefined : Array ->[d1, d2] : Array +>[d1, d2] || undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2606,8 +2606,8 @@ var x266: Array = [d1, d2] || undefined; >x266 : Base[] >Array : T[] >Base : Base ->[d1, d2] || undefined : Array ->[d1, d2] : Array +>[d1, d2] || undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2616,8 +2616,8 @@ var x267: { [n: number]: Base; } = [d1, d2] || undefined; >x267 : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] || undefined : Array ->[d1, d2] : Array +>[d1, d2] || undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2626,10 +2626,10 @@ var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; >x268 : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } || undefined : { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } || undefined : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -2637,51 +2637,51 @@ var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; var x269: () => Base[] = undefined || function() { return [d1, d2] }; >x269 : () => Base[] >Base : Base ->undefined || function() { return [d1, d2] } : () => Array +>undefined || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x270: () => Base[] = undefined || function named() { return [d1, d2] }; >x270 : () => Base[] >Base : Base ->undefined || function named() { return [d1, d2] } : () => Array +>undefined || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; >x271 : () => Base[] >Base : Base ->undefined || function() { return [d1, d2] } : () => Array +>undefined || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; >x272 : () => Base[] >Base : Base ->undefined || function named() { return [d1, d2] } : () => Array +>undefined || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x273: Base[] = undefined || [d1, d2]; >x273 : Base[] >Base : Base ->undefined || [d1, d2] : Array +>undefined || [d1, d2] : (Derived1 | Derived2)[] >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2689,9 +2689,9 @@ var x274: Array = undefined || [d1, d2]; >x274 : Base[] >Array : T[] >Base : Base ->undefined || [d1, d2] : Array +>undefined || [d1, d2] : (Derived1 | Derived2)[] >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2699,9 +2699,9 @@ var x275: { [n: number]: Base; } = undefined || [d1, d2]; >x275 : { [x: number]: Base; } >n : number >Base : Base ->undefined || [d1, d2] : Array +>undefined || [d1, d2] : (Derived1 | Derived2)[] >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2709,78 +2709,78 @@ var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; >x276 : { n: Base[]; } >n : Base[] >Base : Base ->undefined || { n: [d1, d2] } : { n: Array; } +>undefined || { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } >undefined : undefined ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; >x277 : () => Base[] >Base : Base ->function() { return [d1, d2] } || function() { return [d1, d2] } : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; >x278 : () => Base[] >Base : Base ->function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; >x279 : () => Base[] >Base : Base ->function() { return [d1, d2] } || function() { return [d1, d2] } : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; >x280 : () => Base[] >Base : Base ->function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x281: Base[] = [d1, d2] || [d1, d2]; >x281 : Base[] >Base : Base ->[d1, d2] || [d1, d2] : Array ->[d1, d2] : Array +>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2788,11 +2788,11 @@ var x282: Array = [d1, d2] || [d1, d2]; >x282 : Base[] >Array : T[] >Base : Base ->[d1, d2] || [d1, d2] : Array ->[d1, d2] : Array +>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2800,11 +2800,11 @@ var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; >x283 : { [x: number]: Base; } >n : number >Base : Base ->[d1, d2] || [d1, d2] : Array ->[d1, d2] : Array +>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2812,108 +2812,108 @@ var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; >x284 : { n: Base[]; } >n : Base[] >Base : Base ->{ n: [d1, d2] } || { n: [d1, d2] } : { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } || { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; >x285 : () => Base[] >Base : Base ->true ? () => [d1, d2] : () => [d1, d2] : () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; >x286 : () => Base[] >Base : Base ->true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; >x287 : () => Base[] >Base : Base ->true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; >x288 : () => Base[] >Base : Base ->true ? () => [d1, d2] : () => [d1, d2] : () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; >x289 : () => Base[] >Base : Base ->true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; >x290 : () => Base[] >Base : Base ->true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x291: Base[] = true ? [d1, d2] : [d1, d2]; >x291 : Base[] >Base : Base ->true ? [d1, d2] : [d1, d2] : Array ->[d1, d2] : Array +>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2921,11 +2921,11 @@ var x292: Array = true ? [d1, d2] : [d1, d2]; >x292 : Base[] >Array : T[] >Base : Base ->true ? [d1, d2] : [d1, d2] : Array ->[d1, d2] : Array +>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2933,11 +2933,11 @@ var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; >x293 : { [x: number]: Base; } >n : number >Base : Base ->true ? [d1, d2] : [d1, d2] : Array ->[d1, d2] : Array +>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2945,15 +2945,15 @@ var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; >x294 : { n: Base[]; } >n : Base[] >Base : Base ->true ? { n: [d1, d2] } : { n: [d1, d2] } : { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>true ? { n: [d1, d2] } : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2975,90 +2975,90 @@ var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n >x296 : Genric >Genric : Genric >Base : Base ->true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x297: () => Base[] = true ? undefined : () => [d1, d2]; >x297 : () => Base[] >Base : Base ->true ? undefined : () => [d1, d2] : () => Array +>true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] >undefined : undefined ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; >x298 : () => Base[] >Base : Base ->true ? undefined : function() { return [d1, d2] } : () => Array +>true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; >x299 : () => Base[] >Base : Base ->true ? undefined : function named() { return [d1, d2] } : () => Array +>true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; >x300 : () => Base[] >Base : Base ->true ? undefined : () => [d1, d2] : () => Array +>true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] >undefined : undefined ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; >x301 : () => Base[] >Base : Base ->true ? undefined : function() { return [d1, d2] } : () => Array +>true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; >x302 : () => Base[] >Base : Base ->true ? undefined : function named() { return [d1, d2] } : () => Array +>true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >undefined : undefined ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x303: Base[] = true ? undefined : [d1, d2]; >x303 : Base[] >Base : Base ->true ? undefined : [d1, d2] : Array +>true ? undefined : [d1, d2] : (Derived1 | Derived2)[] >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3066,9 +3066,9 @@ var x304: Array = true ? undefined : [d1, d2]; >x304 : Base[] >Array : T[] >Base : Base ->true ? undefined : [d1, d2] : Array +>true ? undefined : [d1, d2] : (Derived1 | Derived2)[] >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3076,9 +3076,9 @@ var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; >x305 : { [x: number]: Base; } >n : number >Base : Base ->true ? undefined : [d1, d2] : Array +>true ? undefined : [d1, d2] : (Derived1 | Derived2)[] >undefined : undefined ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3086,11 +3086,11 @@ var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; >x306 : { n: Base[]; } >n : Base[] >Base : Base ->true ? undefined : { n: [d1, d2] } : { n: Array; } +>true ? undefined : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } >undefined : undefined ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3109,22 +3109,22 @@ var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; >x308 : Genric >Genric : Genric >Base : Base ->true ? undefined : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>true ? undefined : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } >undefined : undefined ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 var x309: () => Base[] = true ? () => [d1, d2] : undefined; >x309 : () => Base[] >Base : Base ->true ? () => [d1, d2] : undefined : () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3132,9 +3132,9 @@ var x309: () => Base[] = true ? () => [d1, d2] : undefined; var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; >x310 : () => Base[] >Base : Base ->true ? function() { return [d1, d2] } : undefined : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3142,10 +3142,10 @@ var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; >x311 : () => Base[] >Base : Base ->true ? function named() { return [d1, d2] } : undefined : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3153,9 +3153,9 @@ var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; >x312 : () => Base[] >Base : Base ->true ? () => [d1, d2] : undefined : () => Array ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3163,9 +3163,9 @@ var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; >x313 : () => Base[] >Base : Base ->true ? function() { return [d1, d2] } : undefined : () => Array ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3173,10 +3173,10 @@ var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; >x314 : () => Base[] >Base : Base ->true ? function named() { return [d1, d2] } : undefined : () => Array ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3184,8 +3184,8 @@ var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefi var x315: Base[] = true ? [d1, d2] : undefined; >x315 : Base[] >Base : Base ->true ? [d1, d2] : undefined : Array ->[d1, d2] : Array +>true ? [d1, d2] : undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3194,8 +3194,8 @@ var x316: Array = true ? [d1, d2] : undefined; >x316 : Base[] >Array : T[] >Base : Base ->true ? [d1, d2] : undefined : Array ->[d1, d2] : Array +>true ? [d1, d2] : undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3204,8 +3204,8 @@ var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; >x317 : { [x: number]: Base; } >n : number >Base : Base ->true ? [d1, d2] : undefined : Array ->[d1, d2] : Array +>true ? [d1, d2] : undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3214,10 +3214,10 @@ var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; >x318 : { n: Base[]; } >n : Base[] >Base : Base ->true ? { n: [d1, d2] } : undefined : { n: Array; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>true ? { n: [d1, d2] } : undefined : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3237,12 +3237,12 @@ var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; >x320 : Genric >Genric : Genric >Base : Base ->true ? { func: n => { return [d1, d2]; } } : undefined : { func: (n: Base[]) => Array; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>true ? { func: n => { return [d1, d2]; } } : undefined : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3253,8 +3253,8 @@ function x321(n: () => Base[]) { }; x321(() => [d1, d2]); >Base : Base >x321(() => [d1, d2]) : void >x321 : (n: () => Base[]) => void ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3264,8 +3264,8 @@ function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); >Base : Base >x322(function() { return [d1, d2] }) : void >x322 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3275,9 +3275,9 @@ function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); >Base : Base >x323(function named() { return [d1, d2] }) : void >x323 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3287,8 +3287,8 @@ function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); >Base : Base >x324(() => [d1, d2]) : void >x324 : (n: () => Base[]) => void ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3298,8 +3298,8 @@ function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); >Base : Base >x325(function() { return [d1, d2] }) : void >x325 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3309,9 +3309,9 @@ function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] } >Base : Base >x326(function named() { return [d1, d2] }) : void >x326 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3321,7 +3321,7 @@ function x327(n: Base[]) { }; x327([d1, d2]); >Base : Base >x327([d1, d2]) : void >x327 : (n: Base[]) => void ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3332,7 +3332,7 @@ function x328(n: Array) { }; x328([d1, d2]); >Base : Base >x328([d1, d2]) : void >x328 : (n: Base[]) => void ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3343,7 +3343,7 @@ function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); >Base : Base >x329([d1, d2]) : void >x329 : (n: { [x: number]: Base; }) => void ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3354,9 +3354,9 @@ function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); >Base : Base >x330({ n: [d1, d2] }) : void >x330 : (n: { n: Base[]; }) => void ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3379,11 +3379,11 @@ function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); >Base : Base >x332({ func: n => { return [d1, d2]; } }) : void >x332 : (n: Genric) => void ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3395,8 +3395,8 @@ var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); >n : () => Base[] >x333(() => [d1, d2]) : () => Base[] >x333 : (n: () => Base[]) => () => Base[] ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3408,8 +3408,8 @@ var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); >n : () => Base[] >x334(function() { return [d1, d2] }) : () => Base[] >x334 : (n: () => Base[]) => () => Base[] ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3421,9 +3421,9 @@ var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); >n : () => Base[] >x335(function named() { return [d1, d2] }) : () => Base[] >x335 : (n: () => Base[]) => () => Base[] ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3435,8 +3435,8 @@ var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); >n : () => Base[] >x336(() => [d1, d2]) : () => Base[] >x336 : (n: () => Base[]) => () => Base[] ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3448,8 +3448,8 @@ var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); >n : () => Base[] >x337(function() { return [d1, d2] }) : () => Base[] >x337 : (n: () => Base[]) => () => Base[] ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3461,9 +3461,9 @@ var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }) >n : () => Base[] >x338(function named() { return [d1, d2] }) : () => Base[] >x338 : (n: () => Base[]) => () => Base[] ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3475,7 +3475,7 @@ var x339 = (n: Base[]) => n; x339([d1, d2]); >n : Base[] >x339([d1, d2]) : Base[] >x339 : (n: Base[]) => Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3488,7 +3488,7 @@ var x340 = (n: Array) => n; x340([d1, d2]); >n : Base[] >x340([d1, d2]) : Base[] >x340 : (n: Base[]) => Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3501,7 +3501,7 @@ var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); >n : { [x: number]: Base; } >x341([d1, d2]) : { [x: number]: Base; } >x341 : (n: { [x: number]: Base; }) => { [x: number]: Base; } ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3514,9 +3514,9 @@ var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); >n : { n: Base[]; } >x342({ n: [d1, d2] }) : { n: Base[]; } >x342 : (n: { n: Base[]; }) => { n: Base[]; } ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3543,11 +3543,11 @@ var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); >n : Genric >x344({ func: n => { return [d1, d2]; } }) : Genric >x344 : (n: Genric) => Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3558,8 +3558,8 @@ var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); >Base : Base >x345(() => [d1, d2]) : void >x345 : (n: () => Base[]) => void ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3570,8 +3570,8 @@ var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); >Base : Base >x346(function() { return [d1, d2] }) : void >x346 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3582,9 +3582,9 @@ var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2 >Base : Base >x347(function named() { return [d1, d2] }) : void >x347 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3595,8 +3595,8 @@ var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); >Base : Base >x348(() => [d1, d2]) : void >x348 : (n: () => Base[]) => void ->() => [d1, d2] : () => Array ->[d1, d2] : Array +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3607,8 +3607,8 @@ var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] } >Base : Base >x349(function() { return [d1, d2] }) : void >x349 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => Array ->[d1, d2] : Array +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3619,9 +3619,9 @@ var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, >Base : Base >x350(function named() { return [d1, d2] }) : void >x350 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => Array ->named : () => Array ->[d1, d2] : Array +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3632,7 +3632,7 @@ var x351 = function(n: Base[]) { }; x351([d1, d2]); >Base : Base >x351([d1, d2]) : void >x351 : (n: Base[]) => void ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3644,7 +3644,7 @@ var x352 = function(n: Array) { }; x352([d1, d2]); >Base : Base >x352([d1, d2]) : void >x352 : (n: Base[]) => void ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3656,7 +3656,7 @@ var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); >Base : Base >x353([d1, d2]) : void >x353 : (n: { [x: number]: Base; }) => void ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3668,9 +3668,9 @@ var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); >Base : Base >x354({ n: [d1, d2] }) : void >x354 : (n: { n: Base[]; }) => void ->{ n: [d1, d2] } : { n: Array; } ->n : Array ->[d1, d2] : Array +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3695,11 +3695,11 @@ var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } >Base : Base >x356({ func: n => { return [d1, d2]; } }) : void >x356 : (n: Genric) => void ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } ->func : (n: Base[]) => Array ->n => { return [d1, d2]; } : (n: Base[]) => Array +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] >n : Base[] ->[d1, d2] : Array +>[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 diff --git a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types index f16e747d41e..768b8846880 100644 --- a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types +++ b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types @@ -49,7 +49,7 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean ->[true, 1, null, 'yes'] : Array +>[true, 1, null, 'yes'] : (string | number | boolean)[] >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types index 84082a68ebd..f4965940436 100644 --- a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types +++ b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types @@ -40,21 +40,21 @@ var r3 = foo([]); // number[] >[] : undefined[] var r4 = foo([1, '']); // {}[] ->r4 : Array ->foo([1, '']) : Array +>r4 : (string | number)[] +>foo([1, '']) : (string | number)[] >foo : (t: T) => T ->[1, ''] : Array +>[1, ''] : (string | number)[] var r5 = foo([1, '']); // any[] >r5 : any[] >foo([1, '']) : any[] >foo : (t: T) => T ->[1, ''] : Array +>[1, ''] : (string | number)[] var r6 = foo([1, '']); // Object[] >r6 : Object[] >foo([1, '']) : Object[] >foo : (t: T) => T >Object : Object ->[1, ''] : Array +>[1, ''] : (string | number)[] diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments.errors.txt new file mode 100644 index 00000000000..43bad8f6a1d --- /dev/null +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments.errors.txt @@ -0,0 +1,51 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts(18,10): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts(19,10): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts (2 errors) ==== + // When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, + // the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. + + function foo(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + //var r1 = foo((x: number) => 1, (x: string) => ''); // error + var r1b = foo((x) => 1, (x) => ''); // {} => {} + var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object + var r3 = foo((x: number) => 1, (x: Object) => null); // number => number + var r3ii = foo((x: number) => 1, (x: number) => 1); // number => number + + var a: { x: number; y?: number; }; + var b: { x: number; z?: number; }; + + var r4 = foo((x: typeof a) => a, (x: typeof b) => b); // typeof a => typeof a + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r5 = foo((x: typeof b) => b, (x: typeof a) => a); // typeof b => typeof b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + function other(x: T) { + var r6 = foo((a: T) => a, (b: T) => b); // T => T + var r6b = foo((a) => a, (b) => b); // {} => {} + } + + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); // T => T + var r7b = foo((a) => a, (b) => b); // {} => {} + var r8 = r7(null); + // BUG 835518 + //var r9 = r7(new Date()); + } + + + function foo2(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + function other3(x: T) { + var r8 = foo2((a: Date) => a, (b: Date) => b); // Date => Date + } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments.types deleted file mode 100644 index 9f634070b56..00000000000 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments.types +++ /dev/null @@ -1,216 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts === -// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, -// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. - -function foo(a: (x: T) => T, b: (x: T) => T) { ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->T : T ->a : (x: T) => T ->x : T ->T : T ->T : T ->b : (x: T) => T ->x : T ->T : T ->T : T - - var r: (x: T) => T; ->r : (x: T) => T ->x : T ->T : T ->T : T - - return r; ->r : (x: T) => T -} - -//var r1 = foo((x: number) => 1, (x: string) => ''); // error -var r1b = foo((x) => 1, (x) => ''); // {} => {} ->r1b : (x: {}) => {} ->foo((x) => 1, (x) => '') : (x: {}) => {} ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x) => 1 : (x: {}) => number ->x : {} ->(x) => '' : (x: {}) => string ->x : {} - -var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object ->r2 : (x: any) => any ->foo((x: Object) => null, (x: string) => '') : (x: any) => any ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: Object) => null : (x: Object) => any ->x : Object ->Object : Object ->(x: string) => '' : (x: string) => string ->x : string - -var r3 = foo((x: number) => 1, (x: Object) => null); // number => number ->r3 : (x: any) => any ->foo((x: number) => 1, (x: Object) => null) : (x: any) => any ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: number) => 1 : (x: number) => number ->x : number ->(x: Object) => null : (x: Object) => any ->x : Object ->Object : Object - -var r3ii = foo((x: number) => 1, (x: number) => 1); // number => number ->r3ii : (x: number) => number ->foo((x: number) => 1, (x: number) => 1) : (x: number) => number ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: number) => 1 : (x: number) => number ->x : number ->(x: number) => 1 : (x: number) => number ->x : number - -var a: { x: number; y?: number; }; ->a : { x: number; y?: number; } ->x : number ->y : number - -var b: { x: number; z?: number; }; ->b : { x: number; z?: number; } ->x : number ->z : number - -var r4 = foo((x: typeof a) => a, (x: typeof b) => b); // typeof a => typeof a ->r4 : (x: { x: number; y?: number; }) => { x: number; y?: number; } ->foo((x: typeof a) => a, (x: typeof b) => b) : (x: { x: number; y?: number; }) => { x: number; y?: number; } ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: typeof a) => a : (x: { x: number; y?: number; }) => { x: number; y?: number; } ->x : { x: number; y?: number; } ->a : { x: number; y?: number; } ->a : { x: number; y?: number; } ->(x: typeof b) => b : (x: { x: number; z?: number; }) => { x: number; z?: number; } ->x : { x: number; z?: number; } ->b : { x: number; z?: number; } ->b : { x: number; z?: number; } - -var r5 = foo((x: typeof b) => b, (x: typeof a) => a); // typeof b => typeof b ->r5 : (x: { x: number; z?: number; }) => { x: number; z?: number; } ->foo((x: typeof b) => b, (x: typeof a) => a) : (x: { x: number; z?: number; }) => { x: number; z?: number; } ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: typeof b) => b : (x: { x: number; z?: number; }) => { x: number; z?: number; } ->x : { x: number; z?: number; } ->b : { x: number; z?: number; } ->b : { x: number; z?: number; } ->(x: typeof a) => a : (x: { x: number; y?: number; }) => { x: number; y?: number; } ->x : { x: number; y?: number; } ->a : { x: number; y?: number; } ->a : { x: number; y?: number; } - -function other(x: T) { ->other : (x: T) => void ->T : T ->x : T ->T : T - - var r6 = foo((a: T) => a, (b: T) => b); // T => T ->r6 : (x: T) => T ->foo((a: T) => a, (b: T) => b) : (x: T) => T ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(a: T) => a : (a: T) => T ->a : T ->T : T ->a : T ->(b: T) => b : (b: T) => T ->b : T ->T : T ->b : T - - var r6b = foo((a) => a, (b) => b); // {} => {} ->r6b : (x: {}) => {} ->foo((a) => a, (b) => b) : (x: {}) => {} ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(a) => a : (a: {}) => {} ->a : {} ->a : {} ->(b) => b : (b: {}) => {} ->b : {} ->b : {} -} - -function other2(x: T) { ->other2 : (x: T) => void ->T : T ->Date : Date ->x : T ->T : T - - var r7 = foo((a: T) => a, (b: T) => b); // T => T ->r7 : (x: T) => T ->foo((a: T) => a, (b: T) => b) : (x: T) => T ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(a: T) => a : (a: T) => T ->a : T ->T : T ->a : T ->(b: T) => b : (b: T) => T ->b : T ->T : T ->b : T - - var r7b = foo((a) => a, (b) => b); // {} => {} ->r7b : (x: {}) => {} ->foo((a) => a, (b) => b) : (x: {}) => {} ->foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(a) => a : (a: {}) => {} ->a : {} ->a : {} ->(b) => b : (b: {}) => {} ->b : {} ->b : {} - - var r8 = r7(null); ->r8 : T ->r7(null) : T ->r7 : (x: T) => T - - // BUG 835518 - //var r9 = r7(new Date()); -} - - -function foo2(a: (x: T) => T, b: (x: T) => T) { ->foo2 : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->T : T ->Date : Date ->a : (x: T) => T ->x : T ->T : T ->T : T ->b : (x: T) => T ->x : T ->T : T ->T : T - - var r: (x: T) => T; ->r : (x: T) => T ->x : T ->T : T ->T : T - - return r; ->r : (x: T) => T -} - -function other3(x: T) { ->other3 : (x: T) => void ->T : T ->RegExp : RegExp ->x : T ->T : T - - var r8 = foo2((a: Date) => a, (b: Date) => b); // Date => Date ->r8 : (x: Date) => Date ->foo2((a: Date) => a, (b: Date) => b) : (x: Date) => Date ->foo2 : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(a: Date) => a : (a: Date) => Date ->a : Date ->Date : Date ->a : Date ->(b: Date) => b : (b: Date) => Date ->b : Date ->Date : Date ->b : Date -} diff --git a/tests/baselines/reference/genericCallWithNonSymmetricSubtypes.errors.txt b/tests/baselines/reference/genericCallWithNonSymmetricSubtypes.errors.txt new file mode 100644 index 00000000000..c14db877073 --- /dev/null +++ b/tests/baselines/reference/genericCallWithNonSymmetricSubtypes.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts(12,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts(13,10): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts (2 errors) ==== + // generic type argument inference where inference leads to two candidates that are both supertypes of all candidates + // we choose the first candidate so the result is dependent on the order of the arguments provided + + function foo(x: T, y: T) { + var r: T; + return r; + } + + var a: { x: number; y?: number; }; + var b: { x: number; z?: number; }; + + var r = foo(a, b); // { x: number; y?: number; }; + ~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r2 = foo(b, a); // { x: number; z?: number; }; + ~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + var x: { x: number; }; + var y: { x?: number; }; + + var r3 = foo(a, x); // { x: number; y?: number; }; + var r4 = foo(x, a); // { x: number; }; + + var r5 = foo(a, y); // { x?: number; }; + var r5 = foo(y, a); // { x?: number; }; + + var r6 = foo(x, y); // { x?: number; }; + var r6 = foo(y, x); // { x?: number; }; + + var s1: (x: Object) => string; + var s2: (x: string) => string; + + var r7 = foo(s1, s2); // (x: Object) => string; + var r8 = foo(s2, s1); // (x: string) => string; \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithNonSymmetricSubtypes.types b/tests/baselines/reference/genericCallWithNonSymmetricSubtypes.types deleted file mode 100644 index e37a010baed..00000000000 --- a/tests/baselines/reference/genericCallWithNonSymmetricSubtypes.types +++ /dev/null @@ -1,117 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts === -// generic type argument inference where inference leads to two candidates that are both supertypes of all candidates -// we choose the first candidate so the result is dependent on the order of the arguments provided - -function foo(x: T, y: T) { ->foo : (x: T, y: T) => T ->T : T ->x : T ->T : T ->y : T ->T : T - - var r: T; ->r : T ->T : T - - return r; ->r : T -} - -var a: { x: number; y?: number; }; ->a : { x: number; y?: number; } ->x : number ->y : number - -var b: { x: number; z?: number; }; ->b : { x: number; z?: number; } ->x : number ->z : number - -var r = foo(a, b); // { x: number; y?: number; }; ->r : { x: number; y?: number; } ->foo(a, b) : { x: number; y?: number; } ->foo : (x: T, y: T) => T ->a : { x: number; y?: number; } ->b : { x: number; z?: number; } - -var r2 = foo(b, a); // { x: number; z?: number; }; ->r2 : { x: number; z?: number; } ->foo(b, a) : { x: number; z?: number; } ->foo : (x: T, y: T) => T ->b : { x: number; z?: number; } ->a : { x: number; y?: number; } - -var x: { x: number; }; ->x : { x: number; } ->x : number - -var y: { x?: number; }; ->y : { x?: number; } ->x : number - -var r3 = foo(a, x); // { x: number; y?: number; }; ->r3 : { x: number; y?: number; } ->foo(a, x) : { x: number; y?: number; } ->foo : (x: T, y: T) => T ->a : { x: number; y?: number; } ->x : { x: number; } - -var r4 = foo(x, a); // { x: number; }; ->r4 : { x: number; } ->foo(x, a) : { x: number; } ->foo : (x: T, y: T) => T ->x : { x: number; } ->a : { x: number; y?: number; } - -var r5 = foo(a, y); // { x?: number; }; ->r5 : { x?: number; } ->foo(a, y) : { x?: number; } ->foo : (x: T, y: T) => T ->a : { x: number; y?: number; } ->y : { x?: number; } - -var r5 = foo(y, a); // { x?: number; }; ->r5 : { x?: number; } ->foo(y, a) : { x?: number; } ->foo : (x: T, y: T) => T ->y : { x?: number; } ->a : { x: number; y?: number; } - -var r6 = foo(x, y); // { x?: number; }; ->r6 : { x?: number; } ->foo(x, y) : { x?: number; } ->foo : (x: T, y: T) => T ->x : { x: number; } ->y : { x?: number; } - -var r6 = foo(y, x); // { x?: number; }; ->r6 : { x?: number; } ->foo(y, x) : { x?: number; } ->foo : (x: T, y: T) => T ->y : { x?: number; } ->x : { x: number; } - -var s1: (x: Object) => string; ->s1 : (x: Object) => string ->x : Object ->Object : Object - -var s2: (x: string) => string; ->s2 : (x: string) => string ->x : string - -var r7 = foo(s1, s2); // (x: Object) => string; ->r7 : (x: Object) => string ->foo(s1, s2) : (x: Object) => string ->foo : (x: T, y: T) => T ->s1 : (x: Object) => string ->s2 : (x: string) => string - -var r8 = foo(s2, s1); // (x: string) => string; ->r8 : (x: string) => string ->foo(s2, s1) : (x: string) => string ->foo : (x: T, y: T) => T ->s2 : (x: string) => string ->s1 : (x: Object) => string - diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.types b/tests/baselines/reference/genericCallWithObjectTypeArgs2.types index aa1eeaf4670..3e178a7062d 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs2.types +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs2.types @@ -22,7 +22,7 @@ class Derived2 extends Base { // returns {}[] function f(a: { x: T; y: U }) { ->f : (a: { x: T; y: U; }) => Array +>f : (a: { x: T; y: U; }) => (T | U)[] >T : T >Base : Base >U : U @@ -34,7 +34,7 @@ function f(a: { x: T; y: U }) { >U : U return [a.x, a.y]; ->[a.x, a.y] : Array +>[a.x, a.y] : (T | U)[] >a.x : T >a : { x: T; y: U; } >x : T @@ -44,9 +44,9 @@ function f(a: { x: T; y: U }) { } var r = f({ x: new Derived(), y: new Derived2() }); // {}[] ->r : Array ->f({ x: new Derived(), y: new Derived2() }) : Array ->f : (a: { x: T; y: U; }) => Array +>r : (Derived | Derived2)[] +>f({ x: new Derived(), y: new Derived2() }) : (Derived | Derived2)[] +>f : (a: { x: T; y: U; }) => (T | U)[] >{ x: new Derived(), y: new Derived2() } : { x: Derived; y: Derived2; } >x : Derived >new Derived() : Derived @@ -57,8 +57,8 @@ var r = f({ x: new Derived(), y: new Derived2() }); // {}[] var r2 = f({ x: new Base(), y: new Derived2() }); // {}[] >r2 : Base[] ->f({ x: new Base(), y: new Derived2() }) : Array ->f : (a: { x: T; y: U; }) => Array +>f({ x: new Base(), y: new Derived2() }) : (Base | Derived2)[] +>f : (a: { x: T; y: U; }) => (T | U)[] >{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; } >x : Base >new Base() : Base diff --git a/tests/baselines/reference/genericTypeArgumentInference1.types b/tests/baselines/reference/genericTypeArgumentInference1.types index be7a3e9226d..c718ccca620 100644 --- a/tests/baselines/reference/genericTypeArgumentInference1.types +++ b/tests/baselines/reference/genericTypeArgumentInference1.types @@ -47,7 +47,7 @@ var r = _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true, 1, null, 'yes'] : Array +>[true, 1, null, 'yes'] : (string | number | boolean)[] >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericsManyTypeParameters.types b/tests/baselines/reference/genericsManyTypeParameters.types index df2144de866..cb492c30623 100644 --- a/tests/baselines/reference/genericsManyTypeParameters.types +++ b/tests/baselines/reference/genericsManyTypeParameters.types @@ -1,6 +1,6 @@ === tests/cases/compiler/genericsManyTypeParameters.ts === function Foo< ->Foo : (x1: a1, y1: a21, z1: a31, a1: a41, b1: a51, c1: a61, x2: a119, y2: a22, z2: a32, a2: a42, b2: a52, c2: a62, x3: a219, y3: a23, z3: a33, a3: a43, b3: a53, c3: a63, x4: a319, y4: a24, z4: a34, a4: a44, b4: a54, c4: a64, x5: a419, y5: a25, z5: a35, a5: a45, b5: a55, c5: a65, x6: a519, y6: a26, z6: a36, a6: a46, b6: a56, c6: a66, x7: a619, y7: a27, z7: a37, a7: a47, b7: a57, c7: a67, x8: a71, y8: a28, z8: a38, a8: a48, b8: a58, c8: a68, x9: a81, y9: a29, z9: a39, a9: a49, b9: a59, c9: a69, x10: a91, y12: a210, z10: a310, a10: a410, b10: a510, c10: a610, x11: a111, y13: a211, z11: a311, a11: a411, b11: a511, c11: a611, x12: a112, y14: a212, z12: a312, a12: a412, b12: a512, c12: a612, x13: a113, y15: a213, z13: a313, a13: a413, b13: a513, c13: a613, x14: a114, y16: a214, z14: a314, a14: a414, b14: a514, c14: a614, x15: a115, y17: a215, z15: a315, a15: a415, b15: a515, c15: a615, x16: a116, y18: a216, z16: a316, a16: a416, b16: a516, c16: a616, x17: a117, y19: a217, z17: a317, a17: a417, b17: a517, c17: a617, x18: a118, y10: a218, z18: a318, a18: a418, b18: a518, c18: a618) => Array +>Foo : (x1: a1, y1: a21, z1: a31, a1: a41, b1: a51, c1: a61, x2: a119, y2: a22, z2: a32, a2: a42, b2: a52, c2: a62, x3: a219, y3: a23, z3: a33, a3: a43, b3: a53, c3: a63, x4: a319, y4: a24, z4: a34, a4: a44, b4: a54, c4: a64, x5: a419, y5: a25, z5: a35, a5: a45, b5: a55, c5: a65, x6: a519, y6: a26, z6: a36, a6: a46, b6: a56, c6: a66, x7: a619, y7: a27, z7: a37, a7: a47, b7: a57, c7: a67, x8: a71, y8: a28, z8: a38, a8: a48, b8: a58, c8: a68, x9: a81, y9: a29, z9: a39, a9: a49, b9: a59, c9: a69, x10: a91, y12: a210, z10: a310, a10: a410, b10: a510, c10: a610, x11: a111, y13: a211, z11: a311, a11: a411, b11: a511, c11: a611, x12: a112, y14: a212, z12: a312, a12: a412, b12: a512, c12: a612, x13: a113, y15: a213, z13: a313, a13: a413, b13: a513, c13: a613, x14: a114, y16: a214, z14: a314, a14: a414, b14: a514, c14: a614, x15: a115, y17: a215, z15: a315, a15: a415, b15: a515, c15: a615, x16: a116, y18: a216, z16: a316, a16: a416, b16: a516, c16: a616, x17: a117, y19: a217, z17: a317, a17: a417, b17: a517, c17: a617, x18: a118, y10: a218, z18: a318, a18: a418, b18: a518, c18: a618) => (a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618)[] a1, a21, a31, a41, a51, a61, >a1 : a1 @@ -402,7 +402,7 @@ function Foo< ) { return [x1 , y1 , z1 , a1 , b1 , c1, ->[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : Array +>[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : (a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618)[] >x1 : a1 >y1 : a21 >z1 : a31 diff --git a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt index 985aaa7948c..15f8f21b8f3 100644 --- a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt +++ b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type 'Array' is not assignable to parameter of type 'string[]'. +tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'string[]'. Type 'string | number' is not assignable to type 'string': Type 'number' is not assignable to type 'string'. @@ -14,7 +14,7 @@ tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argu this.test([]); this.test([1, 2, "hi", 5]); // Error ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'Array' is not assignable to parameter of type 'string[]'. +!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'string[]'. !!! error TS2345: Type 'string | number' is not assignable to type 'string': !!! error TS2345: Type 'number' is not assignable to type 'string'. } diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index c236fe7ff6d..7ea7d4196a6 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -2,16 +2,16 @@ // type of an array is the best common type of its elements (plus its contextual type if it exists) var a = [1, '']; // {}[] ->a : Array ->[1, ''] : Array +>a : (string | number)[] +>[1, ''] : (string | number)[] var b = [1, null]; // number[] >b : number[] >[1, null] : number[] var c = [1, '', null]; // {}[] ->c : Array ->[1, '', null] : Array +>c : (string | number)[] +>[1, '', null] : (string | number)[] var d = [{}, 1]; // {}[] >d : {}[] @@ -31,8 +31,8 @@ var f = [[], [1]]; // number[][] >[1] : number[] var g = [[1], ['']]; // {}[] ->g : Array ->[[1], ['']] : Array +>g : (string[] | number[])[] +>[[1], ['']] : (string[] | number[])[] >[1] : number[] >[''] : string[] @@ -46,8 +46,8 @@ var h = [{ foo: 1, bar: '' }, { foo: 2 }]; // {foo: number}[] >foo : number var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[] ->i : Array<{ foo: number; bar: string; } | { foo: string; }> ->[{ foo: 1, bar: '' }, { foo: '' }] : Array<{ foo: number; bar: string; } | { foo: string; }> +>i : ({ foo: number; bar: string; } | { foo: string; })[] +>[{ foo: 1, bar: '' }, { foo: '' }] : ({ foo: number; bar: string; } | { foo: string; })[] >{ foo: 1, bar: '' } : { foo: number; bar: string; } >foo : number >bar : string @@ -55,36 +55,36 @@ var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[] >foo : string var j = [() => 1, () => '']; // {}[] ->j : Array<{ (): number; } | { (): string; }> ->[() => 1, () => ''] : Array<{ (): number; } | { (): string; }> +>j : ((() => number) | (() => string))[] +>[() => 1, () => ''] : ((() => number) | (() => string))[] >() => 1 : () => number >() => '' : () => string var k = [() => 1, () => 1]; // { (): number }[] ->k : { (): number; }[] ->[() => 1, () => 1] : { (): number; }[] +>k : (() => number)[] +>[() => 1, () => 1] : (() => number)[] >() => 1 : () => number >() => 1 : () => number var l = [() => 1, () => null]; // { (): any }[] ->l : { (): any; }[] ->[() => 1, () => null] : { (): any; }[] +>l : (() => any)[] +>[() => 1, () => null] : (() => any)[] >() => 1 : () => number >() => null : () => any var m = [() => 1, () => '', () => null]; // { (): any }[] ->m : { (): any; }[] ->[() => 1, () => '', () => null] : { (): any; }[] +>m : (() => any)[] +>[() => 1, () => '', () => null] : (() => any)[] >() => 1 : () => number >() => '' : () => string >() => null : () => any var n = [[() => 1], [() => '']]; // {}[] ->n : Array<{ (): number; }[] | { (): string; }[]> ->[[() => 1], [() => '']] : Array<{ (): number; }[] | { (): string; }[]> ->[() => 1] : { (): number; }[] +>n : ((() => number)[] | (() => string)[])[] +>[[() => 1], [() => '']] : ((() => number)[] | (() => string)[])[] +>[() => 1] : (() => number)[] >() => 1 : () => number ->[() => ''] : { (): string; }[] +>[() => ''] : (() => string)[] >() => '' : () => string class Base { foo: string; } @@ -129,8 +129,8 @@ module Derived { >base : Base var i = [{ foo: base, basear: derived }, { foo: derived }]; // {foo: Derived}[] ->i : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }> ->[{ foo: base, basear: derived }, { foo: derived }] : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }> +>i : ({ foo: Base; basear: Derived; } | { foo: Derived; })[] +>[{ foo: base, basear: derived }, { foo: derived }] : ({ foo: Base; basear: Derived; } | { foo: Derived; })[] >{ foo: base, basear: derived } : { foo: Base; basear: Derived; } >foo : Base >base : Base @@ -141,30 +141,30 @@ module Derived { >derived : Derived var j = [() => base, () => derived]; // { {}: Base } ->j : { (): Base; }[] ->[() => base, () => derived] : { (): Base; }[] +>j : (() => Base)[] +>[() => base, () => derived] : (() => Base)[] >() => base : () => Base >base : Base >() => derived : () => Derived >derived : Derived var k = [() => base, () => 1]; // {}[]~ ->k : Array<{ (): Base; } | { (): number; }> ->[() => base, () => 1] : Array<{ (): Base; } | { (): number; }> +>k : ((() => Base) | (() => number))[] +>[() => base, () => 1] : ((() => Base) | (() => number))[] >() => base : () => Base >base : Base >() => 1 : () => number var l = [() => base, () => null]; // { (): any }[] ->l : { (): any; }[] ->[() => base, () => null] : { (): any; }[] +>l : (() => any)[] +>[() => base, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => null : () => any var m = [() => base, () => derived, () => null]; // { (): any }[] ->m : { (): any; }[] ->[() => base, () => derived, () => null] : { (): any; }[] +>m : (() => any)[] +>[() => base, () => derived, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -172,18 +172,18 @@ module Derived { >() => null : () => any var n = [[() => base], [() => derived]]; // { (): Base }[] ->n : { (): Base; }[][] ->[[() => base], [() => derived]] : { (): Base; }[][] ->[() => base] : { (): Base; }[] +>n : (() => Base)[][] +>[[() => base], [() => derived]] : (() => Base)[][] +>[() => base] : (() => Base)[] >() => base : () => Base >base : Base ->[() => derived] : { (): Derived; }[] +>[() => derived] : (() => Derived)[] >() => derived : () => Derived >derived : Derived var o = [derived, derived2]; // {}[] ->o : Array ->[derived, derived2] : Array +>o : (Derived | Derived2)[] +>[derived, derived2] : (Derived | Derived2)[] >derived : Derived >derived2 : Derived2 @@ -195,12 +195,12 @@ module Derived { >base : Base var q = [[() => derived2], [() => derived]]; // {}[] ->q : Array<{ (): Derived2; }[] | { (): Derived; }[]> ->[[() => derived2], [() => derived]] : Array<{ (): Derived2; }[] | { (): Derived; }[]> ->[() => derived2] : { (): Derived2; }[] +>q : ((() => Derived2)[] | (() => Derived)[])[] +>[[() => derived2], [() => derived]] : ((() => Derived2)[] | (() => Derived)[])[] +>[() => derived2] : (() => Derived2)[] >() => derived2 : () => Derived2 >derived2 : Derived2 ->[() => derived] : { (): Derived; }[] +>[() => derived] : (() => Derived)[] >() => derived : () => Derived >derived : Derived } @@ -212,7 +212,7 @@ module WithContextualType { var a: Base[] = [derived, derived2]; >a : Base[] >Base : Base ->[derived, derived2] : Array +>[derived, derived2] : (Derived | Derived2)[] >derived : Derived >derived2 : Derived2 @@ -227,9 +227,9 @@ module WithContextualType { >[] : undefined[] var d: { (): Base }[] = [() => derived, () => derived2]; ->d : { (): Base; }[] +>d : (() => Base)[] >Base : Base ->[() => derived, () => derived2] : Array<{ (): Derived; } | { (): Derived2; }> +>[() => derived, () => derived2] : ((() => Derived) | (() => Derived2))[] >() => derived : () => Derived >derived : Derived >() => derived2 : () => Derived2 @@ -257,27 +257,27 @@ function foo(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : Array ->[t, u] : Array +>c : (T | U)[] +>[t, u] : (T | U)[] >t : T >u : U var d = [t, 1]; // {}[] ->d : Array ->[t, 1] : Array +>d : (number | T)[] +>[t, 1] : (number | T)[] >t : T var e = [() => t, () => u]; // {}[] ->e : Array<{ (): T; } | { (): U; }> ->[() => t, () => u] : Array<{ (): T; } | { (): U; }> +>e : ((() => T) | (() => U))[] +>[() => t, () => u] : ((() => T) | (() => U))[] >() => t : () => T >t : T >() => u : () => U >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : { (): any; }[] ->[() => t, () => u, () => null] : { (): any; }[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -308,27 +308,27 @@ function foo2(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : Array ->[t, u] : Array +>c : (T | U)[] +>[t, u] : (T | U)[] >t : T >u : U var d = [t, 1]; // {}[] ->d : Array ->[t, 1] : Array +>d : (number | T)[] +>[t, 1] : (number | T)[] >t : T var e = [() => t, () => u]; // {}[] ->e : Array<{ (): T; } | { (): U; }> ->[() => t, () => u] : Array<{ (): T; } | { (): U; }> +>e : ((() => T) | (() => U))[] +>[() => t, () => u] : ((() => T) | (() => U))[] >() => t : () => T >t : T >() => u : () => U >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : { (): any; }[] ->[() => t, () => u, () => null] : { (): any; }[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -342,8 +342,8 @@ function foo2(t: T, u: U) { >base : Base var h = [t, derived]; // Derived[] ->h : Array ->[t, derived] : Array +>h : (Derived | T)[] +>[t, derived] : (Derived | T)[] >t : T >derived : Derived @@ -383,27 +383,27 @@ function foo3(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : Array ->[t, u] : Array +>c : (T | U)[] +>[t, u] : (T | U)[] >t : T >u : U var d = [t, 1]; // {}[] ->d : Array ->[t, 1] : Array +>d : (number | T)[] +>[t, 1] : (number | T)[] >t : T var e = [() => t, () => u]; // {}[] ->e : Array<{ (): T; } | { (): U; }> ->[() => t, () => u] : Array<{ (): T; } | { (): U; }> +>e : ((() => T) | (() => U))[] +>[() => t, () => u] : ((() => T) | (() => U))[] >() => t : () => T >t : T >() => u : () => U >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : { (): any; }[] ->[() => t, () => u, () => null] : { (): any; }[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -458,27 +458,27 @@ function foo4(t: T, u: U) { >t : T var c = [t, u]; // BUG 821629 ->c : Array ->[t, u] : Array +>c : (T | U)[] +>[t, u] : (T | U)[] >t : T >u : U var d = [t, 1]; // {}[] ->d : Array ->[t, 1] : Array +>d : (number | T)[] +>[t, 1] : (number | T)[] >t : T var e = [() => t, () => u]; // {}[] ->e : Array<{ (): T; } | { (): U; }> ->[() => t, () => u] : Array<{ (): T; } | { (): U; }> +>e : ((() => T) | (() => U))[] +>[() => t, () => u] : ((() => T) | (() => U))[] >() => t : () => T >t : T >() => u : () => U >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : { (): any; }[] ->[() => t, () => u, () => null] : { (): any; }[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -492,8 +492,8 @@ function foo4(t: T, u: U) { >base : Base var h = [t, derived]; // Derived[] ->h : Array ->[t, derived] : Array +>h : (Derived | T)[] +>[t, derived] : (Derived | T)[] >t : T >derived : Derived @@ -504,15 +504,15 @@ function foo4(t: T, u: U) { >base : Base var j = [u, derived]; // Derived[] ->j : Array ->[u, derived] : Array +>j : (Derived | U)[] +>[u, derived] : (Derived | U)[] >u : U >derived : Derived var k: Base[] = [t, u]; >k : Base[] >Base : Base ->[t, u] : Array +>[t, u] : (T | U)[] >t : T >u : U } diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index b82c82b9eb5..3ec718f3b25 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array>'. +tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. var arr = [new C(), new C2(), new D()]; ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array>'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt index ed4f45ec1de..cc93b716d2e 100644 --- a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt +++ b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. Type 'string | number' is not assignable to type 'number': Type 'string' is not assignable to type 'number'. tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): error TS2346: Supplied parameters do not match any signature of call target. @@ -16,7 +16,7 @@ tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): e var r6 = map([1, ""], (x) => x.toString()); var r7 = map([1, ""], (x) => x.toString()); // error ~~~~~~~ -!!! error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. !!! error TS2345: Type 'string | number' is not assignable to type 'number': !!! error TS2345: Type 'string' is not assignable to type 'number'. var r7b = map([1, ""], (x) => x.toString()); // error diff --git a/tests/baselines/reference/nestedRecursiveLambda.types b/tests/baselines/reference/nestedRecursiveLambda.types index 358ebda8abf..864daea3e1f 100644 --- a/tests/baselines/reference/nestedRecursiveLambda.types +++ b/tests/baselines/reference/nestedRecursiveLambda.types @@ -35,7 +35,7 @@ void(r =>(r => r)); >r : any [(r =>(r => r))] ->[(r =>(r => r))] : { (r: any): (r: any) => any; }[] +>[(r =>(r => r))] : ((r: any) => (r: any) => any)[] >(r =>(r => r)) : (r: any) => (r: any) => any >r =>(r => r) : (r: any) => (r: any) => any >r : any diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index b59b734b3d0..9965709713d 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -4,12 +4,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(20,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(55,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }': Index signatures are incompatible: Type 'string | number' is not assignable to type 'string': @@ -17,7 +14,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. -==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts (14 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts (11 errors) ==== // String indexer types constrain the types of named properties in their containing type interface MyNumber extends Number { @@ -40,8 +37,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo !!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. "3.0": string; // ok "4.0": number; // error - ~~~~~~~~~~~~~~ -!!! error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'. 3.0: MyNumber // error ~~~~~~~~~~~~~ !!! error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'. @@ -87,8 +82,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo foo(): string; // ok "3.0": string; // ok "4.0": number; // error - ~~~~~~~~~~~~~~ -!!! error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'. f: MyNumber; // error } @@ -109,8 +102,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo foo(): string; // ok "3.0": string; // ok "4.0": number; // error - ~~~~~~~~~~~~~~ -!!! error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'. f: MyNumber; // error } diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 4d0488ec80f..327a09d8813 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,16 +1,13 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(17,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(26,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(35,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: string | number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }': +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }': Index signatures are incompatible: - Type 'string | number | A' is not assignable to type 'A': - Type 'string' is not assignable to type 'A'. + Type 'number | A' is not assignable to type 'A': + Type 'number' is not assignable to type 'A'. -==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (4 errors) ==== // String indexer providing a constraint of a user defined type class A { @@ -30,8 +27,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo ~~~~~~~~~~~~ !!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. "4.0": string; // error - ~~~~~~~~~~~~~~ -!!! error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'. } interface Foo2 { @@ -43,8 +38,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo ~~~~~~~~~~~~ !!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. "4.0": string; // error - ~~~~~~~~~~~~~~ -!!! error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'. } var a: { @@ -56,17 +49,15 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo ~~~~~~~~~~~~ !!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. "4.0": string; // error - ~~~~~~~~~~~~~~ -!!! error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'. }; // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: string | number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }': +!!! error TS2322: Type '{ [x: number]: number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }': !!! error TS2322: Index signatures are incompatible: -!!! error TS2322: Type 'string | number | A' is not assignable to type 'A': -!!! error TS2322: Type 'string' is not assignable to type 'A'. +!!! error TS2322: Type 'number | A' is not assignable to type 'A': +!!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), "2.5": new B(), diff --git a/tests/baselines/reference/parenthesizedTypes.js b/tests/baselines/reference/parenthesizedTypes.js new file mode 100644 index 00000000000..a80d9d98c31 --- /dev/null +++ b/tests/baselines/reference/parenthesizedTypes.js @@ -0,0 +1,52 @@ +//// [parenthesizedTypes.ts] +var a: string; +var a: (string); +var a: ((string) | string | (((string)))); +var a: ((((((((((((((((((((((((((((((((((((((((string)))))))))))))))))))))))))))))))))))))))); + +var b: (x: string) => string; +var b: ((x: (string)) => (string)); + +var c: string[] | number[]; +var c: (string)[] | (number)[]; +var c: ((string)[]) | ((number)[]); + +var d: (((x: string) => string) | ((x: number) => number))[]; +var d: ({ (x: string): string } | { (x: number): number })[]; +var d: Array<((x: string) => string) | ((x: number) => number)>; +var d: Array<{ (x: string): string } | { (x: number): number }>; +var d: (Array<{ (x: string): string } | { (x: number): number }>); + +var e: typeof a[]; +var e: (typeof a)[]; + +var f: (string) => string; +var f: (string: any) => string; + +var g: [string, string]; +var g: [(string), string]; +var g: [(string), (((typeof a)))]; + + +//// [parenthesizedTypes.js] +var a; +var a; +var a; +var a; +var b; +var b; +var c; +var c; +var c; +var d; +var d; +var d; +var d; +var d; +var e; +var e; +var f; +var f; +var g; +var g; +var g; diff --git a/tests/baselines/reference/parenthesizedTypes.types b/tests/baselines/reference/parenthesizedTypes.types new file mode 100644 index 00000000000..4b7129b3782 --- /dev/null +++ b/tests/baselines/reference/parenthesizedTypes.types @@ -0,0 +1,84 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/parenthesizedTypes.ts === +var a: string; +>a : string + +var a: (string); +>a : string + +var a: ((string) | string | (((string)))); +>a : string + +var a: ((((((((((((((((((((((((((((((((((((((((string)))))))))))))))))))))))))))))))))))))))); +>a : string + +var b: (x: string) => string; +>b : (x: string) => string +>x : string + +var b: ((x: (string)) => (string)); +>b : (x: string) => string +>x : string + +var c: string[] | number[]; +>c : string[] | number[] + +var c: (string)[] | (number)[]; +>c : string[] | number[] + +var c: ((string)[]) | ((number)[]); +>c : string[] | number[] + +var d: (((x: string) => string) | ((x: number) => number))[]; +>d : (((x: string) => string) | ((x: number) => number))[] +>x : string +>x : number + +var d: ({ (x: string): string } | { (x: number): number })[]; +>d : (((x: string) => string) | ((x: number) => number))[] +>x : string +>x : number + +var d: Array<((x: string) => string) | ((x: number) => number)>; +>d : (((x: string) => string) | ((x: number) => number))[] +>Array : T[] +>x : string +>x : number + +var d: Array<{ (x: string): string } | { (x: number): number }>; +>d : (((x: string) => string) | ((x: number) => number))[] +>Array : T[] +>x : string +>x : number + +var d: (Array<{ (x: string): string } | { (x: number): number }>); +>d : (((x: string) => string) | ((x: number) => number))[] +>Array : T[] +>x : string +>x : number + +var e: typeof a[]; +>e : string[] +>a : string + +var e: (typeof a)[]; +>e : string[] +>a : string + +var f: (string) => string; +>f : (string: any) => string +>string : any + +var f: (string: any) => string; +>f : (string: any) => string +>string : any + +var g: [string, string]; +>g : [string, string] + +var g: [(string), string]; +>g : [string, string] + +var g: [(string), (((typeof a)))]; +>g : [string, string] +>a : string + diff --git a/tests/baselines/reference/propertiesAndIndexers2.errors.txt b/tests/baselines/reference/propertiesAndIndexers2.errors.txt new file mode 100644 index 00000000000..e1ab8c9d13d --- /dev/null +++ b/tests/baselines/reference/propertiesAndIndexers2.errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/propertiesAndIndexers2.ts(2,5): error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(8,5): error TS2411: Property 'c' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(9,5): error TS2411: Property '3' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(10,5): error TS2411: Property 'Infinity' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(11,5): error TS2411: Property '"-Infinity"' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(12,5): error TS2411: Property 'NaN' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(13,5): error TS2411: Property '"-NaN"' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2411: Property '6' of type '() => string' is not assignable to string index type 'number'. +tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2412: Property '6' of type '() => string' is not assignable to numeric index type 'string'. + + +==== tests/cases/compiler/propertiesAndIndexers2.ts (9 errors) ==== + interface A { + [n: number]: string; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. + [s: string]: number; + } + + // All of these should fail. + interface B extends A { + c: string; + ~~~~~~~~~~ +!!! error TS2411: Property 'c' of type 'string' is not assignable to string index type 'number'. + 3: string; + ~~~~~~~~~~ +!!! error TS2411: Property '3' of type 'string' is not assignable to string index type 'number'. + Infinity: string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'Infinity' of type 'string' is not assignable to string index type 'number'. + "-Infinity": string; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property '"-Infinity"' of type 'string' is not assignable to string index type 'number'. + NaN: string; + ~~~~~~~~~~~~ +!!! error TS2411: Property 'NaN' of type 'string' is not assignable to string index type 'number'. + "-NaN": string; + ~~~~~~~~~~~~~~~ +!!! error TS2411: Property '"-NaN"' of type 'string' is not assignable to string index type 'number'. + 6(): string; + ~~~~~~~~~~~~ +!!! error TS2411: Property '6' of type '() => string' is not assignable to string index type 'number'. + ~~~~~~~~~~~~ +!!! error TS2412: Property '6' of type '() => string' is not assignable to numeric index type 'string'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/propertiesAndIndexers2.js b/tests/baselines/reference/propertiesAndIndexers2.js new file mode 100644 index 00000000000..74485a89248 --- /dev/null +++ b/tests/baselines/reference/propertiesAndIndexers2.js @@ -0,0 +1,19 @@ +//// [propertiesAndIndexers2.ts] +interface A { + [n: number]: string; + [s: string]: number; +} + +// All of these should fail. +interface B extends A { + c: string; + 3: string; + Infinity: string; + "-Infinity": string; + NaN: string; + "-NaN": string; + 6(): string; +} + + +//// [propertiesAndIndexers2.js] diff --git a/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt b/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt new file mode 100644 index 00000000000..01dcb61c70c --- /dev/null +++ b/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt @@ -0,0 +1,69 @@ +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(6,5): error TS2412: Property '"1"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(7,5): error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(8,5): error TS2412: Property '"-2.5"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(9,5): error TS2412: Property '"3.141592"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(10,5): error TS2412: Property '"1.2e-20"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(11,5): error TS2412: Property '"Infinity"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(12,5): error TS2412: Property '"-Infinity"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(13,5): error TS2412: Property '"NaN"' of type 'string' is not assignable to numeric index type 'number'. + + +==== tests/cases/compiler/propertiesAndIndexersForNumericNames.ts (8 errors) ==== + class C { + [i: number]: number; + + // These all have numeric names; they should error + // because their types are not compatible with the numeric indexer. + public "1": string = "number"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"1"' of type 'string' is not assignable to numeric index type 'number'. + public "-1": string = "negative number"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index type 'number'. + public "-2.5": string = "negative number"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"-2.5"' of type 'string' is not assignable to numeric index type 'number'. + public "3.141592": string = "pi-sitive number"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"3.141592"' of type 'string' is not assignable to numeric index type 'number'. + public "1.2e-20": string = "really small number"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"1.2e-20"' of type 'string' is not assignable to numeric index type 'number'. + public "Infinity": string = "A gillion"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"Infinity"' of type 'string' is not assignable to numeric index type 'number'. + public "-Infinity": string = "Negative-a-gillion"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"-Infinity"' of type 'string' is not assignable to numeric index type 'number'. + public "NaN": string = "not a number"; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2412: Property '"NaN"' of type 'string' is not assignable to numeric index type 'number'. + + // These all have *partially* numeric names, + // but should really be treated as plain string literals. + public " 1": string = "leading space"; // No error + public "1 ": string = "trailing space"; // No error + public "": string = "no nothing"; // No error + public " ": string = "just space"; // No error + public "1 0 1": string = "several numbers and spaces"; // No error + public "hunter2": string = "not a password"; // No error + public "+Infinity": string = "A gillion"; // No error + public "+NaN": string = "not a positive number"; // No error + public "-NaN": string = "not a negative number"; // No error + + + // These fall into the above category, however, they are "trickier"; + // these all are *scanned* as numeric literals, but they are not written in + // "canonical" numeric representations. + public "+1": string = "positive number (for the paranoid)"; // No error + public "1e0": string = "just one"; // No error + public "-0": string = "just zero"; // No error + public "-0e0": string = "just zero"; // No error + public "0xF00D": string = "hex food"; // No error + public "0xBEEF": string = "hex beef"; // No error + public "0123": string = "oct 83"; // No error + public "0o123": string = "explicit oct 83"; // No error + public "0b101101001010": string = "explicit binary"; // No error + public "0.000000000000000000012": string = "should've been in exponential form"; // No error + } + \ No newline at end of file diff --git a/tests/baselines/reference/propertiesAndIndexersForNumericNames.js b/tests/baselines/reference/propertiesAndIndexersForNumericNames.js new file mode 100644 index 00000000000..975abdc00ec --- /dev/null +++ b/tests/baselines/reference/propertiesAndIndexersForNumericNames.js @@ -0,0 +1,84 @@ +//// [propertiesAndIndexersForNumericNames.ts] +class C { + [i: number]: number; + + // These all have numeric names; they should error + // because their types are not compatible with the numeric indexer. + public "1": string = "number"; // Error + public "-1": string = "negative number"; // Error + public "-2.5": string = "negative number"; // Error + public "3.141592": string = "pi-sitive number"; // Error + public "1.2e-20": string = "really small number"; // Error + public "Infinity": string = "A gillion"; // Error + public "-Infinity": string = "Negative-a-gillion"; // Error + public "NaN": string = "not a number"; // Error + + // These all have *partially* numeric names, + // but should really be treated as plain string literals. + public " 1": string = "leading space"; // No error + public "1 ": string = "trailing space"; // No error + public "": string = "no nothing"; // No error + public " ": string = "just space"; // No error + public "1 0 1": string = "several numbers and spaces"; // No error + public "hunter2": string = "not a password"; // No error + public "+Infinity": string = "A gillion"; // No error + public "+NaN": string = "not a positive number"; // No error + public "-NaN": string = "not a negative number"; // No error + + + // These fall into the above category, however, they are "trickier"; + // these all are *scanned* as numeric literals, but they are not written in + // "canonical" numeric representations. + public "+1": string = "positive number (for the paranoid)"; // No error + public "1e0": string = "just one"; // No error + public "-0": string = "just zero"; // No error + public "-0e0": string = "just zero"; // No error + public "0xF00D": string = "hex food"; // No error + public "0xBEEF": string = "hex beef"; // No error + public "0123": string = "oct 83"; // No error + public "0o123": string = "explicit oct 83"; // No error + public "0b101101001010": string = "explicit binary"; // No error + public "0.000000000000000000012": string = "should've been in exponential form"; // No error +} + + +//// [propertiesAndIndexersForNumericNames.js] +var C = (function () { + function C() { + // These all have numeric names; they should error + // because their types are not compatible with the numeric indexer. + this["1"] = "number"; // Error + this["-1"] = "negative number"; // Error + this["-2.5"] = "negative number"; // Error + this["3.141592"] = "pi-sitive number"; // Error + this["1.2e-20"] = "really small number"; // Error + this["Infinity"] = "A gillion"; // Error + this["-Infinity"] = "Negative-a-gillion"; // Error + this["NaN"] = "not a number"; // Error + // These all have *partially* numeric names, + // but should really be treated as plain string literals. + this[" 1"] = "leading space"; // No error + this["1 "] = "trailing space"; // No error + this[""] = "no nothing"; // No error + this[" "] = "just space"; // No error + this["1 0 1"] = "several numbers and spaces"; // No error + this["hunter2"] = "not a password"; // No error + this["+Infinity"] = "A gillion"; // No error + this["+NaN"] = "not a positive number"; // No error + this["-NaN"] = "not a negative number"; // No error + // These fall into the above category, however, they are "trickier"; + // these all are *scanned* as numeric literals, but they are not written in + // "canonical" numeric representations. + this["+1"] = "positive number (for the paranoid)"; // No error + this["1e0"] = "just one"; // No error + this["-0"] = "just zero"; // No error + this["-0e0"] = "just zero"; // No error + this["0xF00D"] = "hex food"; // No error + this["0xBEEF"] = "hex beef"; // No error + this["0123"] = "oct 83"; // No error + this["0o123"] = "explicit oct 83"; // No error + this["0b101101001010"] = "explicit binary"; // No error + this["0.000000000000000000012"] = "should've been in exponential form"; // No error + } + return C; +})(); diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index b71b04263b1..8039cdf01f0 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -24,9 +24,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | MyString | { (): void; }; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }': +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | MyString | (() => void); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }': Index signatures are incompatible: - Type 'string | number | MyString | { (): void; }' is not assignable to type 'string': + Type 'string | number | MyString | (() => void)' is not assignable to type 'string': Type 'number' is not assignable to type 'string'. @@ -160,9 +160,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | MyString | { (): void; }; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }': +!!! error TS2322: Type '{ [x: string]: string | number | MyString | (() => void); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }': !!! error TS2322: Index signatures are incompatible: -!!! error TS2322: Type 'string | number | MyString | { (): void; }' is not assignable to type 'string': +!!! error TS2322: Type 'string | number | MyString | (() => void)' is not assignable to type 'string': !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 12344a46f3f..a2669bf6e65 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -330,14 +330,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : { (x: T): T[]; }[] ->[r1arg2, r1arg1] : { (x: T): T[]; }[] +>r1a : ((x: T) => T[])[] +>[r1arg2, r1arg1] : ((x: T) => T[])[] >r1arg2 : (x: number) => number[] >r1arg1 : (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : { (x: T): T[]; }[] ->[r1arg1, r1arg2] : { (x: T): T[]; }[] +>r1b : ((x: T) => T[])[] +>[r1arg1, r1arg2] : ((x: T) => T[])[] >r1arg1 : (x: T) => T[] >r1arg2 : (x: number) => number[] @@ -362,14 +362,14 @@ var r2 = foo2(r2arg1); >r2arg1 : (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : { (x: T): string[]; }[] ->[r2arg1, r2arg2] : { (x: T): string[]; }[] +>r2a : ((x: T) => string[])[] +>[r2arg1, r2arg2] : ((x: T) => string[])[] >r2arg1 : (x: T) => string[] >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : { (x: T): string[]; }[] ->[r2arg2, r2arg1] : { (x: T): string[]; }[] +>r2b : ((x: T) => string[])[] +>[r2arg2, r2arg1] : ((x: T) => string[])[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -393,14 +393,14 @@ var r3 = foo3(r3arg1); >r3arg1 : (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : { (x: T): T; }[] ->[r3arg1, r3arg2] : { (x: T): T; }[] +>r3a : ((x: T) => T)[] +>[r3arg1, r3arg2] : ((x: T) => T)[] >r3arg1 : (x: T) => T >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : { (x: T): T; }[] ->[r3arg2, r3arg1] : { (x: T): T; }[] +>r3b : ((x: T) => T)[] +>[r3arg2, r3arg1] : ((x: T) => T)[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -428,14 +428,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : { (x: T, y: U): T; }[] ->[r4arg1, r4arg2] : { (x: T, y: U): T; }[] +>r4a : ((x: T, y: U) => T)[] +>[r4arg1, r4arg2] : ((x: T, y: U) => T)[] >r4arg1 : (x: T, y: U) => T >r4arg2 : (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : { (x: T, y: U): T; }[] ->[r4arg2, r4arg1] : { (x: T, y: U): T; }[] +>r4b : ((x: T, y: U) => T)[] +>[r4arg2, r4arg1] : ((x: T, y: U) => T)[] >r4arg2 : (x: string, y: number) => string >r4arg1 : (x: T, y: U) => T @@ -464,14 +464,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : { (x: (arg: T) => U): T; }[] ->[r5arg1, r5arg2] : { (x: (arg: T) => U): T; }[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : { (x: (arg: T) => U): T; }[] ->[r5arg2, r5arg1] : { (x: (arg: T) => U): T; }[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -506,14 +506,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : { (x: (arg: T) => U): T; }[] ->[r6arg1, r6arg2] : { (x: (arg: T) => U): T; }[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : { (x: (arg: T) => U): T; }[] ->[r6arg2, r6arg1] : { (x: (arg: T) => U): T; }[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -554,14 +554,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : { (x: (arg: T) => U): (r: T) => U; }[] ->[r7arg1, r7arg2] : { (x: (arg: T) => U): (r: T) => U; }[] +>r7a : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : { (x: (arg: T) => U): (r: T) => U; }[] ->[r7arg2, r7arg1] : { (x: (arg: T) => U): (r: T) => U; }[] +>r7b : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -610,14 +610,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : { (x: (arg: T) => U, y: (arg2: T) => U): (r: T) => U; }[] ->[r8arg1, r8arg2] : { (x: (arg: T) => U, y: (arg2: T) => U): (r: T) => U; }[] +>r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : { (x: (arg: T) => U, y: (arg2: T) => U): (r: T) => U; }[] ->[r8arg2, r8arg1] : { (x: (arg: T) => U, y: (arg2: T) => U): (r: T) => U; }[] +>r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -667,14 +667,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : { (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): (r: T) => U; }[] ->[r9arg1, r9arg2] : { (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): (r: T) => U; }[] +>r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : { (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): (r: T) => U; }[] ->[r9arg2, r9arg1] : { (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): (r: T) => U; }[] +>r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U @@ -703,14 +703,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : { (...x: T[]): T; }[] ->[r10arg1, r10arg2] : { (...x: T[]): T; }[] +>r10a : ((...x: T[]) => T)[] +>[r10arg1, r10arg2] : ((...x: T[]) => T)[] >r10arg1 : (...x: T[]) => T >r10arg2 : (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : { (...x: T[]): T; }[] ->[r10arg2, r10arg1] : { (...x: T[]): T; }[] +>r10b : ((...x: T[]) => T)[] +>[r10arg2, r10arg1] : ((...x: T[]) => T)[] >r10arg2 : (...x: Derived[]) => Derived >r10arg1 : (...x: T[]) => T @@ -743,14 +743,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : { (x: T, y: T): T; }[] ->[r11arg1, r11arg2] : { (x: T, y: T): T; }[] +>r11a : ((x: T, y: T) => T)[] +>[r11arg1, r11arg2] : ((x: T, y: T) => T)[] >r11arg1 : (x: T, y: T) => T >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : { (x: T, y: T): T; }[] ->[r11arg2, r11arg1] : { (x: T, y: T): T; }[] +>r11b : ((x: T, y: T) => T)[] +>[r11arg2, r11arg1] : ((x: T, y: T) => T)[] >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : (x: T, y: T) => T @@ -789,14 +789,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : { (x: Base[], y: T): Derived[]; }[] ->[r12arg1, r12arg2] : { (x: Base[], y: T): Derived[]; }[] +>r12a : ((x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : ((x: Base[], y: T) => Derived[])[] >r12arg1 : (x: Base[], y: T) => Derived[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : { (x: Base[], y: T): Derived[]; }[] ->[r12arg2, r12arg1] : { (x: Base[], y: T): Derived[]; }[] +>r12b : ((x: Base[], y: T) => Derived[])[] +>[r12arg2, r12arg1] : ((x: Base[], y: T) => Derived[])[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] @@ -833,14 +833,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : { (x: Base[], y: T): T; }[] ->[r13arg1, r13arg2] : { (x: Base[], y: T): T; }[] +>r13a : ((x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : ((x: Base[], y: T) => T)[] >r13arg1 : (x: Base[], y: T) => T >r13arg2 : (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : { (x: Base[], y: T): T; }[] ->[r13arg2, r13arg1] : { (x: Base[], y: T): T; }[] +>r13b : ((x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : ((x: Base[], y: T) => T)[] >r13arg2 : (x: Base[], y: Derived[]) => Derived[] >r13arg1 : (x: Base[], y: T) => T @@ -873,14 +873,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : { (x: { a: T; b: T; }): T; }[] ->[r14arg1, r14arg2] : { (x: { a: T; b: T; }): T; }[] +>r14a : ((x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : ((x: { a: T; b: T; }) => T)[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : { (x: { a: T; b: T; }): T; }[] ->[r14arg2, r14arg1] : { (x: { a: T; b: T; }): T; }[] +>r14b : ((x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : ((x: { a: T; b: T; }) => T)[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index be5fb44c9c7..cc2d47d3a33 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -218,8 +218,8 @@ module Errors { >U : U var r1a = [(x: number) => [''], (x: T) => null]; ->r1a : { (x: T): U[]; }[] ->[(x: number) => [''], (x: T) => null] : { (x: T): U[]; }[] +>r1a : ((x: T) => U[])[] +>[(x: number) => [''], (x: T) => null] : ((x: T) => U[])[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] @@ -232,8 +232,8 @@ module Errors { >U : U var r1b = [(x: T) => null, (x: number) => ['']]; ->r1b : { (x: T): U[]; }[] ->[(x: T) => null, (x: number) => ['']] : { (x: T): U[]; }[] +>r1b : ((x: T) => U[])[] +>[(x: T) => null, (x: number) => ['']] : ((x: T) => U[])[] >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -284,14 +284,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : { (x: (arg: T) => U): (r: T) => V; }[] ->[r2arg2, r2arg] : { (x: (arg: T) => U): (r: T) => V; }[] +>r2a : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : { (x: (arg: T) => U): (r: T) => V; }[] ->[r2arg, r2arg2] : { (x: (arg: T) => U): (r: T) => V; }[] +>r2b : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 @@ -340,14 +340,14 @@ module Errors { >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U var r3a = [r3arg2, r3arg]; ->r3a : Array<{ (x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }> ->[r3arg2, r3arg] : Array<{ (x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }> +>r3a : (((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>[r3arg2, r3arg] : (((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] >r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U var r3b = [r3arg, r3arg2]; ->r3b : Array<{ (x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }> ->[r3arg, r3arg2] : Array<{ (x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }> +>r3b : (((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>[r3arg, r3arg2] : (((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U >r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived @@ -376,14 +376,14 @@ module Errors { >r4arg : (...x: T[]) => T var r4a = [r4arg2, r4arg]; ->r4a : { (...x: T[]): T; }[] ->[r4arg2, r4arg] : { (...x: T[]): T; }[] +>r4a : ((...x: T[]) => T)[] +>[r4arg2, r4arg] : ((...x: T[]) => T)[] >r4arg2 : (...x: Base[]) => Base >r4arg : (...x: T[]) => T var r4b = [r4arg, r4arg2]; ->r4b : { (...x: T[]): T; }[] ->[r4arg, r4arg2] : { (...x: T[]): T; }[] +>r4b : ((...x: T[]) => T)[] +>[r4arg, r4arg2] : ((...x: T[]) => T)[] >r4arg : (...x: T[]) => T >r4arg2 : (...x: Base[]) => Base @@ -417,14 +417,14 @@ module Errors { >r5arg : (x: T, y: T) => T var r5a = [r5arg2, r5arg]; ->r5a : { (x: T, y: T): T; }[] ->[r5arg2, r5arg] : { (x: T, y: T): T; }[] +>r5a : ((x: T, y: T) => T)[] +>[r5arg2, r5arg] : ((x: T, y: T) => T)[] >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg : (x: T, y: T) => T var r5b = [r5arg, r5arg2]; ->r5b : { (x: T, y: T): T; }[] ->[r5arg, r5arg2] : { (x: T, y: T): T; }[] +>r5b : ((x: T, y: T) => T)[] +>[r5arg, r5arg2] : ((x: T, y: T) => T)[] >r5arg : (x: T, y: T) => T >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -463,14 +463,14 @@ module Errors { >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg]; ->r6a : { (x: Base[], y: Base[]): T; }[] ->[r6arg2, r6arg] : { (x: Base[], y: Base[]): T; }[] +>r6a : ((x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg] : ((x: Base[], y: Base[]) => T)[] >r6arg2 : (x: Base[], y: Base[]) => T >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg, r6arg2]; ->r6b : { (x: Base[], y: Base[]): T; }[] ->[r6arg, r6arg2] : { (x: Base[], y: Base[]): T; }[] +>r6b : ((x: Base[], y: Base[]) => T)[] +>[r6arg, r6arg2] : ((x: Base[], y: Base[]) => T)[] >r6arg : (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : (x: Base[], y: Base[]) => T @@ -500,14 +500,14 @@ module Errors { >r7arg : (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg]; ->r7a : { (x: { a: T; b: T; }): T; }[] ->[r7arg2, r7arg] : { (x: { a: T; b: T; }): T; }[] +>r7a : ((x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg] : ((x: { a: T; b: T; }) => T)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg : (x: { a: T; b: T; }) => T var r7b = [r7arg, r7arg2]; ->r7b : { (x: { a: T; b: T; }): T; }[] ->[r7arg, r7arg2] : { (x: { a: T; b: T; }): T; }[] +>r7b : ((x: { a: T; b: T; }) => T)[] +>[r7arg, r7arg2] : ((x: { a: T; b: T; }) => T)[] >r7arg : (x: { a: T; b: T; }) => T >r7arg2 : (x: { a: string; b: number; }) => number @@ -529,14 +529,14 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : { (x: { a: string; b: number; }): number; }[] ->[r7arg2, r7arg3] : { (x: { a: string; b: number; }): number; }[] +>r7d : ((x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : ((x: { a: string; b: number; }) => number)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : { (x: { a: string; b: number; }): number; }[] ->[r7arg3, r7arg2] : { (x: { a: string; b: number; }): number; }[] +>r7e : ((x: { a: string; b: number; }) => number)[] +>[r7arg3, r7arg2] : ((x: { a: string; b: number; }) => number)[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index f31a4fa928e..0325552187b 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -244,14 +244,14 @@ var r1 = foo1(r1arg); >r1arg : (x: T) => T[] var r1a = [r1arg, r1arg2]; ->r1a : { (x: T): T[]; }[] ->[r1arg, r1arg2] : { (x: T): T[]; }[] +>r1a : ((x: T) => T[])[] +>[r1arg, r1arg2] : ((x: T) => T[])[] >r1arg : (x: T) => T[] >r1arg2 : (x: T) => T[] var r1b = [r1arg2, r1arg]; ->r1b : { (x: T): T[]; }[] ->[r1arg2, r1arg] : { (x: T): T[]; }[] +>r1b : ((x: T) => T[])[] +>[r1arg2, r1arg] : ((x: T) => T[])[] >r1arg2 : (x: T) => T[] >r1arg : (x: T) => T[] @@ -278,14 +278,14 @@ var r2 = foo2(r2arg); >r2arg : (x: T) => string[] var r2a = [r2arg, r2arg2]; ->r2a : { (x: T): string[]; }[] ->[r2arg, r2arg2] : { (x: T): string[]; }[] +>r2a : ((x: T) => string[])[] +>[r2arg, r2arg2] : ((x: T) => string[])[] >r2arg : (x: T) => string[] >r2arg2 : (x: T) => string[] var r2b = [r2arg2, r2arg]; ->r2b : { (x: T): string[]; }[] ->[r2arg2, r2arg] : { (x: T): string[]; }[] +>r2b : ((x: T) => string[])[] +>[r2arg2, r2arg] : ((x: T) => string[])[] >r2arg2 : (x: T) => string[] >r2arg : (x: T) => string[] @@ -312,14 +312,14 @@ var r3 = foo3(r3arg); >r3arg : (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : { (x: T): T; }[] ->[r3arg, r3arg2] : { (x: T): T; }[] +>r3a : ((x: T) => T)[] +>[r3arg, r3arg2] : ((x: T) => T)[] >r3arg : (x: T) => T >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : { (x: T): T; }[] ->[r3arg2, r3arg] : { (x: T): T; }[] +>r3b : ((x: T) => T)[] +>[r3arg2, r3arg] : ((x: T) => T)[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -350,14 +350,14 @@ var r4 = foo4(r4arg); >r4arg : (x: T, y: U) => string var r4a = [r4arg, r4arg2]; ->r4a : { (x: T, y: U): string; }[] ->[r4arg, r4arg2] : { (x: T, y: U): string; }[] +>r4a : ((x: T, y: U) => string)[] +>[r4arg, r4arg2] : ((x: T, y: U) => string)[] >r4arg : (x: T, y: U) => string >r4arg2 : (x: T, y: U) => string var r4b = [r4arg2, r4arg]; ->r4b : { (x: T, y: U): string; }[] ->[r4arg2, r4arg] : { (x: T, y: U): string; }[] +>r4b : ((x: T, y: U) => string)[] +>[r4arg2, r4arg] : ((x: T, y: U) => string)[] >r4arg2 : (x: T, y: U) => string >r4arg : (x: T, y: U) => string @@ -392,14 +392,14 @@ var r5 = foo5(r5arg); >r5arg : (x: (arg: T) => U) => T var r5a = [r5arg, r5arg2]; ->r5a : { (x: (arg: T) => U): T; }[] ->[r5arg, r5arg2] : { (x: (arg: T) => U): T; }[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: T) => U) => T var r5b = [r5arg2, r5arg]; ->r5b : { (x: (arg: T) => U): T; }[] ->[r5arg2, r5arg] : { (x: (arg: T) => U): T; }[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: T) => U) => T >r5arg : (x: (arg: T) => U) => T @@ -436,14 +436,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : { (x: (arg: T) => U): T; }[] ->[r6arg, r6arg2] : { (x: (arg: T) => U): T; }[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : { (x: (arg: T) => U): T; }[] ->[r6arg2, r6arg] : { (x: (arg: T) => U): T; }[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -485,14 +485,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : { (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] ->[r11arg, r11arg2] : { (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] +>r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : { (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] ->[r11arg2, r11arg] : { (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] +>r11b : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -528,14 +528,14 @@ var r15 = foo15(r15arg); >r15arg : (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : { (x: { a: U; b: V; }): U[]; }[] ->[r15arg, r15arg2] : { (x: { a: U; b: V; }): U[]; }[] +>r15a : ((x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : ((x: { a: U; b: V; }) => U[])[] >r15arg : (x: { a: U; b: V; }) => U[] >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : { (x: { a: U; b: V; }): U[]; }[] ->[r15arg2, r15arg] : { (x: { a: U; b: V; }): U[]; }[] +>r15b : ((x: { a: U; b: V; }) => U[])[] +>[r15arg2, r15arg] : ((x: { a: U; b: V; }) => U[])[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] @@ -572,14 +572,14 @@ var r16 = foo16(r16arg); >r16arg : (x: { a: T; b: T; }) => T[] var r16a = [r16arg, r16arg2]; ->r16a : { (x: { a: T; b: T; }): T[]; }[] ->[r16arg, r16arg2] : { (x: { a: T; b: T; }): T[]; }[] +>r16a : ((x: { a: T; b: T; }) => T[])[] +>[r16arg, r16arg2] : ((x: { a: T; b: T; }) => T[])[] >r16arg : (x: { a: T; b: T; }) => T[] >r16arg2 : (x: { a: T; b: T; }) => T[] var r16b = [r16arg2, r16arg]; ->r16b : { (x: { a: T; b: T; }): T[]; }[] ->[r16arg2, r16arg] : { (x: { a: T; b: T; }): T[]; }[] +>r16b : ((x: { a: T; b: T; }) => T[])[] +>[r16arg2, r16arg] : ((x: { a: T; b: T; }) => T[])[] >r16arg2 : (x: { a: T; b: T; }) => T[] >r16arg : (x: { a: T; b: T; }) => T[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index 3832697d04c..d723a367ecb 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -326,14 +326,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : new (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : { new (x: T): T[]; }[] ->[r1arg2, r1arg1] : { new (x: T): T[]; }[] +>r1a : (new (x: T) => T[])[] +>[r1arg2, r1arg1] : (new (x: T) => T[])[] >r1arg2 : new (x: number) => number[] >r1arg1 : new (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : { new (x: T): T[]; }[] ->[r1arg1, r1arg2] : { new (x: T): T[]; }[] +>r1b : (new (x: T) => T[])[] +>[r1arg1, r1arg2] : (new (x: T) => T[])[] >r1arg1 : new (x: T) => T[] >r1arg2 : new (x: number) => number[] @@ -354,14 +354,14 @@ var r2 = foo2(r2arg1); >r2arg1 : new (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : { new (x: T): string[]; }[] ->[r2arg1, r2arg2] : { new (x: T): string[]; }[] +>r2a : (new (x: T) => string[])[] +>[r2arg1, r2arg2] : (new (x: T) => string[])[] >r2arg1 : new (x: T) => string[] >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : { new (x: T): string[]; }[] ->[r2arg2, r2arg1] : { new (x: T): string[]; }[] +>r2b : (new (x: T) => string[])[] +>[r2arg2, r2arg1] : (new (x: T) => string[])[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -383,14 +383,14 @@ var r3 = foo3(r3arg1); >r3arg1 : new (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : { new (x: T): T; }[] ->[r3arg1, r3arg2] : { new (x: T): T; }[] +>r3a : (new (x: T) => T)[] +>[r3arg1, r3arg2] : (new (x: T) => T)[] >r3arg1 : new (x: T) => T >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : { new (x: T): T; }[] ->[r3arg2, r3arg1] : { new (x: T): T; }[] +>r3b : (new (x: T) => T)[] +>[r3arg2, r3arg1] : (new (x: T) => T)[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -416,14 +416,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : new (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : { new (x: T, y: U): T; }[] ->[r4arg1, r4arg2] : { new (x: T, y: U): T; }[] +>r4a : (new (x: T, y: U) => T)[] +>[r4arg1, r4arg2] : (new (x: T, y: U) => T)[] >r4arg1 : new (x: T, y: U) => T >r4arg2 : new (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : { new (x: T, y: U): T; }[] ->[r4arg2, r4arg1] : { new (x: T, y: U): T; }[] +>r4b : (new (x: T, y: U) => T)[] +>[r4arg2, r4arg1] : (new (x: T, y: U) => T)[] >r4arg2 : new (x: string, y: number) => string >r4arg1 : new (x: T, y: U) => T @@ -449,14 +449,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : new (x: new (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : { new (x: new (arg: T) => U): T; }[] ->[r5arg1, r5arg2] : { new (x: new (arg: T) => U): T; }[] +>r5a : (new (x: new (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : (new (x: new (arg: T) => U) => T)[] >r5arg1 : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : { new (x: new (arg: T) => U): T; }[] ->[r5arg2, r5arg1] : { new (x: new (arg: T) => U): T; }[] +>r5b : (new (x: new (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : (new (x: new (arg: T) => U) => T)[] >r5arg2 : new (x: new (arg: string) => number) => string >r5arg1 : new (x: new (arg: T) => U) => T @@ -487,14 +487,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : new (x: new (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : { new (x: new (arg: T) => U): T; }[] ->[r6arg1, r6arg2] : { new (x: new (arg: T) => U): T; }[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg1 : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : { new (x: new (arg: T) => U): T; }[] ->[r6arg2, r6arg1] : { new (x: new (arg: T) => U): T; }[] +>r6b : (new (x: new (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : (new (x: new (arg: T) => U) => T)[] >r6arg2 : new (x: new (arg: Base) => Derived) => Base >r6arg1 : new (x: new (arg: T) => U) => T @@ -529,14 +529,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : { new (x: new (arg: T) => U): new (r: T) => U; }[] ->[r7arg1, r7arg2] : { new (x: new (arg: T) => U): new (r: T) => U; }[] +>r7a : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg1, r7arg2] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : { new (x: new (arg: T) => U): new (r: T) => U; }[] ->[r7arg2, r7arg1] : { new (x: new (arg: T) => U): new (r: T) => U; }[] +>r7b : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg2, r7arg1] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U @@ -579,14 +579,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : { new (x: new (arg: T) => U, y: new (arg2: T) => U): new (r: T) => U; }[] ->[r8arg1, r8arg2] : { new (x: new (arg: T) => U, y: new (arg2: T) => U): new (r: T) => U; }[] +>r8a : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg1, r8arg2] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : { new (x: new (arg: T) => U, y: new (arg2: T) => U): new (r: T) => U; }[] ->[r8arg2, r8arg1] : { new (x: new (arg: T) => U, y: new (arg2: T) => U): new (r: T) => U; }[] +>r8b : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg2, r8arg1] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U @@ -630,14 +630,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> ->[r9arg1, r9arg2] : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> +>r9a : ((new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>[r9arg1, r9arg2] : ((new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] >r9arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U >r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> ->[r9arg2, r9arg1] : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> +>r9b : ((new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>[r9arg2, r9arg1] : ((new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] >r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r9arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U @@ -662,14 +662,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : new (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : { new (...x: T[]): T; }[] ->[r10arg1, r10arg2] : { new (...x: T[]): T; }[] +>r10a : (new (...x: T[]) => T)[] +>[r10arg1, r10arg2] : (new (...x: T[]) => T)[] >r10arg1 : new (...x: T[]) => T >r10arg2 : new (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : { new (...x: T[]): T; }[] ->[r10arg2, r10arg1] : { new (...x: T[]): T; }[] +>r10b : (new (...x: T[]) => T)[] +>[r10arg2, r10arg1] : (new (...x: T[]) => T)[] >r10arg2 : new (...x: Derived[]) => Derived >r10arg1 : new (...x: T[]) => T @@ -699,14 +699,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : new (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : { new (x: T, y: T): T; }[] ->[r11arg1, r11arg2] : { new (x: T, y: T): T; }[] +>r11a : (new (x: T, y: T) => T)[] +>[r11arg1, r11arg2] : (new (x: T, y: T) => T)[] >r11arg1 : new (x: T, y: T) => T >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : { new (x: T, y: T): T; }[] ->[r11arg2, r11arg1] : { new (x: T, y: T): T; }[] +>r11b : (new (x: T, y: T) => T)[] +>[r11arg2, r11arg1] : (new (x: T, y: T) => T)[] >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : new (x: T, y: T) => T @@ -741,14 +741,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : new (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : { new (x: Base[], y: T): Derived[]; }[] ->[r12arg1, r12arg2] : { new (x: Base[], y: T): Derived[]; }[] +>r12a : (new (x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : (new (x: Base[], y: T) => Derived[])[] >r12arg1 : new (x: Base[], y: T) => Derived[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : { new (x: Base[], y: T): Derived[]; }[] ->[r12arg2, r12arg1] : { new (x: Base[], y: T): Derived[]; }[] +>r12b : (new (x: Base[], y: T) => Derived[])[] +>[r12arg2, r12arg1] : (new (x: Base[], y: T) => Derived[])[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] @@ -782,14 +782,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : new (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : { new (x: Base[], y: T): T; }[] ->[r13arg1, r13arg2] : { new (x: Base[], y: T): T; }[] +>r13a : (new (x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : (new (x: Base[], y: T) => T)[] >r13arg1 : new (x: Base[], y: T) => T >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : { new (x: Base[], y: T): T; }[] ->[r13arg2, r13arg1] : { new (x: Base[], y: T): T; }[] +>r13b : (new (x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : (new (x: Base[], y: T) => T)[] >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] >r13arg1 : new (x: Base[], y: T) => T @@ -817,14 +817,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : { new (x: { a: T; b: T; }): T; }[] ->[r14arg1, r14arg2] : { new (x: { a: T; b: T; }): T; }[] +>r14a : (new (x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : (new (x: { a: T; b: T; }) => T)[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : { new (x: { a: T; b: T; }): T; }[] ->[r14arg2, r14arg1] : { new (x: { a: T; b: T; }): T; }[] +>r14b : (new (x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : (new (x: { a: T; b: T; }) => T)[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index ff6b9adef0a..b0f0680c7a0 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -224,14 +224,14 @@ module Errors { >r1arg1 : new (x: T) => U[] var r1a = [r1arg2, r1arg1]; ->r1a : { new (x: T): U[]; }[] ->[r1arg2, r1arg1] : { new (x: T): U[]; }[] +>r1a : (new (x: T) => U[])[] +>[r1arg2, r1arg1] : (new (x: T) => U[])[] >r1arg2 : new (x: number) => string[] >r1arg1 : new (x: T) => U[] var r1b = [r1arg1, r1arg2]; ->r1b : { new (x: T): U[]; }[] ->[r1arg1, r1arg2] : { new (x: T): U[]; }[] +>r1b : (new (x: T) => U[])[] +>[r1arg1, r1arg2] : (new (x: T) => U[])[] >r1arg1 : new (x: T) => U[] >r1arg2 : new (x: number) => string[] @@ -268,14 +268,14 @@ module Errors { >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2a = [r2arg2, r2arg1]; ->r2a : { new (x: new (arg: T) => U): new (r: T) => V; }[] ->[r2arg2, r2arg1] : { new (x: new (arg: T) => U): new (r: T) => V; }[] +>r2a : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg2, r2arg1] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2b = [r2arg1, r2arg2]; ->r2b : { new (x: new (arg: T) => U): new (r: T) => V; }[] ->[r2arg1, r2arg2] : { new (x: new (arg: T) => U): new (r: T) => V; }[] +>r2b : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg1, r2arg2] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 @@ -318,14 +318,14 @@ module Errors { >r3arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U var r3a = [r3arg2, r3arg1]; ->r3a : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> ->[r3arg2, r3arg1] : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> +>r3a : ((new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U) | (new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>[r3arg2, r3arg1] : ((new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U) | (new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] >r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r3arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U var r3b = [r3arg1, r3arg2]; ->r3b : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> ->[r3arg1, r3arg2] : Array<{ new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }> +>r3b : ((new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U) | (new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>[r3arg1, r3arg2] : ((new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U) | (new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] >r3arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U >r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived @@ -350,14 +350,14 @@ module Errors { >r4arg1 : new (...x: T[]) => T var r4a = [r4arg2, r4arg1]; ->r4a : { new (...x: T[]): T; }[] ->[r4arg2, r4arg1] : { new (...x: T[]): T; }[] +>r4a : (new (...x: T[]) => T)[] +>[r4arg2, r4arg1] : (new (...x: T[]) => T)[] >r4arg2 : new (...x: Base[]) => Base >r4arg1 : new (...x: T[]) => T var r4b = [r4arg1, r4arg2]; ->r4b : { new (...x: T[]): T; }[] ->[r4arg1, r4arg2] : { new (...x: T[]): T; }[] +>r4b : (new (...x: T[]) => T)[] +>[r4arg1, r4arg2] : (new (...x: T[]) => T)[] >r4arg1 : new (...x: T[]) => T >r4arg2 : new (...x: Base[]) => Base @@ -387,14 +387,14 @@ module Errors { >r5arg1 : new (x: T, y: T) => T var r5a = [r5arg2, r5arg1]; ->r5a : { new (x: T, y: T): T; }[] ->[r5arg2, r5arg1] : { new (x: T, y: T): T; }[] +>r5a : (new (x: T, y: T) => T)[] +>[r5arg2, r5arg1] : (new (x: T, y: T) => T)[] >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg1 : new (x: T, y: T) => T var r5b = [r5arg1, r5arg2]; ->r5b : { new (x: T, y: T): T; }[] ->[r5arg1, r5arg2] : { new (x: T, y: T): T; }[] +>r5b : (new (x: T, y: T) => T)[] +>[r5arg1, r5arg2] : (new (x: T, y: T) => T)[] >r5arg1 : new (x: T, y: T) => T >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -429,14 +429,14 @@ module Errors { >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg1]; ->r6a : { new (x: Base[], y: Base[]): T; }[] ->[r6arg2, r6arg1] : { new (x: Base[], y: Base[]): T; }[] +>r6a : (new (x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg1] : (new (x: Base[], y: Base[]) => T)[] >r6arg2 : new (x: Base[], y: Base[]) => T >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg1, r6arg2]; ->r6b : { new (x: Base[], y: Base[]): T; }[] ->[r6arg1, r6arg2] : { new (x: Base[], y: Base[]): T; }[] +>r6b : (new (x: Base[], y: Base[]) => T)[] +>[r6arg1, r6arg2] : (new (x: Base[], y: Base[]) => T)[] >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : new (x: Base[], y: Base[]) => T @@ -463,14 +463,14 @@ module Errors { >r7arg1 : new (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg1]; ->r7a : { new (x: { a: T; b: T; }): T; }[] ->[r7arg2, r7arg1] : { new (x: { a: T; b: T; }): T; }[] +>r7a : (new (x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg1] : (new (x: { a: T; b: T; }) => T)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg1 : new (x: { a: T; b: T; }) => T var r7b = [r7arg1, r7arg2]; ->r7b : { new (x: { a: T; b: T; }): T; }[] ->[r7arg1, r7arg2] : { new (x: { a: T; b: T; }): T; }[] +>r7b : (new (x: { a: T; b: T; }) => T)[] +>[r7arg1, r7arg2] : (new (x: { a: T; b: T; }) => T)[] >r7arg1 : new (x: { a: T; b: T; }) => T >r7arg2 : new (x: { a: string; b: number; }) => number @@ -491,14 +491,14 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : { new (x: { a: string; b: number; }): number; }[] ->[r7arg2, r7arg3] : { new (x: { a: string; b: number; }): number; }[] +>r7d : (new (x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : (new (x: { a: string; b: number; }) => number)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : { new (x: { a: string; b: number; }): number; }[] ->[r7arg3, r7arg2] : { new (x: { a: string; b: number; }): number; }[] +>r7e : (new (x: { a: string; b: number; }) => number)[] +>[r7arg3, r7arg2] : (new (x: { a: string; b: number; }) => number)[] >r7arg3 : new (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 473bbe9a205..21a40ecf7fc 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -240,14 +240,14 @@ var r1 = foo1(r1arg); >r1arg : new (x: T) => T[] var r1a = [r1arg, r1arg2]; ->r1a : { new (x: T): T[]; }[] ->[r1arg, r1arg2] : { new (x: T): T[]; }[] +>r1a : (new (x: T) => T[])[] +>[r1arg, r1arg2] : (new (x: T) => T[])[] >r1arg : new (x: T) => T[] >r1arg2 : new (x: T) => T[] var r1b = [r1arg2, r1arg]; ->r1b : { new (x: T): T[]; }[] ->[r1arg2, r1arg] : { new (x: T): T[]; }[] +>r1b : (new (x: T) => T[])[] +>[r1arg2, r1arg] : (new (x: T) => T[])[] >r1arg2 : new (x: T) => T[] >r1arg : new (x: T) => T[] @@ -270,14 +270,14 @@ var r2 = foo2(r2arg); >r2arg : new (x: T) => string[] var r2a = [r2arg, r2arg2]; ->r2a : { new (x: T): string[]; }[] ->[r2arg, r2arg2] : { new (x: T): string[]; }[] +>r2a : (new (x: T) => string[])[] +>[r2arg, r2arg2] : (new (x: T) => string[])[] >r2arg : new (x: T) => string[] >r2arg2 : new (x: T) => string[] var r2b = [r2arg2, r2arg]; ->r2b : { new (x: T): string[]; }[] ->[r2arg2, r2arg] : { new (x: T): string[]; }[] +>r2b : (new (x: T) => string[])[] +>[r2arg2, r2arg] : (new (x: T) => string[])[] >r2arg2 : new (x: T) => string[] >r2arg : new (x: T) => string[] @@ -301,14 +301,14 @@ var r3 = foo3(r3arg); >r3arg : new (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : { new (x: T): T; }[] ->[r3arg, r3arg2] : { new (x: T): T; }[] +>r3a : (new (x: T) => T)[] +>[r3arg, r3arg2] : (new (x: T) => T)[] >r3arg : new (x: T) => T >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : { new (x: T): T; }[] ->[r3arg2, r3arg] : { new (x: T): T; }[] +>r3b : (new (x: T) => T)[] +>[r3arg2, r3arg] : (new (x: T) => T)[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -337,14 +337,14 @@ var r4 = foo4(r4arg); >r4arg : new (x: T, y: U) => string var r4a = [r4arg, r4arg2]; ->r4a : { new (x: T, y: U): string; }[] ->[r4arg, r4arg2] : { new (x: T, y: U): string; }[] +>r4a : (new (x: T, y: U) => string)[] +>[r4arg, r4arg2] : (new (x: T, y: U) => string)[] >r4arg : new (x: T, y: U) => string >r4arg2 : new (x: T, y: U) => string var r4b = [r4arg2, r4arg]; ->r4b : { new (x: T, y: U): string; }[] ->[r4arg2, r4arg] : { new (x: T, y: U): string; }[] +>r4b : (new (x: T, y: U) => string)[] +>[r4arg2, r4arg] : (new (x: T, y: U) => string)[] >r4arg2 : new (x: T, y: U) => string >r4arg : new (x: T, y: U) => string @@ -375,14 +375,14 @@ var r5 = foo5(r5arg); >r5arg : new (x: new (arg: T) => U) => T var r5a = [r5arg, r5arg2]; ->r5a : { new (x: new (arg: T) => U): T; }[] ->[r5arg, r5arg2] : { new (x: new (arg: T) => U): T; }[] +>r5a : (new (x: new (arg: T) => U) => T)[] +>[r5arg, r5arg2] : (new (x: new (arg: T) => U) => T)[] >r5arg : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: T) => U) => T var r5b = [r5arg2, r5arg]; ->r5b : { new (x: new (arg: T) => U): T; }[] ->[r5arg2, r5arg] : { new (x: new (arg: T) => U): T; }[] +>r5b : (new (x: new (arg: T) => U) => T)[] +>[r5arg2, r5arg] : (new (x: new (arg: T) => U) => T)[] >r5arg2 : new (x: new (arg: T) => U) => T >r5arg : new (x: new (arg: T) => U) => T @@ -415,14 +415,14 @@ var r6 = foo6(r6arg); >r6arg : new (x: new (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : { new (x: new (arg: T) => U): T; }[] ->[r6arg, r6arg2] : { new (x: new (arg: T) => U): T; }[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : { new (x: new (arg: T) => U): T; }[] ->[r6arg2, r6arg] : { new (x: new (arg: T) => U): T; }[] +>r6b : (new (x: new (arg: T) => U) => T)[] +>[r6arg2, r6arg] : (new (x: new (arg: T) => U) => T)[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -460,14 +460,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : { new (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] ->[r11arg, r11arg2] : { new (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] +>r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : { new (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] ->[r11arg2, r11arg] : { new (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] +>r11b : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -499,14 +499,14 @@ var r15 = foo15(r15arg); >r15arg : new (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : { new (x: { a: U; b: V; }): U[]; }[] ->[r15arg, r15arg2] : { new (x: { a: U; b: V; }): U[]; }[] +>r15a : (new (x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : (new (x: { a: U; b: V; }) => U[])[] >r15arg : new (x: { a: U; b: V; }) => U[] >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : { new (x: { a: U; b: V; }): U[]; }[] ->[r15arg2, r15arg] : { new (x: { a: U; b: V; }): U[]; }[] +>r15b : (new (x: { a: U; b: V; }) => U[])[] +>[r15arg2, r15arg] : (new (x: { a: U; b: V; }) => U[])[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] @@ -539,14 +539,14 @@ var r16 = foo16(r16arg); >r16arg : new (x: { a: T; b: T; }) => T[] var r16a = [r16arg, r16arg2]; ->r16a : { new (x: { a: T; b: T; }): T[]; }[] ->[r16arg, r16arg2] : { new (x: { a: T; b: T; }): T[]; }[] +>r16a : (new (x: { a: T; b: T; }) => T[])[] +>[r16arg, r16arg2] : (new (x: { a: T; b: T; }) => T[])[] >r16arg : new (x: { a: T; b: T; }) => T[] >r16arg2 : new (x: { a: T; b: T; }) => T[] var r16b = [r16arg2, r16arg]; ->r16b : { new (x: { a: T; b: T; }): T[]; }[] ->[r16arg2, r16arg] : { new (x: { a: T; b: T; }): T[]; }[] +>r16b : (new (x: { a: T; b: T; }) => T[])[] +>[r16arg2, r16arg] : (new (x: { a: T; b: T; }) => T[])[] >r16arg2 : new (x: { a: T; b: T; }) => T[] >r16arg : new (x: { a: T; b: T; }) => T[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types index f4bd9f447a8..055863e0bfa 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types @@ -69,8 +69,8 @@ var b: { Foo2: Derived; } >Derived : Derived var r = true ? a : b; // ok ->r : { Foo?: Base; } ->true ? a : b : { Foo?: Base; } +>r : { Foo?: Base; } | { Foo2: Derived; } +>true ? a : b : { Foo?: Base; } | { Foo2: Derived; } >a : { Foo?: Base; } >b : { Foo2: Derived; } diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types index 7ad4580090c..96204004b64 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types @@ -69,8 +69,8 @@ var b: { Foo2?: Derived; } >Derived : Derived var r = true ? a : b; // ok ->r : { Foo2?: Derived; } ->true ? a : b : { Foo2?: Derived; } +>r : { Foo: Base; } | { Foo2?: Derived; } +>true ? a : b : { Foo: Base; } | { Foo2?: Derived; } >a : { Foo: Base; } >b : { Foo2?: Derived; } diff --git a/tests/baselines/reference/targetTypeTest2.types b/tests/baselines/reference/targetTypeTest2.types index f40d68d075a..0000e65b8a7 100644 --- a/tests/baselines/reference/targetTypeTest2.types +++ b/tests/baselines/reference/targetTypeTest2.types @@ -4,7 +4,7 @@ var a : any[] = [1,2,"3"]; >a : any[] ->[1,2,"3"] : Array +>[1,2,"3"] : (string | number)[] function func1(stuff:any[]) { return stuff; } @@ -21,7 +21,7 @@ function func2(stuff1:string, stuff2:number, stuff3:number) { return func1([stuff1, stuff2, stuff3]); >func1([stuff1, stuff2, stuff3]) : any[] >func1 : (stuff: any[]) => any[] ->[stuff1, stuff2, stuff3] : Array +>[stuff1, stuff2, stuff3] : (string | number)[] >stuff1 : string >stuff2 : number >stuff3 : number diff --git a/tests/baselines/reference/targetTypeTest3.errors.txt b/tests/baselines/reference/targetTypeTest3.errors.txt index d9dbec41150..41b2d027fb5 100644 --- a/tests/baselines/reference/targetTypeTest3.errors.txt +++ b/tests/baselines/reference/targetTypeTest3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type 'Array' is not assignable to type 'string[]': +tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '(string | number)[]' is not assignable to type 'string[]': Type 'string | number' is not assignable to type 'string': Type 'number' is not assignable to type 'string'. @@ -9,7 +9,7 @@ tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type 'Array' is not assignable to type 'string[]': +!!! error TS2322: Type '(string | number)[]' is not assignable to type 'string[]': !!! error TS2322: Type 'string | number' is not assignable to type 'string': !!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.types b/tests/baselines/reference/thisInPropertyBoundDeclarations.types index 899aa41a684..196cf4e2ddc 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.types +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.types @@ -8,7 +8,7 @@ class Bug { private static func: Function[] = [ >func : Function[] >Function : Function ->[ (that: Bug, name: string) => { that.foo(name); } ] : { (that: Bug, name: string): void; }[] +>[ (that: Bug, name: string) => { that.foo(name); } ] : ((that: Bug, name: string) => void)[] (that: Bug, name: string) => { >(that: Bug, name: string) => { that.foo(name); } : (that: Bug, name: string) => void diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types index 7f106daced9..eeef863f6eb 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -219,7 +219,7 @@ throw []; >[] : undefined[] throw ['a', ['b']]; ->['a', ['b']] : Array +>['a', ['b']] : (string | string[])[] >['b'] : string[] throw /[a-z]/; diff --git a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt index 823bf93e535..9b068b62e68 100644 --- a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt +++ b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. Type 'string | number' is not assignable to type 'number': Type 'string' is not assignable to type 'number'. -tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. Type 'string | number' is not assignable to type 'number': Type 'string' is not assignable to type 'number'. @@ -13,12 +13,12 @@ tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS // these two should give the same error this.test([1, 2, "hi", 5, ]); ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. !!! error TS2345: Type 'string | number' is not assignable to type 'number': !!! error TS2345: Type 'string' is not assignable to type 'number'. this.test([1, 2, "hi", 5]); ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'Array' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. !!! error TS2345: Type 'string | number' is not assignable to type 'number': !!! error TS2345: Type 'string' is not assignable to type 'number'. } diff --git a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types index 1cee9140a01..27fcd05bb28 100644 --- a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types +++ b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types @@ -23,7 +23,7 @@ interface IMenuItem { var menuData: IMenuItem[] = [ >menuData : IMenuItem[] >IMenuItem : IMenuItem ->[ { "id": "ourLogo", "type": "image", "link": "", "icon": "modules/menu/logo.svg" }, { "id": "productName", "type": "default", "link": "", "text": "Product Name" }] : Array<{ "id": string; "type": string; "link": string; "icon": string; } | { "id": string; "type": string; "link": string; "text": string; }> +>[ { "id": "ourLogo", "type": "image", "link": "", "icon": "modules/menu/logo.svg" }, { "id": "productName", "type": "default", "link": "", "text": "Product Name" }] : ({ "id": string; "type": string; "link": string; "icon": string; } | { "id": string; "type": string; "link": string; "text": string; })[] { >{ "id": "ourLogo", "type": "image", "link": "", "icon": "modules/menu/logo.svg" } : { "id": string; "type": string; "link": string; "icon": string; } diff --git a/tests/baselines/reference/typeParameterAsElementType.types b/tests/baselines/reference/typeParameterAsElementType.types index 828c7034a58..5cbad56c5f1 100644 --- a/tests/baselines/reference/typeParameterAsElementType.types +++ b/tests/baselines/reference/typeParameterAsElementType.types @@ -8,7 +8,7 @@ function fee() { >T : T var arr = [t, ""]; ->arr : Array ->[t, ""] : Array +>arr : (string | T)[] +>[t, ""] : (string | T)[] >t : T } diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 5337a4971d1..752c39b5e51 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -176,7 +176,7 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[true, 1, null, 'yes'] : Array +>[true, 1, null, 'yes'] : (string | number | boolean)[] >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T @@ -186,7 +186,7 @@ _.any([null, 0, 'yes', false]); >_.any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[null, 0, 'yes', false] : Array +>[null, 0, 'yes', false] : (string | number | boolean)[] _.contains([1, 2, 3], 3); >_.contains([1, 2, 3], 3) : boolean @@ -364,11 +364,11 @@ _.rest([5, 4, 3, 2, 1]); >[5, 4, 3, 2, 1] : number[] _.compact([0, 1, false, 2, '', 3]); ->_.compact([0, 1, false, 2, '', 3]) : Array +>_.compact([0, 1, false, 2, '', 3]) : (string | number | boolean)[] >_.compact : (list: T[]) => T[] >_ : Underscore.Static >compact : (list: T[]) => T[] ->[0, 1, false, 2, '', 3] : Array +>[0, 1, false, 2, '', 3] : (string | number | boolean)[] _.flatten([1, 2, 3, 4]); >_.flatten([1, 2, 3, 4]) : {}[] @@ -382,7 +382,7 @@ _.flatten([1, [2]]); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2]] : Array +>[1, [2]] : (number | number[])[] >[2] : number[] // typescript doesn't like the elements being different @@ -391,9 +391,9 @@ _.flatten([1, [2], [3, [[4]]]]); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : Array> +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >[2] : number[] ->[3, [[4]]] : Array +>[3, [[4]]] : (number | number[][])[] >[[4]] : number[][] >[4] : number[] @@ -402,9 +402,9 @@ _.flatten([1, [2], [3, [[4]]]], true); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : Array> +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >[2] : number[] ->[3, [[4]]] : Array +>[3, [[4]]] : (number | number[][])[] >[[4]] : number[][] >[4] : number[] @@ -470,10 +470,10 @@ _.object([['moe', 30], ['larry', 40], ['curly', 50]]); >_.object : { (list: any[][]): any; (keys: string[], values: any[]): any; } >_ : Underscore.Static >object : { (list: any[][]): any; (keys: string[], values: any[]): any; } ->[['moe', 30], ['larry', 40], ['curly', 50]] : Array[] ->['moe', 30] : Array ->['larry', 40] : Array ->['curly', 50] : Array +>[['moe', 30], ['larry', 40], ['curly', 50]] : (string | number)[][] +>['moe', 30] : (string | number)[] +>['larry', 40] : (string | number)[] +>['curly', 50] : (string | number)[] _.indexOf([1, 2, 3], 2); >_.indexOf([1, 2, 3], 2) : number diff --git a/tests/baselines/reference/varArgParamTypeCheck.types b/tests/baselines/reference/varArgParamTypeCheck.types index 1b5b20adbec..9cd2fad7aca 100644 --- a/tests/baselines/reference/varArgParamTypeCheck.types +++ b/tests/baselines/reference/varArgParamTypeCheck.types @@ -1,7 +1,7 @@ === tests/cases/compiler/varArgParamTypeCheck.ts === function sequence(...sequences:{():void;}[]) { ->sequence : (...sequences: { (): void; }[]) => void ->sequences : { (): void; }[] +>sequence : (...sequences: (() => void)[]) => void +>sequences : (() => void)[] } function callback(clb:()=>void) { @@ -11,7 +11,7 @@ function callback(clb:()=>void) { sequence( >sequence( function bar() { }, function foo() { callback(()=>{ this(); }); }, function baz() { callback(()=>{ this(); }); }) : void ->sequence : (...sequences: { (): void; }[]) => void +>sequence : (...sequences: (() => void)[]) => void function bar() { >function bar() { } : () => void diff --git a/tests/baselines/reference/varArgsOnConstructorTypes.types b/tests/baselines/reference/varArgsOnConstructorTypes.types index 17993a32fda..5ac9babd426 100644 --- a/tests/baselines/reference/varArgsOnConstructorTypes.types +++ b/tests/baselines/reference/varArgsOnConstructorTypes.types @@ -45,14 +45,14 @@ export interface I1 { >I1 : I1 register(inputClass: new(...params: any[]) => A); ->register : { (inputClass: new (...params: any[]) => A): any; (inputClass: { new (...params: any[]): A; }[]): any; } +>register : { (inputClass: new (...params: any[]) => A): any; (inputClass: (new (...params: any[]) => A)[]): any; } >inputClass : new (...params: any[]) => A >params : any[] >A : A register(inputClass: { new (...params: any[]): A; }[]); ->register : { (inputClass: new (...params: any[]) => A): any; (inputClass: { new (...params: any[]): A; }[]): any; } ->inputClass : { new (...params: any[]): A; }[] +>register : { (inputClass: new (...params: any[]) => A): any; (inputClass: (new (...params: any[]) => A)[]): any; } +>inputClass : (new (...params: any[]) => A)[] >params : any[] >A : A } @@ -64,8 +64,8 @@ var reg: I1; reg.register(B); >reg.register(B) : any ->reg.register : { (inputClass: new (...params: any[]) => A): any; (inputClass: { new (...params: any[]): A; }[]): any; } +>reg.register : { (inputClass: new (...params: any[]) => A): any; (inputClass: (new (...params: any[]) => A)[]): any; } >reg : I1 ->register : { (inputClass: new (...params: any[]) => A): any; (inputClass: { new (...params: any[]): A; }[]): any; } +>register : { (inputClass: new (...params: any[]) => A): any; (inputClass: (new (...params: any[]) => A)[]): any; } >B : typeof B diff --git a/tests/baselines/reference/vardecl.js b/tests/baselines/reference/vardecl.js index 326a639ca91..5ce8e095020 100644 --- a/tests/baselines/reference/vardecl.js +++ b/tests/baselines/reference/vardecl.js @@ -213,9 +213,7 @@ declare var d2: { }; }; declare var n2: () => void; -declare var n4: { - (): void; -}[]; +declare var n4: (() => void)[]; declare var d4: { foo(n: string, x: { x: number; diff --git a/tests/baselines/reference/vardecl.types b/tests/baselines/reference/vardecl.types index f757562c103..25257e57d78 100644 --- a/tests/baselines/reference/vardecl.types +++ b/tests/baselines/reference/vardecl.types @@ -107,7 +107,7 @@ var n2: { (): void; } var n4: { ->n4 : { (): void; }[] +>n4 : (() => void)[] (): void; }[]; diff --git a/tests/cases/compiler/propertiesAndIndexers2.ts b/tests/cases/compiler/propertiesAndIndexers2.ts new file mode 100644 index 00000000000..188635bf1dd --- /dev/null +++ b/tests/cases/compiler/propertiesAndIndexers2.ts @@ -0,0 +1,15 @@ +interface A { + [n: number]: string; + [s: string]: number; +} + +// All of these should fail. +interface B extends A { + c: string; + 3: string; + Infinity: string; + "-Infinity": string; + NaN: string; + "-NaN": string; + 6(): string; +} diff --git a/tests/cases/compiler/propertiesAndIndexersForNumericNames.ts b/tests/cases/compiler/propertiesAndIndexersForNumericNames.ts new file mode 100644 index 00000000000..3a6f4afd52b --- /dev/null +++ b/tests/cases/compiler/propertiesAndIndexersForNumericNames.ts @@ -0,0 +1,41 @@ +class C { + [i: number]: number; + + // These all have numeric names; they should error + // because their types are not compatible with the numeric indexer. + public "1": string = "number"; // Error + public "-1": string = "negative number"; // Error + public "-2.5": string = "negative number"; // Error + public "3.141592": string = "pi-sitive number"; // Error + public "1.2e-20": string = "really small number"; // Error + public "Infinity": string = "A gillion"; // Error + public "-Infinity": string = "Negative-a-gillion"; // Error + public "NaN": string = "not a number"; // Error + + // These all have *partially* numeric names, + // but should really be treated as plain string literals. + public " 1": string = "leading space"; // No error + public "1 ": string = "trailing space"; // No error + public "": string = "no nothing"; // No error + public " ": string = "just space"; // No error + public "1 0 1": string = "several numbers and spaces"; // No error + public "hunter2": string = "not a password"; // No error + public "+Infinity": string = "A gillion"; // No error + public "+NaN": string = "not a positive number"; // No error + public "-NaN": string = "not a negative number"; // No error + + + // These fall into the above category, however, they are "trickier"; + // these all are *scanned* as numeric literals, but they are not written in + // "canonical" numeric representations. + public "+1": string = "positive number (for the paranoid)"; // No error + public "1e0": string = "just one"; // No error + public "-0": string = "just zero"; // No error + public "-0e0": string = "just zero"; // No error + public "0xF00D": string = "hex food"; // No error + public "0xBEEF": string = "hex beef"; // No error + public "0123": string = "oct 83"; // No error + public "0o123": string = "explicit oct 83"; // No error + public "0b101101001010": string = "explicit binary"; // No error + public "0.000000000000000000012": string = "should've been in exponential form"; // No error +} diff --git a/tests/cases/conformance/types/specifyingTypes/typeLiterals/parenthesizedTypes.ts b/tests/cases/conformance/types/specifyingTypes/typeLiterals/parenthesizedTypes.ts new file mode 100644 index 00000000000..92959698885 --- /dev/null +++ b/tests/cases/conformance/types/specifyingTypes/typeLiterals/parenthesizedTypes.ts @@ -0,0 +1,27 @@ +var a: string; +var a: (string); +var a: ((string) | string | (((string)))); +var a: ((((((((((((((((((((((((((((((((((((((((string)))))))))))))))))))))))))))))))))))))))); + +var b: (x: string) => string; +var b: ((x: (string)) => (string)); + +var c: string[] | number[]; +var c: (string)[] | (number)[]; +var c: ((string)[]) | ((number)[]); + +var d: (((x: string) => string) | ((x: number) => number))[]; +var d: ({ (x: string): string } | { (x: number): number })[]; +var d: Array<((x: string) => string) | ((x: number) => number)>; +var d: Array<{ (x: string): string } | { (x: number): number }>; +var d: (Array<{ (x: string): string } | { (x: number): number }>); + +var e: typeof a[]; +var e: (typeof a)[]; + +var f: (string) => string; +var f: (string: any) => string; + +var g: [string, string]; +var g: [(string), string]; +var g: [(string), (((typeof a)))]; diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts b/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts new file mode 100644 index 00000000000..393d0e10d37 --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts @@ -0,0 +1,28 @@ +// TypeScript Spec, section 4.12.2: +// If e is an expression of a function type that contains exactly one generic call signature and no other members, +// and T is a function type with exactly one non - generic call signature and no other members, then any inferences +// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed +// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). + +declare function foo(cb: (x: number, y: string) => T): T; +declare function bar(x: T, y: U, cb: (x: T, y: U) => V): V; +declare function baz(x: T, y: T, cb: (x: T, y: T) => U): U; + +declare function g(x: T, y: T): T; +declare function h(x: T, y: U): T[] | U[]; + +var a: number; +var a = bar(1, 1, g); // Should be number +var a = baz(1, 1, g); // Should be number + +var b: number | string; +var b = foo(g); // Should be number | string +var b = bar(1, "one", g); // Should be number | string +var b = bar("one", 1, g); // Should be number | string +var b = baz(b, b, g); // Should be number | string + +var d: number[] | string[]; +var d = foo(h); // Should be number[] | string[] +var d = bar(1, "one", h); // Should be number[] | string[] +var d = bar("one", 1, h); // Should be number[] | string[] +var d = baz(d, d, g); // Should be number[] | string[] diff --git a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts index 917ed526d69..79d3174b542 100644 --- a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts +++ b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts @@ -28,7 +28,7 @@ goTo.marker('2'); verify.quickInfoIs('(var) c1: {\n name: string;\n age: number;\n}[]'); goTo.marker('3'); -verify.quickInfoIs('(var) c2: Array<{\n\ +verify.quickInfoIs('(var) c2: ({\n\ name: string;\n\ age: number;\n\ address: string;\n\ @@ -36,7 +36,7 @@ verify.quickInfoIs('(var) c2: Array<{\n\ name: string;\n\ age: number;\n\ dob: Date;\n\ -}>'); +})[]'); goTo.marker('4'); verify.quickInfoIs('(var) c2a: {\n name: string;\n age: number;\n}[]'); diff --git a/tests/cases/fourslash/contextualTyping.ts b/tests/cases/fourslash/contextualTyping.ts index dad6ee8b587..13fb4dc2450 100644 --- a/tests/cases/fourslash/contextualTyping.ts +++ b/tests/cases/fourslash/contextualTyping.ts @@ -242,7 +242,7 @@ verify.quickInfoIs("(var) c3t9: number[][]"); goTo.marker('23'); verify.quickInfoIs("(var) c3t10: IFoo[]"); goTo.marker('24'); -verify.quickInfoIs("(var) c3t11: {\n (n: number, s: string): string;\n}[]"); +verify.quickInfoIs("(var) c3t11: ((n: number, s: string) => string)[]"); goTo.marker('25'); verify.quickInfoIs("(parameter) n: number"); goTo.marker('26'); @@ -314,7 +314,7 @@ verify.quickInfoIs("(property) t9: number[][]"); goTo.marker('59'); verify.quickInfoIs("(property) t10: IFoo[]"); goTo.marker('60'); -verify.quickInfoIs("(property) t11: {\n (n: number, s: string): string;\n}[]"); +verify.quickInfoIs("(property) t11: ((n: number, s: string) => string)[]"); goTo.marker('61'); verify.quickInfoIs("(parameter) n: number"); goTo.marker('62'); @@ -374,7 +374,7 @@ verify.quickInfoIs("(var) c12t9: number[][]"); goTo.marker('89'); verify.quickInfoIs("(var) c12t10: IFoo[]"); goTo.marker('90'); -verify.quickInfoIs("(var) c12t11: {\n (n: number, s: string): string;\n}[]"); +verify.quickInfoIs("(var) c12t11: ((n: number, s: string) => string)[]"); goTo.marker('91'); verify.quickInfoIs("(parameter) n: number"); goTo.marker('92'); diff --git a/tests/cases/fourslash/genericParameterHelp.ts b/tests/cases/fourslash/genericParameterHelp.ts index a1df1cc2f32..17882485fd7 100644 --- a/tests/cases/fourslash/genericParameterHelp.ts +++ b/tests/cases/fourslash/genericParameterHelp.ts @@ -6,26 +6,12 @@ //// return null; ////} //// -////class testClass { -//// constructor(a:T, b:U, c:M){ } -////} ////// Function calls ////testFunction(/*3*/ ////testFunction(null, null, null); ////testFunction<, ,/*5*/>(null, null, null); -////// Constructor calls -////new testClass(null, null, null) -////new testClass<,,/*construcor4*/>(null, null, null) -////new testClass(null, null, null) -////// Generic types -////testClass extends testClass; // goTo.marker("1"); // verify.currentSignatureParamterCountIs(3); @@ -38,56 +24,14 @@ // verify.currentParameterHelpArgumentNameIs("U"); // verify.currentParameterSpanIs("U"); - goTo.marker("3"); - verify.currentParameterHelpArgumentNameIs("a"); - verify.currentParameterSpanIs("a: T"); +goTo.marker("3"); +verify.currentParameterHelpArgumentNameIs("a"); +verify.currentParameterSpanIs("a: T"); - // goTo.marker("4"); - // verify.currentParameterHelpArgumentNameIs("M"); - // verify.currentParameterSpanIs("M extends IFoo"); +goTo.marker("4"); +verify.currentParameterHelpArgumentNameIs("M"); +verify.currentParameterSpanIs("M extends IFoo"); - // goTo.marker("5"); - // verify.currentParameterHelpArgumentNameIs("M"); - // verify.currentParameterSpanIs("M extends IFoo"); - - // goTo.marker("construcor1"); - // verify.currentSignatureHelpIs("testClass(a: T, b: U, c: M): testClass"); - // verify.currentParameterHelpArgumentNameIs("T"); - // verify.currentParameterSpanIs("T extends IFoo"); - - // goTo.marker("construcor2"); - // verify.currentParameterHelpArgumentNameIs("U"); - // verify.currentParameterSpanIs("U"); - - //goTo.marker("construcor3"); - //verify.currentParameterHelpArgumentNameIs("T"); - //verify.currentParameterSpanIs("T extends IFoo"); - - // goTo.marker("construcor4"); - // verify.currentParameterHelpArgumentNameIs("M"); - // verify.currentParameterSpanIs("M extends IFoo"); - - // goTo.marker("construcor5"); - // verify.currentParameterHelpArgumentNameIs("U"); - // verify.currentParameterSpanIs("U"); - - // goTo.marker("type1"); - // verify.signatureHelpCountIs(1); - // verify.currentSignatureHelpIs("testClass"); - // verify.currentParameterHelpArgumentNameIs("T"); - // verify.currentParameterSpanIs("T extends IFoo"); - - // goTo.marker("type2"); - // verify.signatureHelpCountIs(1); - // verify.currentParameterHelpArgumentNameIs("T"); - // verify.currentParameterSpanIs("T extends IFoo"); - - // goTo.marker("type3"); - // verify.signatureHelpCountIs(1); - // verify.currentParameterHelpArgumentNameIs("T"); - // verify.currentParameterSpanIs("T extends IFoo"); - - // goTo.marker("type4"); - // verify.signatureHelpCountIs(1); - // verify.currentParameterHelpArgumentNameIs("M"); - // verify.currentParameterSpanIs("M extends IFoo"); \ No newline at end of file +goTo.marker("5"); +verify.currentParameterHelpArgumentNameIs("M"); +verify.currentParameterSpanIs("M extends IFoo"); \ No newline at end of file diff --git a/tests/cases/fourslash/genericParameterHelpConstructorCalls.ts b/tests/cases/fourslash/genericParameterHelpConstructorCalls.ts new file mode 100644 index 00000000000..4cbe141fcce --- /dev/null +++ b/tests/cases/fourslash/genericParameterHelpConstructorCalls.ts @@ -0,0 +1,35 @@ +/// + +////interface IFoo { } +//// +////class testClass { +//// constructor(a:T, b:U, c:M){ } +////} +//// +////// Constructor calls +////new testClass(null, null, null) +////new testClass<,,/*construcor4*/>(null, null, null) +////new testClass(null, null, null) + + // goTo.marker("construcor1"); + // verify.currentSignatureHelpIs("testClass(a: T, b: U, c: M): testClass"); + // verify.currentParameterHelpArgumentNameIs("T"); + // verify.currentParameterSpanIs("T extends IFoo"); + + // goTo.marker("construcor2"); + // verify.currentParameterHelpArgumentNameIs("U"); + // verify.currentParameterSpanIs("U"); + +goTo.marker("construcor3"); +verify.currentParameterHelpArgumentNameIs("T"); +verify.currentParameterSpanIs("T extends IFoo"); + +goTo.marker("construcor4"); +verify.currentParameterHelpArgumentNameIs("M"); +verify.currentParameterSpanIs("M extends IFoo"); + +goTo.marker("construcor5"); +verify.currentParameterHelpArgumentNameIs("U"); +verify.currentParameterSpanIs("U"); diff --git a/tests/cases/fourslash/genericParameterHelpTypeReferences.ts b/tests/cases/fourslash/genericParameterHelpTypeReferences.ts new file mode 100644 index 00000000000..346cf7191c1 --- /dev/null +++ b/tests/cases/fourslash/genericParameterHelpTypeReferences.ts @@ -0,0 +1,34 @@ +/// + +////interface IFoo { } +//// +////class testClass { +//// constructor(a:T, b:U, c:M){ } +////} +//// +////// Generic types +////testClass extends testClass; + + // goTo.marker("type1"); + // verify.signatureHelpCountIs(1); + // verify.currentSignatureHelpIs("testClass"); + // verify.currentParameterHelpArgumentNameIs("T"); + // verify.currentParameterSpanIs("T extends IFoo"); + + // goTo.marker("type2"); + // verify.signatureHelpCountIs(1); + // verify.currentParameterHelpArgumentNameIs("T"); + // verify.currentParameterSpanIs("T extends IFoo"); + + // goTo.marker("type3"); + // verify.signatureHelpCountIs(1); + // verify.currentParameterHelpArgumentNameIs("T"); + // verify.currentParameterSpanIs("T extends IFoo"); + + // goTo.marker("type4"); + // verify.signatureHelpCountIs(1); + // verify.currentParameterHelpArgumentNameIs("M"); + // verify.currentParameterSpanIs("M extends IFoo"); \ No newline at end of file diff --git a/tests/cases/fourslash/genericTypeArgumentInference1.ts b/tests/cases/fourslash/genericTypeArgumentInference1.ts index eadec7ad0ce..5c30363d35c 100644 --- a/tests/cases/fourslash/genericTypeArgumentInference1.ts +++ b/tests/cases/fourslash/genericTypeArgumentInference1.ts @@ -20,7 +20,7 @@ goTo.marker('1'); verify.quickInfoIs('(var) r: string | number | boolean'); goTo.marker('11'); -verify.quickInfoIs('(method) Underscore.Static.all(list: Array, iterator?: Underscore.Iterator, context?: any): string | number | boolean'); +verify.quickInfoIs('(method) Underscore.Static.all(list: (string | number | boolean)[], iterator?: Underscore.Iterator, context?: any): string | number | boolean'); goTo.marker('2'); verify.quickInfoIs('(var) r2: boolean'); diff --git a/tests/cases/fourslash/genericTypeArgumentInference2.ts b/tests/cases/fourslash/genericTypeArgumentInference2.ts index a660675c51e..bb59cc8eed6 100644 --- a/tests/cases/fourslash/genericTypeArgumentInference2.ts +++ b/tests/cases/fourslash/genericTypeArgumentInference2.ts @@ -20,7 +20,7 @@ goTo.marker('1'); verify.quickInfoIs('(var) r: string | number | boolean'); goTo.marker('11'); -verify.quickInfoIs('(method) Underscore.Static.all(list: Array, iterator?: Underscore.Iterator, context?: any): string | number | boolean'); +verify.quickInfoIs('(method) Underscore.Static.all(list: (string | number | boolean)[], iterator?: Underscore.Iterator, context?: any): string | number | boolean'); goTo.marker('2'); verify.quickInfoIs('(var) r2: boolean'); diff --git a/tests/cases/fourslash/signatureHelpOnNestedOverloads.ts b/tests/cases/fourslash/signatureHelpOnNestedOverloads.ts index 476d79a8243..e657000c113 100644 --- a/tests/cases/fourslash/signatureHelpOnNestedOverloads.ts +++ b/tests/cases/fourslash/signatureHelpOnNestedOverloads.ts @@ -15,6 +15,6 @@ verify.currentParameterSpanIs("x: string"); edit.insert("'',"); verify.signatureHelpCountIs(2); -// verify.currentSignatureHelpIs("fn2(x: string, y: number): any"); -// verify.currentParameterHelpArgumentNameIs("y"); -// verify.currentParameterSpanIs("y: number"); +verify.currentSignatureHelpIs("fn2(x: string, y: number): any"); +verify.currentParameterHelpArgumentNameIs("y"); +verify.currentParameterSpanIs("y: number");