diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6ab80a408d..dfaba0c06ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ Design changes will not be accepted at this time. If you have a design change pr ## Legal You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. -Please submit a Contributor License Agreement (CLA) before submitting a pull request. Download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190)), sign, scan, and email it back to . Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features. +Please submit a Contributor License Agreement (CLA) before submitting a pull request. Download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to . Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features. ## Housekeeping Your pull request should: diff --git a/doc/TypeScript Language Specification (Change Markup).docx b/doc/TypeScript Language Specification (Change Markup).docx index 5bc24af5ec8..aa9f495d04e 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 52998e9ec79..6292c8f091a 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 381ac186a4b..18ce8396a5b 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 049f7e06fb3..4d483ed4e55 100644 Binary files a/doc/TypeScript Language Specification.pdf and b/doc/TypeScript Language Specification.pdf differ diff --git a/doc/spec.md b/doc/spec.md index 5635c100a40..0a802bd8685 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -1,8 +1,8 @@ # TypeScript Language Specification -Version 1.3 +Version 1.4 -September, 2014 +October, 2014
@@ -45,9 +45,10 @@ TypeScript is a trademark of Microsoft Corporation. * [3.3.1 Named Type References](#3.3.1) * [3.3.2 Array Types](#3.3.2) * [3.3.3 Tuple Types](#3.3.3) - * [3.3.4 Function Types](#3.3.4) - * [3.3.5 Constructor Types](#3.3.5) - * [3.3.6 Members](#3.3.6) + * [3.3.4 Union Types](#3.3.4) + * [3.3.5 Function Types](#3.3.5) + * [3.3.6 Constructor Types](#3.3.6) + * [3.3.7 Members](#3.3.7) * [3.4 Type Parameters](#3.4) * [3.4.1 Type Parameter Lists](#3.4.1) * [3.4.2 Type Argument Lists](#3.4.2) @@ -59,9 +60,10 @@ TypeScript is a trademark of Microsoft Corporation. * [3.6.3 Object Type Literals](#3.6.3) * [3.6.4 Array Type Literals](#3.6.4) * [3.6.5 Tuple Type Literals](#3.6.5) - * [3.6.6 Function Type Literals](#3.6.6) - * [3.6.7 Constructor Type Literals](#3.6.7) - * [3.6.8 Type Queries](#3.6.8) + * [3.6.6 Union Type Literals](#3.6.6) + * [3.6.7 Function Type Literals](#3.6.7) + * [3.6.8 Constructor Type Literals](#3.6.8) + * [3.6.9 Type Queries](#3.6.9) * [3.7 Specifying Members](#3.7) * [3.7.1 Property Signatures](#3.7.1) * [3.7.2 Call Signatures](#3.7.2) @@ -77,7 +79,6 @@ TypeScript is a trademark of Microsoft Corporation. * [3.8.6 Type Inference](#3.8.6) * [3.8.7 Recursive Types](#3.8.7) * [3.9 Widened Types](#3.9) - * [3.10 Best Common Type](#3.10) * [4 Expressions](#4) * [4.1 Values and References](#4.1) * [4.2 The this Keyword](#4.2) @@ -119,6 +120,7 @@ TypeScript is a trademark of Microsoft Corporation. * [4.17 Assignment Operators](#4.17) * [4.18 The Comma Operator](#4.18) * [4.19 Contextually Typed Expressions](#4.19) + * [4.20 Type Guards](#4.20) * [5 Statements](#5) * [5.1 Variable Statements](#5.1) * [5.2 If, Do, and While Statements](#5.2) @@ -1049,13 +1051,14 @@ All string literal types are subtypes of the String primitive type. Object types are composed from properties, call signatures, construct signatures, and index signatures, collectively called members. -Class and interface type references, array types, tuple types, function types, and constructor types are all classified as object types. Multiple constructs in the TypeScript language create object types, including: +Class and interface type references, array types, tuple types, union types, function types, and constructor types are all classified as object types. Multiple constructs in the TypeScript language create object types, including: * Object type literals (section [3.6.3](#3.6.3)). * Array type literals (section [3.6.4](#3.6.4)). * Tuple type literals (section [3.6.5](#3.6.5)). -* Function type literals (section [3.6.6](#3.6.6)). -* Constructor type literals (section [3.6.7](#3.6.7)). +* Union type literals (section [3.6.6](#3.6.6)). +* Function type literals (section [3.6.7](#3.6.7)). +* Constructor type literals (section [3.6.8](#3.6.8)). * Object literals (section [4.5](#4.5)). * Array literals (section [4.6](#4.6)). * Function expressions (section [4.9](#4.9)) and function declarations ([6.1](#6.1)). @@ -1105,23 +1108,111 @@ combines the set of properties } ``` -with the members of an array type whose element type is the best common type (section [3.10](#3.10)) of the tuple element types. +with the members of an array type whose element type is the union type (section [3.3.4](#3.3.4)) of the tuple element types. -Array literals (section [4.6](#4.6)) may be used to create values of tuple types. For example +Array literals (section [4.6](#4.6)) may be used to create values of tuple types. + +An example: ```TypeScript -var t: [number, string] = [1, "one"]; +var t: [number, string] = [3, "three"]; +var n = t[0]; // Type of n is number +var s = t[1]; // Type of s is string +var i: number; +var x = t[i]; // Type of x is number | string ``` -### 3.3.4 Function Types +### 3.3.4 Union Types -An object type containing one or more call signatures is said to be a ***function type***. Function types may be written using function type literals (section [3.6.6](#3.6.6)) or by including call signatures in object type literals. +***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)). -### 3.3.5 Constructor 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: -An object type containing one or more construct signatures is said to be a ***constructor type***. Constructor types may be written using constructor type literals (section [3.6.7](#3.6.7)) or by including construct signatures in object type literals. +* *A* | *B* is equivalent to *A* if *B* is a subtype of *A*. +* *A* | *B* is equivalent to *B* | *A*. +* *AB* | *C* is equivalent to *A* | *BC*, where *AB* is *A* | *B* and *BC* is *B* | *C*. -### 3.3.6 Members +Union types are reduced to the smallest possible set of constituent types using these rules. + +Union types have the following subtype relationships: + +* A union type *U* is a subtype of a type *T* if each type in *U* is a subtype of *T*. +* A type *T* is a subtype of a union type *U* if *T* is a subtype of any type in *U*. + +Similarly, union types have the following assignability relationships: + +* A union type *U* is assignable to a type *T* if each type in *U* is assignable to *T*. +* A type *T* is assignable to a union type *U* if *T* is assignable to any type in *U*. + +For purposes of property access (section [4.10](#4.10)) and function calls ([4.12](#4.12)), a union type *U* has those members that are present in every one of its constituent types, with types that are unions of the respective members in the constituent types. Specifically: + +* If each type in *U* has a property *P*, *U* has a property *P* of a union type of the types of *P* from each type in *U*. +* If each type in *U* has call signatures and the sets of call signatures 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 *U*. +* If each type in *U* has construct signatures and the sets of construct signatures 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 *U*. +* If each type in *U* has a string index signature, *U* has a string index signature of a union type of the types of the string index signatures from each type in *U*. +* If each type in *U* has a numeric index signature, *U* has a numeric index signature of a union type of the types of the numeric index signatures from each type in *U*. + +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 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*. + +The || and conditional operators (section [4.15.7](#4.15.7) and [4.16](#4.16)) may produce values of union types, and array literals (section [4.6](#4.6)) may produce array values that have union types as their element types. + +Type guards (section [4.20](#4.20)) may be used to narrow a union type to a more specific type. In particular, type guards are useful for narrowing union type values to a non-union type values. + +In the example + +```TypeScript +var x: string | number; +var test: boolean; +x = "hello"; // Ok +x = 42; // Ok +x = test; // Error, boolean not assignable +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: + +```TypeScript +var n = typeof x === "string" ? x.length : x; // Type of n is number +``` + +The following example illustrates the merging of member types that occurs when union types are created from object types. + +```TypeScript +interface A { + a: string; + b: number; +} + +interface B { + a: number; + b: number; + c: number; +} + +var x: A | B; +var a = x.a; // a has type string | number +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’. + +### 3.3.5 Function Types + +An object type containing one or more call signatures is said to be a ***function type***. Function types may be written using function type literals (section [3.6.7](#3.6.7)) or by including call signatures in object type literals. + +### 3.3.6 Constructor Types + +An object type containing one or more construct signatures is said to be a ***constructor type***. Constructor types may be written using constructor type literals (section [3.6.8](#3.6.8)) or by including construct signatures in object type literals. + +### 3.3.7 Members Every object type is composed from zero or more of the following kinds of members: @@ -1263,6 +1354,7 @@ Types are specified either by referencing their keyword or name, or by writing o    *ObjectType*    *ArrayType*    *TupleType* +   *UnionType*    *FunctionType*    *ConstructorType*    *TypeQuery* @@ -1381,7 +1473,7 @@ An array type literal is written as an element type followed by an open and clos 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 *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 +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 ```TypeScript () => string[] @@ -1415,7 +1507,34 @@ A tuple type literal is written as a sequence of element types, separated by com A tuple type literal references a tuple type (section [3.3.3](#3.3.3)). -### 3.6.6 Function Type Literals +### 3.6.6 Union Type Literals + +A union type literal is written as a sequence of types separated by vertical bars. + +  *UnionType:* +   *ElementType* `|` *UnionOrElementType* + +  *UnionOrElementType:* +   *UnionType* +   *ElementType* + +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 + +```TypeScript +() => string | () => number +``` + +denotes a function whose return value is either a string or a function returning number, whereas + +```TypeScript +{ (): string } | { (): 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. @@ -1436,7 +1555,7 @@ is exactly equivalent to the object type literal Note that function types with multiple call or construct signatures cannot be written as function type literals but must instead be written as object type literals. -### 3.6.7 Constructor Type Literals +### 3.6.8 Constructor Type Literals A constructor type literal specifies the type parameters, regular parameters, and return type of a construct signature. @@ -1457,7 +1576,7 @@ is exactly equivalent to the object type literal Note that constructor types with multiple construct signatures cannot be written as constructor type literals but must instead be written as object type literals. -### 3.6.8 Type Queries +### 3.6.9 Type Queries A type query obtains the type of an expression. @@ -1775,8 +1894,9 @@ Two types are considered ***identical*** when * they are both the Any type, * they are the same primitive type, -* they are the same type parameter, or -* they are object types with identical sets of members. +* they are the same type parameter, +* they are union types with identical sets of constituent types, or +* they are non-union object types with identical sets of members. Two members are considered identical when @@ -1816,6 +1936,8 @@ the variables * *S* is an enum type and *T* is the primitive type Number. * *S* is a string literal type and *T* is the primitive type String. * *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 * *M* and *N* have the same name, @@ -1850,6 +1972,8 @@ Types are required to be assignment compatible in certain circumstances, such as * *S* or *T* is an enum type and* *the other is the primitive type Number. * *S* is a string literal type and *T* is the primitive type String. * *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 * *M* and *N* have the same name, @@ -1890,13 +2014,18 @@ 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. -* The inferred type argument for each type parameter is the best common type (section [3.10](#3.10)) of the set of inferences made for that type parameter. However, if the best common type does not satisfy the constraint of the type parameter, the inferred type argument is instead the constraint. +* 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 In certain contexts, inferences for a given set of type parameters are made *from* a type *S*, in which those type parameters do not occur, *to* another type *T*, in which those type parameters do occur. Inferences consist of a set of candidate type arguments collected for each of the type parameters. The inference process recursively relates *S* and *T* to gather as many inferences as possible: * 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. + * 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*: * If *M* is a property and *S* contains a property *N* with the same name as *M*, inferences are made from the type of *N* to the type of *M*. * If *M* is a call signature and a corresponding call signature *N* exists in *S*, *N* is instantiated with the Any type as an argument for each type parameter (if any) and inferences are made from parameter types in *N* to the corresponding parameter types in *M* for positions that are present in both signatures, and from the return type of *N* to the return type of *M*. @@ -1954,29 +2083,12 @@ infers the type of The following example shows the results of widening types to produce inferred variable types. ```TypeScript -var a = null; // var a: any -var b = undefined; // var b: any -var c = { x: 0, y: null }; // var c: { x: number, y: any } -var d = [ null, undefined ]; // var d: any[] +var a = null; // var a: any +var b = undefined; // var b: any +var c = { x: 0, y: null }; // var c: { x: number, y: any } +var d = [ null, undefined ]; // var d: any[] ``` -## 3.10 Best Common Type - -In several situations a ***best common type*** needs to be inferred from a set of types. In particular, return types of functions with multiple return statements and element types of array literals are found this way. The determination of a best common type may in some cases factor in a contextual type. - -Given a set of types { *T1*, *T2*, …, *Tn* } and a contextual type *C*, the best common type is determined as follows: - -* If the set of types is empty, the best common type is *C*. -* Otherwise, if C is a supertype of every *Tn*, the best common type is C. -* Otherwise, if one exists, the first *Tx* that is a supertype of every *Tn* is the best common type. -* Otherwise, the best common type is an empty object type (the type `{}`). - -Given a set of types { *T1*, *T2*, …, *Tn* } and no contextual type, the best common type is determined as follows: - -* If the set of types is empty, the best common type is an empty object type. -* Otherwise, if one exists, the first *Tx* that is a supertype of every *Tn* is the best common type. -* Otherwise, the best common type is an empty object type (the type `{}`). -
#
4 Expressions @@ -2068,7 +2180,7 @@ f : function ( ... ) { ... } Each property assignment in an object literal is processed as follows: * If the object literal is contextually typed and the contextual type contains a property with a matching name, the property assignment is contextually typed by the type of that property. -* Otherwise, if the object literal is contextually typed, the contextual type contains a numeric index signature, and the property assignment specifies a numeric property name, the property assignment is contextually typed by the type of the numeric index signature. +* Otherwise, if the object literal is contextually typed, if the contextual type contains a numeric index signature, and if the property assignment specifies a numeric property name, the property assignment is contextually typed by the type of the numeric index signature. * Otherwise, if the object literal is contextually typed and the contextual type contains a string index signature, the property assignment is contextually typed by the type of the string index signature. * Otherwise, the property assignment is processed without a contextual type. @@ -2082,14 +2194,14 @@ A get accessor declaration is processed in the same manner as an ordinary functi If a get accessor is declared for a property, the return type of the get accessor becomes the type of the property. If only a set accessor is declared for a property, the parameter type (which may be type Any if no type annotation is present) of the set accessor becomes the type of the property. -When an object literal is contextually typed by a type that includes a string index signature of type *T*, the resulting type of the object literal includes a string index signature with the widened form of the best common type of the contextual type *T* and the types of the properties declared in the object literal. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature of type *T*, the resulting type of the object literal includes a numeric index signature with the widened form of the best common type of the contextual type *T* and the types of the numerically named properties (section [3.7.4](#3.7.4)) declared in the object literal. +When an object literal is contextually typed by a type that includes a string index signature, the resulting type of the object literal includes a string index signature with the union type of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature, the resulting type of the object literal includes a numeric index signature with the union type of the types of the numerically named properties (section [3.7.4](#3.7.4)) declared in the object literal, or the Undefined type if the object literal declares no numerically named properties. ## 4.6 Array Literals An array literal ```TypeScript -[expr1, expr2, ..., exprN] +[ expr1, expr2, ..., exprN ] ``` denotes a value of an array type (section [3.3.2](#3.3.2)) or a tuple type (section [3.3.3](#3.3.3)) depending on context. @@ -2100,22 +2212,17 @@ Each element expression in a non-empty array literal is processed as follows: * Otherwise, if the array literal is contextually typed by a type *T* with a numeric index signature, the element expression is contextually typed by the type of the numeric index signature. * Otherwise, the element expression is not contextually typed. -The resulting type of a non-empty array literal expression is determined as follows: +The resulting type an array literal expression is determined as follows: -* If the array literal is contextually typed by a type *T* and *T* has at least one property with a numeric name that matches the index of an element expression in the array literal, 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 T with a numeric index signature of type *S*, the resulting type is an array type where the element type is the best common type of the contextual type *S* and the types of the element expressions. -* Otherwise, if the array literal is not contextually typed, the resulting type is an array type where the element type is the best common type of the types of the element expressions. - -The resulting type of an empty array literal expression is determined as follows: - -* If the array literal is contextually typed by a type *T* with a numeric index signature of type *S*, the resulting type is an array type with element type *S*. -* Otherwise, the resulting type is an array type with the element type Undefined. +* 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, 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]; // number[] -var b = ["hello", true]; // {}[] +var a = [1, 2]; // Array +var b = ["hello", true]; // Array var c: [number, string] = [3, "three"]; // [number, string] ``` @@ -2336,7 +2443,7 @@ var s = data[0]; // string var n = data[1]; // number ``` -## 4.11 The new Operator +## 4.11 The new Operator A `new` operation has one of the following forms: @@ -2383,8 +2490,7 @@ The compile-time processing of a typed function call consists of the following s * the function call has no type arguments, and * the signature is applicable with respect to the argument list of the function call. * A generic signature is a candidate in a function call without type arguments when - * type inference (section [4.12.2](#4.12.2)) succeeds in inferring a list of type arguments, - * the inferred type arguments satisfy their constraints, and + * type inference (section [4.12.2](#4.12.2)) succeeds for each type parameter, * once the inferred type arguments are substituted for their associated type parameters, the signature is applicable with respect to the argument list of the function call. * A generic signature is a candidate in a function call with type arguments when * The signature has the same number of type parameters as were supplied in the type argument list, @@ -2404,10 +2510,11 @@ A signature is said to be an ***applicable signature*** with respect to an argum 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. -The inferred type argument for a particular type parameter is determined from a set of candidate types. Given a type parameter *T*, let *C* denote the widened form (section [3.9](#3.9)) of the best common type (section [3.10](#3.10)) of the set of candidate types *T*. Then, +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 *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: @@ -2417,27 +2524,27 @@ In order to compute candidate types, the argument list is processed as follows: The process of inferentially typing an expression *e* by a type *T* is the same as that of contextually typing *e* by *T*, with the following exceptions: * Where expressions contained within *e* would be contextually typed, they are instead inferentially typed. -* Where a contextual type would be included in a best common type determination (such as when inferentially typing an object or array literal), an inferential type is not. * 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)). -In the example +An example: ```TypeScript function choose(x: T, y: T): T { return Math.random() < 0.5 ? x : y; } -var x = choose("Five", 5); +var x = choose(10, 20); // Ok, x of type number +var y = choose("Five", 5); // Error ``` -inferences for ‘T’ in the call to ‘choose’ are made as follows: For the first parameter, an inference is made from type ‘string’ to ‘T’. For the second parameter, an inference is made from type ‘number’ to ‘T’. Since the best common type (section [3.10](#3.10)) of ‘string’ and ‘number’ is the empty object type, the call to ‘choose’ 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<{}>("Five", 5); +var x = choose(10, 20); ``` -and the resulting type of ‘x’ is therefore the empty object type. Note that had both arguments been of type ‘string’ or ‘number’, ‘x’ would have been of that type. +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 @@ -2590,7 +2697,7 @@ The ### 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.8](#3.6.8)) 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; @@ -2676,9 +2783,9 @@ The && operator permits the operands to be of any type and produces a result of The || operator permits the operands to be of any type. -If the || expression is contextually typed (section [4.19](#4.19)), the operands are contextually typed by the same type and the result is of the best common type (section [3.10](#3.10)) of the contextual type and the two operand types. +If the || expression is contextually typed (section [4.19](#4.19)), the operands are contextually typed by the same type. Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. -If the || expression is not contextually typed, the right operand is contextually typed by the type of the left operand and the result is of the best common type of the two operand types. +The type of the result is the union type of the two operand types. ||Any|Boolean|Number|String|Object| |:---:|:---:|:---:|:---:|:---:|:---:| @@ -2698,9 +2805,9 @@ test ? expr1 : expr2 the *test* expression may be of any type. -If the conditional expression is contextually typed (section [4.19](#4.19)), *expr1* and *expr2* are contextually typed by the same type and the result is of the best common type (section [3.10](#3.10)) of the contextual type and the types of *expr1* and *expr2*. An error occurs if the best common type is not identical to at least one of the three candidate types. +If the conditional expression is contextually typed (section [4.19](#4.19)), *expr1* and *expr2* are contextually typed by the same type. Otherwise, *expr1* and *expr2* are not contextually typed. -If the conditional expression is not contextually typed, the result is of the best common type of the types of *Expr1* and *Expr2*. An error occurs if the best common type is not identical to at least one of the two candidate types. +The type of the result is the union type of the types of *expr1* and *expr2*. ## 4.17 Assignment Operators @@ -2804,6 +2911,112 @@ 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’. +## 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. + +```TypeScript +function foo(x: number | string) { + if (typeof x === "string") { + return x.length; // x has type string here + } + else { + return x + 1; // x has type number here + } +} +``` + +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 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. +* 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 false*, provided the right operand contains no assignments to the variable or parameter. + +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 + * *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’, + * *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’, + * *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, + * *when true*, narrows the type of x by `typeof x === s` *when false*, or + * *when false*, narrows the type of x by `typeof x === s` *when true*. +* A type guard of the form `!expr` + * *when true*, narrows the type of *x* by *expr* *when false*, or + * *when false*, narrows the type of *x* by *expr* *when true*. +* A type guard of the form `expr1 && expr2` + * *when true*, narrows the type of *x* by *expr1* *when true* and then by *expr2* *when true*, or + * *when false*, narrows the type of *x* to *T1* | *T2*, where *T1* is the type of *x* narrowed by *expr1* *when false*, and *T2* is the type of *x* narrowed by *expr1* *when true* and then by *expr2* *when false*. +* A type guard of the form `expr1 || expr2` + * *when true*, narrows the type of *x* to *T1* | *T2*, where *T1* is the type of *x* narrowed by *expr1* *when true*, and *T2* is the type of *x* narrowed by *expr1* *when false* and then by *expr2* *when true*, or + * *when false*, narrows the type of *x* by *expr1* *when false* and then by *expr2* *when false*. +* A type guard of any other form has no effect on the type of *x*. + +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*. +* 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. + +In the example + +```TypeScript +function isLongString(obj: any) { + return typeof obj === "string" && obj.length > 100; +} +``` + +the ‘obj’ parameter has type string in the right operand of the && operator. + +In the example + +```TypeScript +function f(x: string | number | boolean) { + if (typeof x === "string" || typeof x === "number") { + var y = x; // Type of y is string | number + } + else { + var z = x; // Type of z is 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. + +In the example + +```TypeScript +function processData(data: string | { (): string }) { + var d = typeof data !== "string" ? data() : data; + // Process string in d +} +``` + +the inferred type of ‘d’ is string. + +In the example + +```TypeScript +class NamedItem { + name: string; +} + +function getName(obj: any) { + return obj instanceof NamedItem ? obj.name : "unknown"; +} +``` + +the inferred type of the ‘getName’ function is string. +
#
5 Statements @@ -3000,7 +3213,8 @@ A function implementation without a return type annotation is said to be an ***i * 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, the inferred return type is the widened form (section [3.9](#3.9)) of the best common type (section [3.10](#3.10)) of the types of the return statement expression in the function body, ignoring return statements with no expressions. A compile-time error occurs if the best common type isn’t one of the return statement expression types (i.e. if the best common type is an empty type). +* 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. In the example @@ -4961,6 +5175,7 @@ This appendix contains a summary of the grammar found in the main document. As d    *ObjectType*    *ArrayType*    *TupleType* +   *UnionType*    *FunctionType*    *ConstructorType*    *TypeQuery* @@ -5021,6 +5236,13 @@ This appendix contains a summary of the grammar found in the main document. As d   *TupleElementType:*    *Type* +  *UnionType:* +   *ElementType* `|` *UnionOrElementType* + +  *UnionOrElementType:* +   *UnionType* +   *ElementType* +   *FunctionType:*    *TypeParametersopt* `(` *ParameterListopt* `)` `=>` *Type* diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6927be355a8..5b99e2b2dd9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33,10 +33,16 @@ module ts { if (stringWriters.length == 0) { var str = ""; + var writeText: (text: string) => void = text => str += text; return { string: () => str, - writeKind: text => str += text, - writeSymbol: text => str += text, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, // Completely ignore indentation for string writers. And map newlines to // a single space. @@ -94,7 +100,7 @@ module ts { symbolToString: symbolToString, writeSymbol: writeSymbol, getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType, - getRootSymbol: getRootSymbol, + getRootSymbols: getRootSymbols, getContextualType: getContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: getResolvedSignature, @@ -105,10 +111,12 @@ module ts { writeTypeParameter: writeTypeParameter, writeTypeParametersOfSymbol: writeTypeParametersOfSymbol, isImplementationOfOverload: isImplementationOfOverload, - getAliasedSymbol: resolveImport + getAliasedSymbol: resolveImport, + isUndefinedSymbol: symbol => symbol === undefinedSymbol, + isArgumentsSymbol: symbol => symbol === argumentsSymbol }; - var undefinedSymbol = createSymbol(SymbolFlags.Undefined | SymbolFlags.Property | SymbolFlags.Transient, "undefined"); + var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); var argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); var unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); var resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); @@ -143,6 +151,7 @@ module ts { var globalRegExpType: ObjectType; var tupleTypes: Map = {}; + var unionTypes: Map = {}; var stringLiteralTypes: Map = {}; var emitExtends = false; @@ -757,7 +766,7 @@ module ts { return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): Symbol[] { + function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] { function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable): Symbol[] { function canQualifySymbol(symbolFromSymbolTable: Symbol, meaning: SymbolFlags) { // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible @@ -766,7 +775,7 @@ module ts { } // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning)); + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); return !!accessibleParent; } @@ -788,16 +797,21 @@ module ts { // Check if symbol is any of the alias return forEachValue(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Import) { - var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } + if (!useOnlyExternalAliasing || // We can use any type of alias to get the name + // Is this external alias, then use it to name + ts.forEach(symbolFromSymbolTable.declarations, declaration => + declaration.kind === SyntaxKind.ImportDeclaration && (declaration).externalModuleName)) { + var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } - // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain - // but only if the symbolFromSymbolTable can be qualified - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain + // but only if the symbolFromSymbolTable can be qualified + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } } } }); @@ -843,7 +857,7 @@ module ts { var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -961,19 +975,19 @@ module ts { } function writeKeyword(writer: SymbolWriter, kind: SyntaxKind) { - writer.writeKind(tokenToString(kind), SymbolDisplayPartKind.keyword); + writer.writeKeyword(tokenToString(kind)); } function writePunctuation(writer: SymbolWriter, kind: SyntaxKind) { - writer.writeKind(tokenToString(kind), SymbolDisplayPartKind.punctuation); + writer.writePunctuation(tokenToString(kind)); } function writeOperator(writer: SymbolWriter, kind: SyntaxKind) { - writer.writeKind(tokenToString(kind), SymbolDisplayPartKind.operator); + writer.writeOperator(tokenToString(kind)); } function writeSpace(writer: SymbolWriter) { - writer.writeKind(" ", SymbolDisplayPartKind.space); + writer.writeSpace(" "); } function symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string { @@ -1026,7 +1040,7 @@ module ts { writer.trackSymbol(symbol, enclosingDeclaration, meaning); function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -1092,8 +1106,8 @@ module ts { // 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.writeKind(!(flags & TypeFormatFlags.WriteOwnNameForAnyLike) && - (type.flags & TypeFlags.Any) ? "any" : (type).intrinsicName, SymbolDisplayPartKind.keyword); + writer.writeKeyword(!(flags & TypeFormatFlags.WriteOwnNameForAnyLike) && + (type.flags & TypeFlags.Any) ? "any" : (type).intrinsicName); } else if (type.flags & TypeFlags.Reference) { writeTypeReference(type); @@ -1104,11 +1118,14 @@ module ts { 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.writeKind((type).text, SymbolDisplayPartKind.stringLiteral); + writer.writeStringLiteral((type).text); } else { // Should never get here @@ -1121,18 +1138,23 @@ module ts { } } - function writeTypeList(types: Type[]) { + function writeTypeList(types: Type[], union: boolean) { for (var i = 0; i < types.length; i++) { if (i > 0) { - writePunctuation(writer, SyntaxKind.CommaToken); + if (union) { + writeSpace(writer); + } + writePunctuation(writer, union ? SyntaxKind.BarToken : SyntaxKind.CommaToken); writeSpace(writer); } - writeType(types[i], flags | TypeFormatFlags.WriteArrowStyleSignature); + // 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)) { + 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); @@ -1142,17 +1164,21 @@ module ts { else { writeSymbol(type.target.symbol, writer, enclosingDeclaration, SymbolFlags.Type); writePunctuation(writer, SyntaxKind.LessThanToken); - writeTypeList(type.typeArguments); + writeTypeList(type.typeArguments, /*union*/ false); writePunctuation(writer, SyntaxKind.GreaterThanToken); } } function writeTupleType(type: TupleType) { writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes); + 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)) { @@ -1241,7 +1267,7 @@ module ts { if (resolved.stringIndexType) { // [x: string]: writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeKind("x", SymbolDisplayPartKind.parameterName); + writer.writeParameter("x"); writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); writeKeyword(writer, SyntaxKind.StringKeyword); @@ -1255,7 +1281,7 @@ module ts { if (resolved.numberIndexType) { // [x: number]: writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeKind("x", SymbolDisplayPartKind.parameterName); + writer.writeParameter("x"); writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); writeKeyword(writer, SyntaxKind.NumberKeyword); @@ -1732,6 +1758,15 @@ module ts { return links.type; } + function getTypeOfUnionProperty(symbol: Symbol): Type { + var links = getSymbolLinks(symbol); + if (!links.type) { + var types = map(links.unionType.types, t => getTypeOfSymbol(getPropertyOfType(getApparentType(t), symbol.name))); + links.type = getUnionType(types); + } + return links.type; + } + function getTypeOfSymbol(symbol: Symbol): Type { if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) { return getTypeOfVariableOrParameterOrProperty(symbol); @@ -1751,6 +1786,9 @@ module ts { if (symbol.flags & SymbolFlags.Instantiated) { return getTypeOfInstantiatedSymbol(symbol); } + if (symbol.flags & SymbolFlags.UnionProperty) { + return getTypeOfUnionProperty(symbol); + } return unknownType; } @@ -2041,12 +2079,101 @@ module ts { } function resolveTupleTypeMembers(type: TupleType) { - var arrayType = resolveObjectTypeMembers(createArrayType(getBestCommonType(type.elementTypes))); + var arrayType = resolveObjectTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } + function signatureListsIdentical(s: Signature[], t: Signature[]): boolean { + if (s.length !== t.length) { + return false; + } + for (var i = 0; i < s.length; i++) { + if (!compareSignatures(s[i], t[i], /*compareReturnTypes*/ false, isTypeIdenticalTo)) { + return false; + } + } + return true; + } + + // If the lists of call or construct signatures in the given types are all identical except for return types, + // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the + // return types of the corresponding signatures in each resulting signature. + function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] { + var signatureLists = map(types, t => getSignaturesOfType(t, kind)); + var signatures = signatureLists[0]; + for (var i = 0; i < signatures.length; i++) { + if (signatures[i].typeParameters) { + return emptyArray; + } + } + for (var i = 1; i < signatureLists.length; i++) { + if (!signatureListsIdentical(signatures, signatureLists[i])) { + return emptyArray; + } + } + var result = map(signatures, cloneSignature); + for (var i = 0; i < result.length; i++) { + var s = result[i]; + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = map(signatureLists, signatures => signatures[i]); + } + return result; + } + + function getUnionIndexType(types: Type[], kind: IndexKind): Type { + var indexTypes: Type[] = []; + for (var i = 0; i < types.length; i++) { + var indexType = getIndexTypeOfType(types[i], kind); + if (!indexType) { + return undefined; + } + indexTypes.push(indexType); + } + return getUnionType(indexTypes); + } + + function resolveUnionTypeMembers(type: UnionType) { + var types: Type[] = []; + forEach(type.types, t => { + var apparentType = getApparentType(t); + if (!contains(types, apparentType)) { + types.push(apparentType); + } + }); + if (types.length <= 1) { + var resolved = types.length ? resolveObjectTypeMembers(types[0]) : emptyObjectType; + setObjectTypeMembers(type, resolved.members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexType, resolved.numberIndexType); + return; + } + var members: SymbolTable = {}; + forEach(getPropertiesOfType(types[0]), prop => { + for (var i = 1; i < types.length; i++) { + if (!getPropertyOfType(types[i], prop.name)) { + return; + } + } + var symbol = createSymbol(SymbolFlags.UnionProperty | SymbolFlags.Transient, prop.name); + symbol.unionType = type; + + symbol.declarations = []; + for (var i = 0; i < types.length; i++) { + var s = getPropertyOfType(types[i], prop.name); + if (s.declarations) + symbol.declarations.push.apply(symbol.declarations, s.declarations); + } + + members[prop.name] = symbol; + }); + var callSignatures = getUnionSignatures(types, SignatureKind.Call); + var constructSignatures = getUnionSignatures(types, SignatureKind.Construct); + var stringIndexType = getUnionIndexType(types, IndexKind.String); + var numberIndexType = getUnionIndexType(types, IndexKind.Number); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type: ObjectType) { var symbol = type.symbol; if (symbol.flags & SymbolFlags.TypeLiteral) { @@ -2095,6 +2222,9 @@ module ts { else if (type.flags & TypeFlags.Tuple) { resolveTupleTypeMembers(type); } + else if (type.flags & TypeFlags.Union) { + resolveUnionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -2255,6 +2385,9 @@ module ts { if (signature.target) { var type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); } + else if (signature.unionSignatures) { + var type = getUnionType(map(signature.unionSignatures, getReturnTypeOfSignature)); + } else { var type = getReturnTypeFromBody(signature.declaration); } @@ -2563,6 +2696,102 @@ module ts { return links.resolvedType; } + function addTypeToSortedSet(sortedSet: Type[], type: Type) { + if (type.flags & TypeFlags.Union) { + addTypesToSortedSet(sortedSet, (type).types); + } + else { + var i = 0; + var id = type.id; + while (i < sortedSet.length && sortedSet[i].id < id) { + i++; + } + if (i === sortedSet.length || sortedSet[i].id !== id) { + sortedSet.splice(i, 0, type); + } + } + } + + function addTypesToSortedSet(sortedTypes: Type[], types: Type[]) { + for (var i = 0, len = types.length; i < len; i++) { + addTypeToSortedSet(sortedTypes, types[i]); + } + } + + function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + return true; + } + } + return false; + } + + function removeSubtypes(types: Type[]) { + var i = types.length; + while (i > 0) { + i--; + if (isSubtypeOfAny(types[i], types)) { + types.splice(i, 1); + } + } + } + + function containsAnyType(types: Type[]) { + for (var i = 0; i < types.length; i++) { + if (types[i].flags & TypeFlags.Any) { + return true; + } + } + return false; + } + + function removeAllButLast(types: Type[], typeToRemove: Type) { + var i = types.length; + while (i > 0 && types.length > 1) { + i--; + if (types[i] === typeToRemove) { + types.splice(i, 1); + } + } + } + + function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { + if (types.length === 0) { + return emptyObjectType; + } + var sortedTypes: Type[] = []; + addTypesToSortedSet(sortedTypes, types); + if (noSubtypeReduction) { + if (containsAnyType(sortedTypes)) { + return anyType; + } + removeAllButLast(sortedTypes, undefinedType); + removeAllButLast(sortedTypes, nullType); + } + else { + removeSubtypes(sortedTypes); + } + if (sortedTypes.length === 1) { + return sortedTypes[0]; + } + var id = getTypeListId(sortedTypes); + var type = unionTypes[id]; + if (!type) { + type = unionTypes[id] = createObjectType(TypeFlags.Union); + type.types = sortedTypes; + } + return type; + } + + function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralNode(node: TypeLiteralNode): Type { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -2609,6 +2838,8 @@ module ts { return getTypeFromArrayTypeNode(node); case SyntaxKind.TupleType: return getTypeFromTupleTypeNode(node); + case SyntaxKind.UnionType: + return getTypeFromUnionTypeNode(node); case SyntaxKind.TypeLiteral: return getTypeFromTypeLiteralNode(node); // This function assumes that an identifier or qualified name is a type expression @@ -2773,6 +3004,9 @@ module ts { if (type.flags & TypeFlags.Tuple) { return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); } + if (type.flags & TypeFlags.Union) { + return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); + } } return type; } @@ -2934,7 +3168,7 @@ module ts { errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source: Type, target: Type, reportErrors: boolean): boolean { + function isRelatedTo(source: Type, target: Type, reportErrors?: boolean): boolean { return isRelatedToWithCustomErrors(source, target, reportErrors, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined); } @@ -2955,8 +3189,17 @@ module ts { if (source === numberType && target.flags & TypeFlags.Enum) return true; } } - - if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { + if (source.flags & TypeFlags.Union) { + if (unionTypeRelatedToType(source, target, reportErrors)) { + return true; + } + } + else if (target.flags & TypeFlags.Union) { + if (typeRelatedToUnionType(source, target, reportErrors)) { + return true; + } + } + else if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { if (typeParameterRelatedTo(source, target, reportErrors)) { return true; } @@ -2973,7 +3216,7 @@ module ts { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; // identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); + var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType && objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; @@ -2994,6 +3237,26 @@ module ts { return false; } + function typeRelatedToUnionType(source: Type, target: UnionType, reportErrors: boolean): boolean { + var targetTypes = target.types; + for (var i = 0, len = targetTypes.length; i < len; i++) { + if (isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1)) { + return true; + } + } + return false; + } + + function unionTypeRelatedToType(source: UnionType, target: Type, reportErrors: boolean): boolean { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + if (!isRelatedTo(sourceTypes[i], target, reportErrors)) { + return false; + } + } + return true; + } + function typesRelatedTo(sources: Type[], targets: Type[], reportErrors: boolean): boolean { for (var i = 0, len = sources.length; i < len; i++) { if (!isRelatedTo(sources[i], targets[i], reportErrors)) return false; @@ -3095,34 +3358,12 @@ module ts { function propertiesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { if (relation === identityRelation) { - return propertiesAreIdenticalTo(source, target, reportErrors); + return propertiesIdenticalTo(source, target, reportErrors); } - else { - return propertiesAreSubtypeOrAssignableTo(source, target, reportErrors); - } - } - - function propertiesAreIdenticalTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { - var sourceProperties = getPropertiesOfType(source); - var targetProperties = getPropertiesOfType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (var i = 0, len = sourceProperties.length; i < len; ++i) { - var sourceProp = sourceProperties[i]; - var targetProp = getPropertyOfType(target, sourceProp.name); - if (!targetProp || !isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, isRelatedTo)) { - return false; - } - } - return true; - } - - function propertiesAreSubtypeOrAssignableTo(source: ApparentType, target: ObjectType, reportErrors: boolean): boolean { var properties = getPropertiesOfType(target); for (var i = 0; i < properties.length; i++) { var targetProp = properties[i]; - var sourceProp = getPropertyOfApparentType(source, targetProp.name); + var sourceProp = getPropertyOfApparentType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { if (!isOptionalProperty(targetProp)) { @@ -3195,80 +3436,26 @@ module ts { return true; } - function signaturesRelatedTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): boolean { - if (relation === identityRelation) { - return areSignaturesIdenticalTo(source, target, kind, reportErrors); - } - else { - return areSignaturesSubtypeOrAssignableTo(source, target, kind, reportErrors); - } - } - - function areSignaturesIdenticalTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): boolean { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - if (sourceSignatures.length !== targetSignatures.length) { + function propertiesIdenticalTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { + var sourceProperties = getPropertiesOfType(source); + var targetProperties = getPropertiesOfType(target); + if (sourceProperties.length !== targetProperties.length) { return false; } - - for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - if (!isSignatureIdenticalTo(sourceSignatures[i], targetSignatures[i], reportErrors)) { + for (var i = 0, len = sourceProperties.length; i < len; ++i) { + var sourceProp = sourceProperties[i]; + var targetProp = getPropertyOfType(target, sourceProp.name); + if (!targetProp || !isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, isRelatedTo)) { return false; } } - return true; } - function isSignatureIdenticalTo(source: Signature, target: Signature, reportErrors: boolean): boolean { - if (source === target) { - return true; + function signaturesRelatedTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): boolean { + if (relation === identityRelation) { + return signaturesIdenticalTo(source, target, kind, reportErrors); } - - if (source.hasRestParameter !== target.hasRestParameter) { - return false; - } - - if (source.parameters.length !== target.parameters.length) { - return false; - } - - if (source.minArgumentCount !== target.minArgumentCount) { - return false; - } - - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return false; - } - - for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - if (!isRelatedTo(source.typeParameters[i], target.typeParameters[i], reportErrors)) { - return false; - } - } - } - else if (source.typeParameters || source.typeParameters) { - return false; - } - - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - if (!isRelatedTo(s, t, reportErrors)) { - return false; - } - } - var t = getReturnTypeOfSignature(target); - var s = getReturnTypeOfSignature(source); - return isRelatedTo(s, t, reportErrors); - } - - function areSignaturesSubtypeOrAssignableTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): boolean { if (target === anyFunctionType || source === anyFunctionType) return true; var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); @@ -3280,7 +3467,7 @@ module ts { for (var j = 0; j < sourceSignatures.length; j++) { var s = sourceSignatures[j]; if (!s.hasStringLiterals || source.flags & TypeFlags.FromSignature) { - if (isSignatureSubtypeOrAssignableTo(s, t, localErrors)) { + if (signatureRelatedTo(s, t, localErrors)) { errorInfo = saveErrorInfo; continue outer; } @@ -3294,15 +3481,13 @@ module ts { return true; } - function isSignatureSubtypeOrAssignableTo(source: Signature, target: Signature, reportErrors: boolean): boolean { + function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): boolean { if (source === target) { return true; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { return false; } - var sourceMax = source.parameters.length; var targetMax = target.parameters.length; var checkCount: number; @@ -3348,71 +3533,117 @@ module ts { return isRelatedTo(s, t, reportErrors); } + function signaturesIdenticalTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): boolean { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + if (sourceSignatures.length !== targetSignatures.length) { + return false; + } + for (var i = 0, len = sourceSignatures.length; i < len; ++i) { + if (!compareSignatures(sourceSignatures[i], targetSignatures[i], /*compareReturnTypes*/ true, isRelatedTo)) { + return false; + } + } + return true; + } + function stringIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { if (relation === identityRelation) { - return areIndexTypesIdenticalTo(IndexKind.String, source, target, reportErrors); + return indexTypesIdenticalTo(IndexKind.String, source, target, reportErrors); } - else { - var targetType = getIndexTypeOfType(target, IndexKind.String); - if (targetType) { - var sourceType = getIndexTypeOfType(source, IndexKind.String); - if (!sourceType) { - if (reportErrors) { - reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return false; - } - if (!isRelatedTo(sourceType, targetType, reportErrors)) { - if (reportErrors) { - reportError(Diagnostics.Index_signatures_are_incompatible_Colon); - } - return false; + var targetType = getIndexTypeOfType(target, IndexKind.String); + if (targetType) { + var sourceType = getIndexTypeOfType(source, IndexKind.String); + if (!sourceType) { + if (reportErrors) { + reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } + return false; + } + if (!isRelatedTo(sourceType, targetType, reportErrors)) { + if (reportErrors) { + reportError(Diagnostics.Index_signatures_are_incompatible_Colon); + } + return false; } - return true; } + return true; } function numberIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { if (relation === identityRelation) { - return areIndexTypesIdenticalTo(IndexKind.Number, source, target, reportErrors); + return indexTypesIdenticalTo(IndexKind.Number, source, target, reportErrors); } - else { - var targetType = getIndexTypeOfType(target, IndexKind.Number); - if (targetType) { - var sourceStringType = getIndexTypeOfType(source, IndexKind.String); - var sourceNumberType = getIndexTypeOfType(source, IndexKind.Number); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return false; - } - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - var compatible = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - var compatible = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!compatible) { - if (reportErrors) { - reportError(Diagnostics.Index_signatures_are_incompatible_Colon); - } - return false; + var targetType = getIndexTypeOfType(target, IndexKind.Number); + if (targetType) { + var sourceStringType = getIndexTypeOfType(source, IndexKind.String); + var sourceNumberType = getIndexTypeOfType(source, IndexKind.Number); + if (!(sourceStringType || sourceNumberType)) { + if (reportErrors) { + reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } + return false; + } + if (sourceStringType && sourceNumberType) { + // If we know for sure we're testing both string and numeric index types then only report errors from the second one + var compatible = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + } + else { + var compatible = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + } + if (!compatible) { + if (reportErrors) { + reportError(Diagnostics.Index_signatures_are_incompatible_Colon); + } + return false; } - return true; } + return true; } - function areIndexTypesIdenticalTo(indexKind: IndexKind, source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { + function indexTypesIdenticalTo(indexKind: IndexKind, source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { var targetType = getIndexTypeOfType(target, indexKind); var sourceType = getIndexTypeOfType(source, indexKind); return (!sourceType && !targetType) || (sourceType && targetType && isRelatedTo(sourceType, targetType, reportErrors)); } } + function compareSignatures(source: Signature, target: Signature, compareReturnTypes: boolean, compareTypes: (s: Type, t: Type) => boolean): boolean { + if (source === target) { + return true; + } + if (source.parameters.length !== target.parameters.length || + source.minArgumentCount !== target.minArgumentCount || + source.hasRestParameter !== target.hasRestParameter) { + return false; + } + if (source.typeParameters && target.typeParameters) { + if (source.typeParameters.length !== target.typeParameters.length) { + return false; + } + for (var i = 0, len = source.typeParameters.length; i < len; ++i) { + if (!compareTypes(source.typeParameters[i], target.typeParameters[i])) { + return false; + } + } + } + else if (source.typeParameters || source.typeParameters) { + return false; + } + // Spec 1.0 Section 3.8.3 & 3.8.4: + // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N + source = getErasedSignature(source); + target = getErasedSignature(target); + for (var i = 0, len = source.parameters.length; i < len; i++) { + var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + if (!compareTypes(s, t)) { + return false; + } + } + return !compareReturnTypes || compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + function isSupertypeOfEach(candidate: Type, types: Type[]): boolean { for (var i = 0, len = types.length; i < len; i++) { if (candidate !== types[i] && !isTypeSubtypeOf(types[i], candidate)) return false; @@ -3420,9 +3651,12 @@ module ts { return true; } - function getBestCommonType(types: Type[], contextualType?: Type, candidatesOnly?: boolean): Type { - if (contextualType && isSupertypeOfEach(contextualType, types)) return contextualType; - return forEach(types, t => isSupertypeOfEach(t, types) ? t : undefined) || (candidatesOnly ? undefined : emptyObjectType); + function getCommonSupertype(types: Type[]): Type { + 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 { @@ -3441,10 +3675,13 @@ module ts { } /* If we are widening on a literal, then we may need to the 'node' parameter for reporting purposes */ - function getWidenedType(type: Type, supressNoImplicitAnyErrors?: boolean): Type { + function getWidenedType(type: Type, suppressNoImplicitAnyErrors?: boolean): Type { if (type.flags & (TypeFlags.Undefined | TypeFlags.Null)) { return anyType; } + if (type.flags & TypeFlags.Union) { + return getWidenedTypeOfUnion(type); + } if (isTypeOfObjectLiteral(type)) { return getWidenedTypeOfObjectLiteral(type); } @@ -3453,6 +3690,10 @@ module ts { } return type; + function getWidenedTypeOfUnion(type: Type): Type { + return getUnionType(map((type).types, t => getWidenedType(t, suppressNoImplicitAnyErrors))); + } + function getWidenedTypeOfObjectLiteral(type: Type): Type { var properties = getPropertiesOfType(type); if (properties.length) { @@ -3463,8 +3704,7 @@ module ts { var widenedType = getWidenedType(propType); if (propType !== widenedType) { propTypeWasWidened = true; - - if (!supressNoImplicitAnyErrors && program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { + if (!suppressNoImplicitAnyErrors && compilerOptions.noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType)); } } @@ -3494,10 +3734,8 @@ module ts { function getWidenedTypeOfArrayLiteral(type: Type): Type { var elementType = (type).typeArguments[0]; - var widenedType = getWidenedType(elementType, supressNoImplicitAnyErrors); - + var widenedType = getWidenedType(elementType, suppressNoImplicitAnyErrors); type = elementType !== widenedType ? createArrayType(widenedType) : type; - return type; } } @@ -3534,6 +3772,7 @@ module ts { for (var i = 0; i < typeParameters.length; i++) inferences.push([]); return { typeParameters: typeParameters, + inferenceCount: 0, inferences: inferences, inferredTypes: new Array(typeParameters.length), }; @@ -3571,6 +3810,7 @@ module ts { var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { + context.inferenceCount++; var inferences = context.inferences[i]; if (!contains(inferences, source)) inferences.push(source); break; @@ -3585,6 +3825,34 @@ module ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (target.flags & TypeFlags.Union) { + var targetTypes = (target).types; + var startCount = context.inferenceCount; + var typeParameterCount = 0; + var typeParameter: TypeParameter; + // First infer to each type in union that isn't a type parameter + for (var i = 0; i < targetTypes.length; i++) { + var t = targetTypes[i]; + if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) { + typeParameter = t; + typeParameterCount++; + } + else { + inferFromTypes(source, t); + } + } + // If no inferences were produced above and union contains a single naked type parameter, infer to that type parameter + if (context.inferenceCount === startCount && typeParameterCount === 1) { + inferFromTypes(source, typeParameter); + } + } + else if (source.flags & TypeFlags.Union) { + // Source is a union type, infer from each consituent type + var sourceTypes = (source).types; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], target); + } + } else if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) || (target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members @@ -3648,9 +3916,19 @@ module ts { function getInferredType(context: InferenceContext, index: number): Type { var result = context.inferredTypes[index]; if (!result) { - var commonType = getWidenedType(getBestCommonType(context.inferences[index])); + 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; + } + else { + // Infer the empty object type when no inferences were made + inferredType = emptyObjectType; + } var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); - var result = constraint && !isTypeAssignableTo(commonType, constraint) ? constraint : commonType; + var result = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; context.inferredTypes[index] = result; } return result; @@ -3670,44 +3948,288 @@ module ts { // EXPRESSION TYPE CHECKING - function checkIdentifier(node: Identifier): Type { - function isInTypeQuery(node: Node): boolean { - // TypeScript 1.0 spec (April 2014): 3.6.3 - // A type query consists of the keyword typeof followed by an expression. - // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - while (node) { - switch (node.kind) { - case SyntaxKind.TypeQuery: - return true; - case SyntaxKind.Identifier: - case SyntaxKind.QualifiedName: - node = node.parent; - continue; - default: - return false; + function getResolvedSymbol(node: Identifier): Symbol { + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + links.resolvedSymbol = resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, identifierToString(node)) || unknownSymbol; + } + return links.resolvedSymbol; + } + + function isInTypeQuery(node: Node): boolean { + // TypeScript 1.0 spec (April 2014): 3.6.3 + // A type query consists of the keyword typeof followed by an expression. + // The expression is restricted to a single identifier or a sequence of identifiers separated by periods + while (node) { + switch (node.kind) { + case SyntaxKind.TypeQuery: + return true; + case SyntaxKind.Identifier: + case SyntaxKind.QualifiedName: + node = node.parent; + continue; + default: + return false; + } + } + Debug.fail("should not get here"); + } + + // Remove one or more primitive types from a union type + function subtractPrimitiveTypes(type: Type, subtractMask: TypeFlags): Type { + if (type.flags & TypeFlags.Union) { + var types = (type).types; + if (forEach(types, t => t.flags & subtractMask)) { + return getUnionType(filter(types, t => !(t.flags & subtractMask))); + } + } + return type; + } + + // Check if a given variable is assigned within a given syntax node + function isVariableAssignedWithin(symbol: Symbol, node: Node): boolean { + var links = getNodeLinks(node); + if (links.assignmentChecks) { + var cachedResult = links.assignmentChecks[symbol.id]; + if (cachedResult !== undefined) { + return cachedResult; + } + } + else { + links.assignmentChecks = {}; + } + return links.assignmentChecks[symbol.id] = isAssignedIn(node); + + function isAssignedInBinaryExpression(node: BinaryExpression) { + if (node.operator >= SyntaxKind.FirstAssignment && node.operator <= SyntaxKind.LastAssignment) { + var n = node.left; + while (n.kind === SyntaxKind.ParenExpression) { + n = (n).expression; + } + if (n.kind === SyntaxKind.Identifier && getResolvedSymbol(n) === symbol) { + return true; } } - Debug.fail("should not get here"); + return forEachChild(node, isAssignedIn); } - var symbol = resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, identifierToString(node)); - if (!symbol) { - symbol = unknownSymbol; + function isAssignedInVariableDeclaration(node: VariableDeclaration) { + if (getSymbolOfNode(node) === symbol && node.initializer) { + return true; + } + return forEachChild(node, isAssignedIn); } + function isAssignedIn(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.BinaryExpression: + return isAssignedInBinaryExpression(node); + case SyntaxKind.VariableDeclaration: + return isAssignedInVariableDeclaration(node); + case SyntaxKind.ArrayLiteral: + case SyntaxKind.ObjectLiteral: + case SyntaxKind.PropertyAccess: + case SyntaxKind.IndexedAccess: + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.TypeAssertion: + case SyntaxKind.ParenExpression: + case SyntaxKind.PrefixOperator: + case SyntaxKind.PostfixOperator: + case SyntaxKind.ConditionalExpression: + case SyntaxKind.Block: + case SyntaxKind.VariableStatement: + case SyntaxKind.ExpressionStatement: + case SyntaxKind.IfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ReturnStatement: + case SyntaxKind.WithStatement: + case SyntaxKind.SwitchStatement: + case SyntaxKind.CaseClause: + case SyntaxKind.DefaultClause: + case SyntaxKind.LabeledStatement: + case SyntaxKind.ThrowStatement: + case SyntaxKind.TryStatement: + case SyntaxKind.TryBlock: + case SyntaxKind.CatchBlock: + case SyntaxKind.FinallyBlock: + return forEachChild(node, isAssignedIn); + } + return false; + } + } + + // Get the narrowed type of a given symbol at a given location + function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) { + var type = getTypeOfSymbol(symbol); + // Only narrow when symbol is variable of a non-primitive type + if (symbol.flags & SymbolFlags.Variable && isTypeAnyOrObjectOrTypeParameter(type)) { + while (true) { + var child = node; + node = node.parent; + // Stop at containing function or module block + if (!node || node.kind === SyntaxKind.FunctionBlock || node.kind === SyntaxKind.ModuleBlock) { + break; + } + var narrowedType = type; + switch (node.kind) { + case SyntaxKind.IfStatement: + // In a branch of an if statement, narrow based on controlling expression + if (child !== (node).expression) { + narrowedType = narrowType(type, (node).expression, /*assumeTrue*/ child === (node).thenStatement); + } + break; + case SyntaxKind.ConditionalExpression: + // In a branch of a conditional expression, narrow based on controlling condition + if (child !== (node).condition) { + narrowedType = narrowType(type, (node).condition, /*assumeTrue*/ child === (node).whenTrue); + } + break; + case SyntaxKind.BinaryExpression: + // In the right operand of an && or ||, narrow based on left operand + if (child === (node).right) { + if ((node).operator === SyntaxKind.AmpersandAmpersandToken) { + narrowedType = narrowType(type, (node).left, /*assumeTrue*/ true); + } + else if ((node).operator === SyntaxKind.BarBarToken) { + narrowedType = narrowType(type, (node).left, /*assumeTrue*/ false); + } + } + break; + } + // Only use narrowed type if construct contains no assignments to variable + if (narrowedType !== type) { + if (isVariableAssignedWithin(symbol, node)) { + break; + } + type = narrowedType; + } + } + } + return type; + + function narrowTypeByEquality(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { + var left = expr.left; + var right = expr.right; + // Check that we have 'typeof ' on the left and string literal on the right + if (left.kind !== SyntaxKind.PrefixOperator || left.operator !== SyntaxKind.TypeOfKeyword || + left.operand.kind !== SyntaxKind.Identifier || right.kind !== SyntaxKind.StringLiteral || + getResolvedSymbol(left.operand) !== symbol) { + return type; + } + var t = right.text; + var checkType: Type = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; + if (expr.operator === SyntaxKind.ExclamationEqualsEqualsToken) { + assumeTrue = !assumeTrue; + } + if (assumeTrue) { + // The assumed result is true. If check was for a primitive type, that type is the narrowed type. Otherwise we can + // remove the primitive types from the narrowed type. + return checkType === emptyObjectType ? subtractPrimitiveTypes(type, TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean) : checkType; + } + else { + // The assumed result is false. If check was for a primitive type we can remove that type from the narrowed type. + // Otherwise we don't have enough information to do anything. + return checkType === emptyObjectType ? type : subtractPrimitiveTypes(type, checkType.flags); + } + } + + function narrowTypeByAnd(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { + if (assumeTrue) { + // The assumed result is true, therefore we narrow assuming each operand to be true. + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); + } + else { + // The assumed result is false. This means either the first operand was false, or the first operand was true + // and the second operand was false. We narrow with those assumptions and union the two resulting types. + return getUnionType([ + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) + ]); + } + } + + function narrowTypeByOr(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { + if (assumeTrue) { + // The assumed result is true. This means either the first operand was true, or the first operand was false + // and the second operand was true. We narrow with those assumptions and union the two resulting types. + return getUnionType([ + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) + ]); + } + else { + // The assumed result is false, therefore we narrow assuming each operand to be false. + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); + } + } + + function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { + // Check that assumed result is true and we have variable symbol on the left + if (!assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(expr.left) !== symbol) { + return type; + } + // Check that right operand is a function type with a prototype property + var rightType = checkExpression(expr.right); + if (!isTypeSubtypeOf(rightType, globalFunctionType)) { + return type; + } + var prototypeProperty = getPropertyOfType(getApparentType(rightType), "prototype"); + if (!prototypeProperty) { + return type; + } + var prototypeType = getTypeOfSymbol(prototypeProperty); + // Narrow to type of prototype property if it is a subtype of current type + return isTypeSubtypeOf(prototypeType, type) ? prototypeType : type; + } + + // Narrow the given type based on the given expression having the assumed boolean value + function narrowType(type: Type, expr: Expression, assumeTrue: boolean): Type { + switch (expr.kind) { + case SyntaxKind.ParenExpression: + return narrowType(type, (expr).expression, assumeTrue); + case SyntaxKind.BinaryExpression: + var operator = (expr).operator; + if (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { + return narrowTypeByEquality(type, expr, assumeTrue); + } + else if (operator === SyntaxKind.AmpersandAmpersandToken) { + return narrowTypeByAnd(type, expr, assumeTrue); + } + else if (operator === SyntaxKind.BarBarToken) { + return narrowTypeByOr(type, expr, assumeTrue); + } + else if (operator === SyntaxKind.InstanceOfKeyword) { + return narrowTypeByInstanceof(type, expr, assumeTrue); + } + break; + case SyntaxKind.PrefixOperator: + if ((expr).operator === SyntaxKind.ExclamationToken) { + return narrowType(type, (expr).operand, !assumeTrue); + } + break; + } + return type; + } + } + + function checkIdentifier(node: Identifier): Type { + var symbol = getResolvedSymbol(node); + if (symbol.flags & SymbolFlags.Import) { // Mark the import as referenced so that we emit it in the final .js file. // exception: identifiers that appear in type queries getSymbolLinks(symbol).referenced = !isInTypeQuery(node); } - getNodeLinks(node).resolvedSymbol = symbol; - checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); checkCollisionWithIndexVariableInGeneratedCode(node, node); - return getTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol)); + return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node: Node, container: Node): void { @@ -3982,6 +4504,54 @@ module ts { return undefined; } + // Apply a mapping function to a contextual type and return the resulting type. If the contextual type + // is a union type, the mapping function is applied to each constituent type and a union of the resulting + // types is returned. + function applyToContextualType(type: Type, mapper: (t: Type) => Type): Type { + if (!(type.flags & TypeFlags.Union)) { + return mapper(type); + } + var types = (type).types; + var mappedType: Type; + var mappedTypes: Type[]; + for (var i = 0; i < types.length; i++) { + var t = mapper(types[i]); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; + } + + function getTypeOfPropertyOfContextualType(type: Type, name: string) { + return applyToContextualType(type, t => { + var prop = getPropertyOfType(t, name); + return prop ? getTypeOfSymbol(prop) : undefined; + }); + } + + function getIndexTypeOfContextualType(type: Type, kind: IndexKind) { + return applyToContextualType(type, t => getIndexTypeOfType(t, kind)); + } + + // Return true if the given contextual type is a tuple-like type + function contextualTypeIsTupleType(type: Type): boolean { + return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getPropertyOfType(t, "0")) : getPropertyOfType(type, "0")); + } + + // Return true if the given contextual type provides an index signature of the given kind + function contextualTypeHasIndexSignature(type: Type, kind: IndexKind): boolean { + return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfType(t, kind)) : getIndexTypeOfType(type, kind)); + } + // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one // exists. Otherwise, it is the type of the string index signature in T, if one exists. @@ -3991,11 +4561,9 @@ module ts { var type = getContextualType(objectLiteral); var name = declaration.name.text; if (type && name) { - var prop = getPropertyOfType(type, name); - if (prop) { - return getTypeOfSymbol(prop); - } - return isNumericName(name) && getIndexTypeOfType(type, IndexKind.Number) || getIndexTypeOfType(type, IndexKind.String); + return getTypeOfPropertyOfContextualType(type, name) || + isNumericName(name) && getIndexTypeOfContextualType(type, IndexKind.Number) || + getIndexTypeOfContextualType(type, IndexKind.String); } return undefined; } @@ -4008,11 +4576,7 @@ module ts { var type = getContextualType(arrayLiteral); if (type) { var index = indexOf(arrayLiteral.elements, node); - var prop = getPropertyOfType(type, "" + index); - if (prop) { - return getTypeOfSymbol(prop); - } - return getIndexTypeOfType(type, IndexKind.Number); + return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number); } return undefined; } @@ -4030,7 +4594,6 @@ module ts { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } - if (node.contextualType) { return node.contextualType; } @@ -4060,18 +4623,45 @@ module ts { return undefined; } + // Return the single non-generic signature in the given type, or undefined if none exists + function getNonGenericSignature(type: Type): Signature { + var signatures = getSignaturesOfType(type, SignatureKind.Call); + if (signatures.length !== 1) { + return undefined; + } + var signature = signatures[0]; + if (signature.typeParameters) { + return undefined; + } + return signature; + } + + // Return the contextual signature for a given expression node. A contextual type provides a + // contextual signature if it has a single call signature and if that call signature is non-generic. + // If the contextual type is a union type and each constituent type that has a contextual signature + // provides the same contextual signature, then the union type provides that contextual signature. function getContextualSignature(node: Expression): Signature { var type = getContextualType(node); - if (type) { - var signatures = getSignaturesOfType(type, SignatureKind.Call); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!signature.typeParameters) { - return signature; + if (!type) { + return undefined; + } + if (!(type.flags & TypeFlags.Union)) { + return getNonGenericSignature(type); + } + var result: Signature; + var types = (type).types; + for (var i = 0; i < types.length; i++) { + var signature = getNonGenericSignature(types[i]); + if (signature) { + if (!result) { + result = signature; + } + else if (!compareSignatures(result, signature, /*compareReturnTypes*/ true, isTypeIdenticalTo)) { + return undefined; } } } - return undefined; + return result; } // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is @@ -4081,27 +4671,16 @@ module ts { } function checkArrayLiteral(node: ArrayLiteral, contextualMapper?: TypeMapper): Type { - var contextualType = getContextualType(node); var elements = node.elements; - var elementTypes: Type[] = []; - var isTupleLiteral: boolean = false; - for (var i = 0; i < elements.length; i++) { - if (contextualType && getPropertyOfType(contextualType, "" + i)) { - isTupleLiteral = true; - } - var element = elements[i]; - var type = element.kind !== SyntaxKind.OmittedExpression ? checkExpression(element, contextualMapper) : undefinedType; - elementTypes.push(type); + if (!elements.length) { + return createArrayType(undefinedType); } - if (isTupleLiteral) { + var elementTypes = map(elements, e => checkExpression(e, contextualMapper)); + var contextualType = getContextualType(node); + if (contextualType && contextualTypeIsTupleType(contextualType)) { return createTupleType(elementTypes); } - var contextualElementType = contextualType && !isInferentialContext(contextualMapper) ? getIndexTypeOfType(contextualType, IndexKind.Number) : undefined; - var elementType = getBestCommonType(uniqueElements(elementTypes), contextualElementType, true); - if (!elementType) { - elementType = elements.length ? emptyObjectType : undefinedType; - } - return createArrayType(elementType); + return createArrayType(getUnionType(elementTypes)); } function isNumericName(name: string) { @@ -4112,7 +4691,6 @@ module ts { var members = node.symbol.members; var properties: SymbolTable = {}; var contextualType = getContextualType(node); - for (var id in members) { if (hasProperty(members, id)) { var member = members[id]; @@ -4150,21 +4728,19 @@ module ts { return createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); function getIndexType(kind: IndexKind) { - if (contextualType) { - var indexType = getIndexTypeOfType(contextualType, kind); - if (indexType) { - var propTypes: Type[] = []; - for (var id in properties) { - if (hasProperty(properties, id)) { - if (kind === IndexKind.String || isNumericName(id)) { - var type = getTypeOfSymbol(properties[id]); - if (!contains(propTypes, type)) propTypes.push(type); - } + if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { + var propTypes: Type[] = []; + for (var id in properties) { + if (hasProperty(properties, id)) { + if (kind === IndexKind.String || isNumericName(id)) { + var type = getTypeOfSymbol(properties[id]); + if (!contains(propTypes, type)) propTypes.push(type); } } - return getBestCommonType(propTypes, isInferentialContext(contextualMapper) ? undefined : indexType); } + return propTypes.length ? getUnionType(propTypes) : undefinedType; } + return undefined; } } @@ -4420,7 +4996,9 @@ module ts { } } } - return getInferredTypes(context); + var inferredTypes = getInferredTypes(context); + // Inference has failed if the undefined type is in list of inferences + return contains(inferredTypes, undefinedType) ? undefined : inferredTypes; } function checkTypeArguments(signature: Signature, typeArguments: TypeNode[]): Type[] { @@ -4445,7 +5023,6 @@ module ts { if (arg.kind === SyntaxKind.OmittedExpression) { continue; } - var paramType = getTypeAtPosition(signature, i); // String literals get string literal types unless we're reporting errors var argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors ? @@ -4481,26 +5058,30 @@ module ts { } } var relation = candidates.length === 1 ? assignableRelation : subtypeRelation; + var lastCandidate: Signature; while (true) { for (var i = 0; i < candidates.length; i++) { if (!signatureHasCorrectArity(node, candidates[i])) { continue; } - while (true) { - var candidateWithCorrectArity = candidates[i]; - if (candidateWithCorrectArity.typeParameters) { + var candidate = candidates[i]; + if (candidate.typeParameters) { var typeArguments = node.typeArguments ? - checkTypeArguments(candidateWithCorrectArity, node.typeArguments) : - inferTypeArguments(candidateWithCorrectArity, args, excludeArgument); - candidateWithCorrectArity = getSignatureInstantiation(candidateWithCorrectArity, typeArguments); + checkTypeArguments(candidate, node.typeArguments) : + inferTypeArguments(candidate, args, excludeArgument); + if (!typeArguments) { + break; + } + candidate = getSignatureInstantiation(candidate, typeArguments); } - if (!checkApplicableSignature(node, candidateWithCorrectArity, relation, excludeArgument, /*reportErrors*/ false)) { + lastCandidate = candidate; + if (!checkApplicableSignature(node, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? indexOf(excludeArgument, true) : -1; if (index < 0) { - return candidateWithCorrectArity; + return candidate; } excludeArgument[index] = false; } @@ -4515,8 +5096,8 @@ module ts { // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. - if (candidateWithCorrectArity) { - checkApplicableSignature(node, candidateWithCorrectArity, relation, /*excludeArgument*/ undefined, /*reportErrors*/ true); + if (lastCandidate) { + checkApplicableSignature(node, lastCandidate, relation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else { error(node, Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); @@ -4616,7 +5197,9 @@ module ts { // but is a subtype of the Function interface, the call is an untyped function call. In an // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. - if ((funcType === anyType) || (!callSignatures.length && !constructSignatures.length && isTypeAssignableTo(funcType, globalFunctionType))) { + // We exclude union types because we may have a union of function types that happen to have + // no common signatures. + if (funcType === anyType || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { if (node.typeArguments) { error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } @@ -4760,11 +5343,12 @@ module ts { } function getReturnTypeFromBody(func: FunctionDeclaration, contextualMapper?: TypeMapper): Type { + var contextualSignature = getContextualSignature(func); if (func.body.kind !== SyntaxKind.FunctionBlock) { var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); - if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { + if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType)); } @@ -4776,7 +5360,9 @@ module ts { // Try to return the best common type if we have any return expressions. if (types.length > 0) { - var commonType = getBestCommonType(types, /*contextualType:*/ undefined, /*candidatesOnly:*/ true); + // When return statements are contextually typed we allow the return type to be a union type. Otherwise we require the + // return expressions to have a best common supertype. + var commonType = contextualSignature ? getUnionType(types) : getCommonSupertype(types); if (!commonType) { error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); @@ -4786,7 +5372,7 @@ module ts { var widenedType = getWidenedType(commonType); // Check and report for noImplicitAny if the best common type implicitly gets widened to an 'any'/arrays-of-'any' type. - if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { + if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { var typeName = typeToString(widenedType); if (func.name) { @@ -5023,8 +5609,8 @@ module ts { return numberType; } - function isTypeAnyTypeObjectTypeOrTypeParameter(type: Type): boolean { - return type === anyType || ((type.flags & (TypeFlags.ObjectType | TypeFlags.TypeParameter)) !== 0); + function isTypeAnyOrObjectOrTypeParameter(type: Type): boolean { + return (type.flags & (TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) !== 0; } function checkInstanceOfExpression(node: BinaryExpression, leftType: Type, rightType: Type): Type { @@ -5033,7 +5619,7 @@ module ts { // 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: do not raise error if leftType is unknown as related error was already reported - if (leftType !== unknownType && !isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) { + if (leftType !== unknownType && !isTypeAnyOrObjectOrTypeParameter(leftType)) { error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -5051,7 +5637,7 @@ module ts { if (leftType !== anyType && leftType !== stringType && leftType !== numberType) { error(node.left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number); } - if (!isTypeAnyTypeObjectTypeOrTypeParameter(rightType)) { + if (!isTypeAnyOrObjectOrTypeParameter(rightType)) { error(node.right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -5163,7 +5749,7 @@ module ts { case SyntaxKind.AmpersandAmpersandToken: return rightType; case SyntaxKind.BarBarToken: - return getBestCommonType([leftType, rightType], isInferentialContext(contextualMapper) ? undefined : getContextualType(node)); + return getUnionType([leftType, rightType]); case SyntaxKind.EqualsToken: checkAssignmentOperator(rightType); return rightType; @@ -5213,18 +5799,7 @@ module ts { checkExpression(node.condition); var type1 = checkExpression(node.whenTrue, contextualMapper); var type2 = checkExpression(node.whenFalse, contextualMapper); - var contextualType = isInferentialContext(contextualMapper) ? undefined : getContextualType(node); - var resultType = getBestCommonType([type1, type2], contextualType, true); - if (!resultType) { - if (contextualType) { - error(node, Diagnostics.No_best_common_type_exists_between_0_1_and_2, typeToString(contextualType), typeToString(type1), typeToString(type2)); - } - else { - error(node, Diagnostics.No_best_common_type_exists_between_0_and_1, typeToString(type1), typeToString(type2)); - } - resultType = emptyObjectType; - } - return resultType; + return getUnionType([type1, type2]); } function checkExpressionWithContextualType(node: Expression, contextualType: Type, contextualMapper?: TypeMapper): Type { @@ -5312,6 +5887,8 @@ module ts { return checkBinaryExpression(node, contextualMapper); case SyntaxKind.ConditionalExpression: return checkConditionalExpression(node, contextualMapper); + case SyntaxKind.OmittedExpression: + return undefinedType; } return unknownType; } @@ -5616,6 +6193,10 @@ module ts { forEach(node.elementTypes, checkSourceElement); } + function checkUnionType(node: UnionTypeNode) { + forEach(node.types, checkSourceElement); + } + function isPrivateWithinAmbient(node: Node): boolean { return (node.flags & NodeFlags.Private) && isInAmbientContext(node); } @@ -6309,7 +6890,7 @@ module ts { var exprType = checkExpression(node.expression); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyTypeObjectTypeOrTypeParameter(exprType) && exprType !== unknownType) { + if (!isTypeAnyOrObjectOrTypeParameter(exprType) && exprType !== unknownType) { error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } @@ -6931,6 +7512,8 @@ module ts { return checkArrayType(node); case SyntaxKind.TupleType: return checkTupleType(node); + case SyntaxKind.UnionType: + return checkUnionType(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.Block: @@ -7590,8 +8173,26 @@ module ts { } } - function getRootSymbol(symbol: Symbol) { - return ((symbol.flags & SymbolFlags.Transient) && getSymbolLinks(symbol).target) || symbol; + 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[] = []; + var name = symbol.name; + forEach(getSymbolLinks(symbol).unionType.types, t => { + symbols.push(getPropertyOfType(getApparentType(t), name)); + }); + return symbols; + } + else if (symbol.flags & SymbolFlags.Transient) { + var target = getSymbolLinks(symbol).target; + if (target) { + return [target]; + } + } + return [symbol]; } // Emitter support diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3da94137fc8..ee7f4701d19 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -82,7 +82,7 @@ module ts { return array1.concat(array2); } - export function uniqueElements(array: T[]): T[] { + export function deduplicate(array: T[]): T[] { if (array) { var result: T[] = []; for (var i = 0, len = array.length; i < len; i++) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index c9d296d8bcc..d96214ae1d9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -188,8 +188,6 @@ module ts { The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - No_best_common_type_exists_between_0_1_and_2: { code: 2366, category: DiagnosticCategory.Error, key: "No best common type exists between '{0}', '{1}', and '{2}'." }, - No_best_common_type_exists_between_0_and_1: { code: 2367, category: DiagnosticCategory.Error, key: "No best common type exists between '{0}' and '{1}'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 68b5395224a..ee1a82b9c13 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -744,14 +744,6 @@ "category": "Error", "code": 2365 }, - "No best common type exists between '{0}', '{1}', and '{2}'.": { - "category": "Error", - "code": 2366 - }, - "No best common type exists between '{0}' and '{1}'.": { - "category": "Error", - "code": 2367 - }, "Type parameter name cannot be '{0}'": { "category": "Error", "code": 2368 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8c0dd818d32..951ed857550 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4,8 +4,11 @@ /// module ts { - interface EmitTextWriter extends SymbolWriter { + interface EmitTextWriter { write(s: string): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; getText(): string; rawWrite(s: string): void; writeLiteral(s: string): void; @@ -15,6 +18,9 @@ module ts { getIndent(): number; } + interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter{ + } + var indentStrings: string[] = ["", " "]; export function getIndentString(level: number) { if (indentStrings[level] === undefined) { @@ -103,7 +109,7 @@ module ts { }; } - function createTextWriter(trackSymbol: (symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags)=> void): EmitTextWriter { + function createTextWriter(): EmitTextWriter { var output = ""; var indent = 0; var lineStart = true; @@ -149,17 +155,8 @@ module ts { } } - function writeKind(text: string, kind: SymbolDisplayPartKind) { - write(text); - } - function writeSymbol(text: string, symbol: Symbol) { - write(text); - } return { write: write, - trackSymbol: trackSymbol, - writeKind: writeKind, - writeSymbol: writeSymbol, rawWrite: rawWrite, writeLiteral: writeLiteral, writeLine: writeLine, @@ -170,7 +167,6 @@ module ts { getLine: () => lineCount + 1, getColumn: () => lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1, getText: () => output, - clear: () => { } }; } @@ -318,7 +314,7 @@ module ts { } function emitJavaScript(jsFilePath: string, root?: SourceFile) { - var writer = createTextWriter(trackSymbol); + var writer = createTextWriter(); var write = writer.write; var writeLine = writer.writeLine; var increaseIndent = writer.increaseIndent; @@ -374,8 +370,6 @@ module ts { /** Sourcemap data that will get encoded */ var sourceMapData: SourceMapData; - function trackSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags) { } - function initializeEmitterWithSourceMaps() { var sourceMapDir: string; // The directory in which sourcemap will be @@ -2337,7 +2331,7 @@ module ts { } function emitDeclarations(jsFilePath: string, root?: SourceFile) { - var writer = createTextWriter(trackSymbol); + var writer = createTextWriterWithSymbolWriter(); var write = writer.write; var writeLine = writer.writeLine; var increaseIndent = writer.increaseIndent; @@ -2361,11 +2355,24 @@ module ts { typeName?: Identifier } + function createTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { + var writer = createTextWriter(); + writer.trackSymbol = trackSymbol; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + return writer; + } + function writeAsychronousImportDeclarations(importDeclarations: ImportDeclaration[]) { var oldWriter = writer; forEach(importDeclarations, aliasToWrite => { var aliasEmitInfo = forEach(aliasDeclarationEmitInfo, declEmitInfo => declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined); - writer = createTextWriter(trackSymbol); + writer = createTextWriterWithSymbolWriter(); for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { writer.increaseIndent(); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b011220095c..112096615b2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -225,6 +225,8 @@ module ts { return child((node).elementType); case SyntaxKind.TupleType: return children((node).elementTypes); + case SyntaxKind.UnionType: + return children((node).types); case SyntaxKind.ArrayLiteral: return children((node).elements); case SyntaxKind.ObjectLiteral: @@ -1729,9 +1731,9 @@ module ts { } } - function parseType(): TypeNode { + function parseNonUnionType(): TypeNode { var type = parseNonArrayType(); - while (type && !scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) { + while (!scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) { parseExpected(SyntaxKind.CloseBracketToken); var node = createNode(SyntaxKind.ArrayType, type.pos); node.elementType = type; @@ -1740,6 +1742,22 @@ module ts { return type; } + function parseType(): TypeNode { + var type = parseNonUnionType(); + if (token === SyntaxKind.BarToken) { + var types = >[type]; + types.pos = type.pos; + while (parseOptional(SyntaxKind.BarToken)) { + types.push(parseNonUnionType()); + } + types.end = getNodeEnd(); + var node = createNode(SyntaxKind.UnionType, type.pos); + node.types = types; + type = finishNode(node); + } + return type; + } + function parseTypeAnnotation(): TypeNode { return parseOptional(SyntaxKind.ColonToken) ? parseType() : undefined; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 09cd613e8f3..5eb567e406e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -154,6 +154,7 @@ module ts { TypeLiteral, ArrayType, TupleType, + UnionType, // Expression ArrayLiteral, ObjectLiteral, @@ -224,7 +225,7 @@ module ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypeReference, - LastTypeNode = TupleType, + LastTypeNode = UnionType, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = EndOfFileToken, @@ -340,6 +341,10 @@ module ts { elementTypes: NodeArray; } + export interface UnionTypeNode extends TypeNode { + types: NodeArray; + } + export interface StringLiteralTypeNode extends TypeNode { text: string; } @@ -651,7 +656,7 @@ module ts { writeSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfApparentType(type: Type): Symbol[]; - getRootSymbol(symbol: Symbol): Symbol; + getRootSymbols(symbol: Symbol): Symbol[]; getContextualType(node: Node): Type; getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; @@ -659,6 +664,8 @@ module ts { 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; // Returns the constant value of this enum member, or 'undefined' if the enum member has a // computed value. @@ -669,7 +676,12 @@ module ts { } export interface SymbolWriter { - writeKind(text: string, kind: SymbolDisplayPartKind): void; + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; writeSymbol(text: string, symbol: Symbol): void; writeLine(): void; increaseIndent(): void; @@ -698,6 +710,9 @@ module ts { // eg. class C { p: T } <-- Show p as C.p here // var a: C; // var p = a.p; <--- Here p is property of C so show it as C.p instead of just C.p + UseOnlyExternalAliasing = 0x00000002, // Use only external alias information to get the symbol name in the given context + // eg. module m { export class c { } } import x = m.c; + // When this flag is specified m.c will be used to refer to the class instead of alias symbol x } export enum SymbolAccessibility { @@ -755,23 +770,22 @@ module ts { ConstructSignature = 0x00010000, // Construct signature IndexSignature = 0x00020000, // Index signature TypeParameter = 0x00040000, // Type parameter + UnionProperty = 0x00080000, // Property in union type // Export markers (see comment in declareModuleMember in binder) - ExportValue = 0x00080000, // Exported value marker - ExportType = 0x00100000, // Exported type marker - ExportNamespace = 0x00200000, // Exported namespace marker + ExportValue = 0x00100000, // Exported value marker + ExportType = 0x00200000, // Exported type marker + ExportNamespace = 0x00400000, // Exported namespace marker - Import = 0x00400000, // Import - Instantiated = 0x00800000, // Instantiated symbol - Merged = 0x01000000, // Merged symbol (created during program binding) - Transient = 0x02000000, // Transient symbol (created during type check) - Prototype = 0x04000000, // Symbol for the prototype property (without source code representation) - - Undefined = 0x08000000, // Symbol for the undefined + Import = 0x00800000, // Import + Instantiated = 0x01000000, // Instantiated symbol + Merged = 0x02000000, // Merged symbol (created during program binding) + Transient = 0x04000000, // Transient symbol (created during type check) + Prototype = 0x08000000, // Prototype property (no source representation) BlockScoped = 0x10000000, - Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor, + Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor | UnionProperty, Type = Class | Interface | Enum | TypeLiteral | ObjectLiteral | TypeParameter, Namespace = ValueModule | NamespaceModule, Module = ValueModule | NamespaceModule, @@ -830,6 +844,7 @@ module ts { mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value exportAssignSymbol?: Symbol; // Symbol exported from external module + unionType?: UnionType; // Containing union type for union property } export interface TransientSymbol extends Symbol, SymbolLinks { } @@ -852,14 +867,15 @@ module ts { } export interface NodeLinks { - resolvedType?: Type; // Cached type of type node - resolvedSignature?: Signature; // Cached signature of signature node or call expression - resolvedSymbol?: Symbol; // Cached name resolution result - flags?: NodeCheckFlags; // Set of flags specific to Node - enumMemberValue?: number; // Constant value of enum member + resolvedType?: Type; // Cached type of type node + resolvedSignature?: Signature; // Cached signature of signature node or call expression + resolvedSymbol?: Symbol; // Cached name resolution result + flags?: NodeCheckFlags; // Set of flags specific to Node + enumMemberValue?: number; // Constant value of enum member isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list - isVisible?: boolean; // Is this node visible - localModuleName?: string; // Local name for module instance + isVisible?: boolean; // Is this node visible + localModuleName?: string; // Local name for module instance + assignmentChecks?: Map; // Cache of assignment checks } export enum TypeFlags { @@ -877,13 +893,14 @@ module ts { Interface = 0x00000800, // Interface Reference = 0x00001000, // Generic type reference Tuple = 0x00002000, // Tuple - Anonymous = 0x00004000, // Anonymous - FromSignature = 0x00008000, // Created for signature assignment check + Union = 0x00004000, // Union + Anonymous = 0x00008000, // Anonymous + FromSignature = 0x00010000, // Created for signature assignment check - Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null, + Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null, StringLike = String | StringLiteral, NumberLike = Number | Enum, - ObjectType = Class | Interface | Reference | Tuple | Anonymous + ObjectType = Class | Interface | Reference | Tuple | Union | Anonymous, } // Properties common to all types @@ -941,6 +958,10 @@ module ts { baseArrayType: TypeReference; // Array where T is best common type of element types } + export interface UnionType extends ObjectType { + types: Type[]; // Constituent types + } + // Resolved object type export interface ResolvedObjectType extends ObjectType { members: SymbolTable; // Properties by name @@ -973,6 +994,7 @@ module ts { hasStringLiterals: boolean; // True if specialized target?: Signature; // Instantiation target mapper?: TypeMapper; // Instantiation mapper + unionSignatures?: Signature[]; // Underlying signatures of a union signature erasedSignatureCache?: Signature; // Erased version of signature (deferred) isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison } @@ -987,9 +1009,10 @@ module ts { } export interface InferenceContext { - typeParameters: TypeParameter[]; - inferences: Type[][]; - inferredTypes: Type[]; + typeParameters: TypeParameter[]; // Type parameters for which inferences are made + 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 } export interface DiagnosticMessage { @@ -1220,32 +1243,7 @@ module ts { tab = 0x09, // \t verticalTab = 0x0B, // \v } - - export enum SymbolDisplayPartKind { - aliasName, - className, - enumName, - fieldName, - interfaceName, - keyword, - lineBreak, - numericLiteral, - stringLiteral, - localName, - methodName, - moduleName, - operator, - parameterName, - propertyName, - punctuation, - space, - text, - typeParameterName, - enumMemberName, - functionName, - regularExpressionLiteral, - } - + export interface CancellationToken { isCancellationRequested(): boolean; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0e605a854e2..82247b1711a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -146,7 +146,7 @@ module FourSlash { function convertGlobalOptionsToCompilationSettings(globalOptions: { [idx: string]: string }): ts.CompilationSettings { var settings: ts.CompilationSettings = {}; - // Convert all property in globalOptions into ts.CompilationSettings + // Convert all property in globalOptions into ts.CompilationSettings for (var prop in globalOptions) { if (globalOptions.hasOwnProperty(prop)) { switch (prop) { @@ -1610,7 +1610,7 @@ module FourSlash { Harness.IO.log(this.getNameOrDottedNameSpan(pos)); } - private verifyClassifications(expected: { classificationType: string; text: string }[], actual: ts.ClassifiedSpan[]) { + private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) { if (actual.length !== expected.length) { this.raiseError('verifyClassifications failed - expected total classifications to be ' + expected.length + ', but was ' + actual.length); } @@ -1626,7 +1626,19 @@ module FourSlash { actualClassification.classificationType); } + var expectedSpan = expectedClassification.textSpan; var actualSpan = actualClassification.textSpan; + + if (expectedSpan) { + var expectedLength = expectedSpan.end - expectedSpan.start; + + if (expectedSpan.start !== actualSpan.start() || expectedLength !== actualSpan.length()) { + this.raiseError("verifyClassifications failed - expected span of text to be " + + "{start=" + expectedSpan.start + ", length=" + expectedLength + "}, but was " + + "{start=" + actualSpan.start() + ", length=" + actualSpan.length() + "}"); + } + } + var actualText = this.activeFile.content.substr(actualSpan.start(), actualSpan.length()); if (expectedClassification.text !== actualText) { this.raiseError('verifyClassifications failed - expected classificatied text to be ' + diff --git a/src/services/compiler/declarationEmitter.ts b/src/services/compiler/declarationEmitter.ts index 85e5bf09647..460904b7e88 100644 --- a/src/services/compiler/declarationEmitter.ts +++ b/src/services/compiler/declarationEmitter.ts @@ -476,8 +476,6 @@ module TypeScript { //} } - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(this.semanticInfoChain); this.emitDeclarationComments(funcDecl); this.emitIndent(); @@ -603,11 +601,6 @@ module TypeScript { private emitConstructSignature(funcDecl: ConstructSignatureSyntax) { var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - this.emitDeclarationComments(funcDecl); this.emitIndent(); @@ -633,11 +626,6 @@ module TypeScript { private emitMethodSignature(funcDecl: MethodSignatureSyntax) { var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - this.emitDeclarationComments(funcDecl); this.emitIndent(); @@ -817,7 +805,6 @@ module TypeScript { var parameter = funcDecl.callSignature.parameterList.parameters[i]; var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); if (hasFlag(parameterDecl.flags, PullElementFlags.PropertyParameter)) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); this.emitDeclarationComments(parameter); this.declFile.Write(this.getIndentString()); this.emitClassElementModifiers(parameter.modifiers); @@ -838,7 +825,6 @@ module TypeScript { var className = classDecl.identifier.text(); this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); this.emitDeclFlags(classDecl, "class"); this.declFile.Write(className); @@ -934,7 +920,6 @@ module TypeScript { var interfaceName = interfaceDecl.identifier.text(); this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); this.emitDeclFlags(interfaceDecl, "interface"); this.declFile.Write(interfaceName); @@ -980,7 +965,6 @@ module TypeScript { } this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); this.emitDeclFlags(moduleDecl, "enum"); this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); diff --git a/src/services/compiler/typescript.ts b/src/services/compiler/typescript.ts index f98d0baf52b..5671d167d1b 100644 --- a/src/services/compiler/typescript.ts +++ b/src/services/compiler/typescript.ts @@ -512,7 +512,7 @@ module TypeScript { for (var i = 0, n = fileNames.length; i < n; i++) { var fileName = fileNames[i]; - var document = this.getDocument(fileNames[i]); + var document = this.getDocument(fileName); sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, file => emitOutput.outputFiles.push(file), sharedEmitter); @@ -578,7 +578,6 @@ module TypeScript { var sourceUnit = document.sourceUnit(); Debug.assert(this._shouldEmit(document)); - var typeScriptFileName = document.fileName; if (!emitter) { var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); var outFile = new TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), OutputFileType.JavaScript); @@ -799,8 +798,6 @@ module TypeScript { } private extractResolutionContextFromAST(resolver: PullTypeResolver, ast: ISyntaxElement, document: Document, propagateContextualTypes: boolean): { ast: ISyntaxElement; enclosingDecl: PullDecl; resolutionContext: PullTypeResolutionContext; inContextuallyTypedAssignment: boolean; inWithBlock: boolean; } { - var scriptName = document.fileName; - var enclosingDecl: PullDecl = null; var enclosingDeclAST: ISyntaxElement = null; var inContextuallyTypedAssignment = false; @@ -981,7 +978,6 @@ module TypeScript { case SyntaxKind.ReturnStatement: if (propagateContextualTypes) { - var returnStatement = current; var contextualType: PullTypeSymbol = null; if (enclosingDecl && (enclosingDecl.kind & PullElementKind.SomeFunction)) { diff --git a/src/services/core/integerUtilities.ts b/src/services/core/integerUtilities.ts index 0af38471dfd..b0a4d6667b9 100644 --- a/src/services/core/integerUtilities.ts +++ b/src/services/core/integerUtilities.ts @@ -7,12 +7,6 @@ module TypeScript { } export function integerMultiplyLow32Bits(n1: number, n2: number): number { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; return resultLow32; } diff --git a/src/services/services.ts b/src/services/services.ts index d7c5dc2d897..0222a448aeb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -994,12 +994,37 @@ module ts { containerKind: string; containerName: string; } - + + export enum SymbolDisplayPartKind { + aliasName, + className, + enumName, + fieldName, + interfaceName, + keyword, + lineBreak, + numericLiteral, + stringLiteral, + localName, + methodName, + moduleName, + operator, + parameterName, + propertyName, + punctuation, + space, + text, + typeParameterName, + enumMemberName, + functionName, + regularExpressionLiteral, + } + export interface SymbolDisplayPart { text: string; kind: string; } - + export interface QuickInfo { kind: string; kindModifiers: string; @@ -1306,7 +1331,12 @@ module ts { resetWriter(); return { displayParts: () => displayParts, - writeKind: writeKind, + writeKeyword: text => writeKind(text, SymbolDisplayPartKind.keyword), + writeOperator: text => writeKind(text, SymbolDisplayPartKind.operator), + writePunctuation: text => writeKind(text, SymbolDisplayPartKind.punctuation), + writeSpace: text => writeKind(text, SymbolDisplayPartKind.space), + writeStringLiteral: text => writeKind(text, SymbolDisplayPartKind.stringLiteral), + writeParameter: text => writeKind(text, SymbolDisplayPartKind.parameterName), writeSymbol: writeSymbol, writeLine: writeLine, increaseIndent: () => { indent++; }, @@ -2250,7 +2280,7 @@ module ts { return undefined; } - function createCompletionEntry(symbol: Symbol): CompletionEntry { + function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker): CompletionEntry { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) @@ -2259,9 +2289,13 @@ module ts { return undefined; } + // TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind' + // which is permissible given that it is backwards compatible; but really we should consider + // passing the meaning for the node so that we don't report that a suggestion for a value is an interface. + // We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration. return { name: displayName, - kind: getSymbolKind(symbol), + kind: getSymbolKind(symbol, typeChecker), kindModifiers: getSymbolModifiers(symbol) }; } @@ -2269,7 +2303,7 @@ module ts { function getCompletionsAtPosition(filename: string, position: number, isMemberCompletion: boolean) { function getCompletionEntriesFromSymbols(symbols: Symbol[], session: CompletionSession): void { forEach(symbols, symbol => { - var entry = createCompletionEntry(symbol); + var entry = createCompletionEntry(symbol, session.typeChecker); if (entry && !lookUp(session.symbols, entry.name)) { session.entries.push(entry); session.symbols[entry.name] = symbol; @@ -2608,12 +2642,12 @@ module ts { if (symbol) { var type = session.typeChecker.getTypeOfSymbol(symbol); Debug.assert(type, "Could not find type for symbol"); - var completionEntry = createCompletionEntry(symbol); + var completionEntry = createCompletionEntry(symbol, session.typeChecker); // TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind' // which is permissible given that it is backwards compatible; but really we should consider // passing the meaning for the node so that we don't report that a suggestion for a value is an interface. // We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration. - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), session.location, session.typeChecker, session.location); + var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), session.location, session.typeChecker, session.location, SemanticMeaning.All); return { name: entryName, kind: displayPartsDocumentationsAndSymbolKind.symbolKind, @@ -2657,15 +2691,15 @@ module ts { } // TODO(drosen): use contextual SemanticMeaning. - function getSymbolKind(symbol: Symbol): string { - var flags = typeInfoResolver.getRootSymbol(symbol).getFlags(); + function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker): string { + var flags = typeInfoResolver.getRootSymbols(symbol)[0].getFlags(); if (flags & SymbolFlags.Class) return ScriptElementKind.classElement; if (flags & SymbolFlags.Enum) return ScriptElementKind.enumElement; if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement; if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags); + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver); if (result === ScriptElementKind.unknown) { if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement; if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement; @@ -2675,16 +2709,19 @@ module ts { return result; } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, typeResolver: TypeChecker) { + if (typeResolver.isUndefinedSymbol(symbol)) { + return ScriptElementKind.variableElement; + } + if (typeResolver.isArgumentsSymbol(symbol)) { + return ScriptElementKind.localVariableElement; + } if (flags & SymbolFlags.Variable) { if (isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; } return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; } - if (flags & SymbolFlags.Undefined) { - return ScriptElementKind.variableElement; - } if (flags & SymbolFlags.Function) return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; if (flags & SymbolFlags.GetAccessor) return ScriptElementKind.memberGetAccessorElement; if (flags & SymbolFlags.SetAccessor) return ScriptElementKind.memberSetAccessorElement; @@ -2737,27 +2774,21 @@ module ts { : ScriptElementKindModifier.none; } - // TODO(drosen): use contextual SemanticMeaning. - function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol: Symbol, - sourceFile: SourceFile, - enclosingDeclaration: Node, - typeResolver: TypeChecker, - location: Node) { + function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, + typeResolver: TypeChecker, location: Node, + // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location + semanticMeaning = getMeaningFromLocation(location)) { var displayParts: SymbolDisplayPart[] = []; var documentation: SymbolDisplayPart[]; - var symbolFlags = typeResolver.getRootSymbol(symbol).flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags); + var symbolFlags = typeResolver.getRootSymbols(symbol)[0].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 - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Signature || symbolFlags & SymbolFlags.Class) { + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Import) { // If it is accessor they are allowed only if location is at name of the accessor if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } - else if (symbol.name === "undefined") { - // undefined is symbol and not property - symbolKind = ScriptElementKind.variableElement; - } var type = typeResolver.getTypeOfSymbol(symbol); if (type) { @@ -2790,6 +2821,18 @@ module ts { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } + else if (symbolFlags & SymbolFlags.Import) { + symbolKind = ScriptElementKind.alias; + displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + displayParts.push(textPart(symbolKind)); + displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + displayParts.push(spacePart()); + if (useConstructSignatures) { + displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + displayParts.push(spacePart()); + } + addFullSymbolName(symbol); + } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } @@ -2847,45 +2890,44 @@ module ts { } } } - if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo) { displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); + addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if (symbolFlags & SymbolFlags.Interface) { + if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) { addNewLineIfDisplayPartsExist(); displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); + addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & SymbolFlags.Enum) { addNewLineIfDisplayPartsExist(); displayParts.push(keywordPart(SyntaxKind.EnumKeyword)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile)); + addFullSymbolName(symbol); } if (symbolFlags & SymbolFlags.Module) { addNewLineIfDisplayPartsExist(); displayParts.push(keywordPart(SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile)); + addFullSymbolName(symbol); } - if (symbolFlags & SymbolFlags.TypeParameter) { + if ((symbolFlags & SymbolFlags.TypeParameter) && (semanticMeaning & SemanticMeaning.Type)) { addNewLineIfDisplayPartsExist(); displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); displayParts.push(textPart("type parameter")); displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration)); + addFullSymbolName(symbol); displayParts.push(spacePart()); displayParts.push(keywordPart(SyntaxKind.InKeyword)); displayParts.push(spacePart()); if (symbol.parent) { // Class/Interface type parameter - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol.parent, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)) + addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { @@ -2897,7 +2939,7 @@ module ts { displayParts.push(spacePart()); } else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, signatureDeclaration.symbol, sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)) + addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); } @@ -2917,18 +2959,37 @@ module ts { } if (symbolFlags & SymbolFlags.Import) { addNewLineIfDisplayPartsExist(); - displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); - displayParts.push(textPart("alias")); - displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile)); + addFullSymbolName(symbol); + displayParts.push(spacePart()); + displayParts.push(punctuationPart(SyntaxKind.EqualsToken)); + displayParts.push(spacePart()); + ts.forEach(symbol.declarations, declaration => { + if (declaration.kind === SyntaxKind.ImportDeclaration) { + var importDeclaration = declaration; + if (importDeclaration.externalModuleName) { + displayParts.push(keywordPart(SyntaxKind.RequireKeyword)); + displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + } + else { + var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + return true; + } + }); } if (!hasAddedSymbolInfo) { if (symbolKind !== ScriptElementKind.unknown) { if (type) { addPrefixForAnyFunctionOrVar(symbol, symbolKind); + // For properties, variables and local vars: show the type if (symbolKind === ScriptElementKind.memberVariableElement || - symbolFlags & SymbolFlags.Variable) { + symbolFlags & SymbolFlags.Variable || + symbolKind === ScriptElementKind.localVariableElement) { displayParts.push(punctuationPart(SyntaxKind.ColonToken)); displayParts.push(spacePart()); // If the type is type parameter, format it specially @@ -2953,7 +3014,7 @@ module ts { } } else { - symbolKind = getSymbolKind(symbol); + symbolKind = getSymbolKind(symbol, typeResolver); } } @@ -2969,6 +3030,12 @@ module ts { } } + function addFullSymbolName(symbol: Symbol, enclosingDeclaration?: Node) { + var fullSymbolDisplayParts = symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, + SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing); + displayParts.push.apply(displayParts, fullSymbolDisplayParts); + } + function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) { addNewLineIfDisplayPartsExist(); if (symbolKind) { @@ -2976,8 +3043,7 @@ module ts { displayParts.push(textPart(symbolKind)); displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); displayParts.push(spacePart()); - // Write type parameters of class/Interface if it is property/method of the generic class/interface - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); + addFullSymbolName(symbol); } } @@ -3015,7 +3081,6 @@ module ts { var symbol = typeInfoResolver.getSymbolInfo(node); if (!symbol) { - // Try getting just type at this position and show switch (node.kind) { case SyntaxKind.Identifier: @@ -3023,7 +3088,7 @@ module ts { case SyntaxKind.QualifiedName: case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: - // For the identifiers/this/usper etc get the type at position + // For the identifiers/this/super etc get the type at position var type = typeInfoResolver.getTypeOfNode(node); if (type) { return { @@ -3050,7 +3115,7 @@ module ts { } /// Goto definition - function getDefinitionAtPosition(filename: string, position: number): DefinitionInfo[]{ + function getDefinitionAtPosition(filename: string, position: number): DefinitionInfo[] { function getDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { return { fileName: node.getSourceFile().filename, @@ -3082,7 +3147,7 @@ module ts { result.push(getDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); return true; } - + return false; } @@ -3146,7 +3211,7 @@ module ts { // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!symbol || !(symbol.getDeclarations())) { + if (!symbol) { return undefined; } @@ -3154,7 +3219,7 @@ module ts { var declarations = symbol.getDeclarations(); var symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - var symbolKind = getSymbolKind(symbol); + var symbolKind = getSymbolKind(symbol, typeInfoResolver); var containerSymbol = symbol.parent; var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : ""; @@ -3679,18 +3744,20 @@ module ts { return [getReferenceEntryFromNode(node)]; } - // the symbol was an internal symbol and does not have a declaration e.g.undefined symbol - if (!symbol.getDeclarations()) { + var declarations = symbol.declarations; + + // The symbol was an internal symbol and does not have a declaration e.g.undefined symbol + if (!declarations || !declarations.length) { return undefined; } var result: ReferenceEntry[]; // Compute the meaning from the location and the symbol it references - var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), symbol.getDeclarations()); + var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); // Get the text to search for, we need to normalize it as external module names will have quote - var symbolName = getNormalizedSymbolName(symbol); + var symbolName = getNormalizedSymbolName(symbol.name, declarations); // Get syntactic diagnostics var scope = getSymbolScope(symbol); @@ -3712,15 +3779,15 @@ module ts { return result; - function getNormalizedSymbolName(symbol: Symbol): string { + function getNormalizedSymbolName(symbolName: string, declarations: Declaration[]): string { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = getDeclarationOfKind(symbol, SyntaxKind.FunctionExpression); + var functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); if (functionExpression && functionExpression.name) { var name = functionExpression.name.text; } else { - var name = symbol.name; + var name = symbolName; } var length = name.length; @@ -3747,22 +3814,24 @@ module ts { var scope: Node = undefined; var declarations = symbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var container = getContainerNode(declarations[i]); + if (declarations) { + for (var i = 0, n = declarations.length; i < n; i++) { + var container = getContainerNode(declarations[i]); - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + + if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { + // This is a global variable and not an external module, any declaration defined + // within this scope is visible outside the file + return undefined; + } + + // The search scope is the container node + scope = container; } - - if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - // This is a global variable and not an external module, any declaration defined - // within this scope is visible outside the file - return undefined; - } - - // The search scope is the container node - scope = container; } return scope; @@ -3898,14 +3967,7 @@ module ts { } var referenceSymbol = typeInfoResolver.getSymbolInfo(referenceLocation); - - // Could not find a symbol e.g. node is string or number keyword, - // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!referenceSymbol || !(referenceSymbol.getDeclarations())) { - return; - } - - if (isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation)) { + if (referenceSymbol && isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation)) { result.push(getReferenceEntryFromNode(referenceLocation)); } }); @@ -4067,24 +4129,27 @@ module ts { // The search set contains at least the current symbol var result = [symbol]; - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - var rootSymbol = typeInfoResolver.getRootSymbol(symbol); - if (rootSymbol && rootSymbol !== symbol) { - result.push(rootSymbol); - } - // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set if (isNameOfPropertyAssignment(location)) { - var symbolFromContextualType = getPropertySymbolFromContextualType(location); - if (symbolFromContextualType) result.push(typeInfoResolver.getRootSymbol(symbolFromContextualType)); + forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => { + result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol)); + }); } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (symbol.parent && symbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(symbol.parent, symbol.getName(), result); - } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + } + }); return result; } @@ -4120,11 +4185,7 @@ module ts { } function isRelatableToSearchSet(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): boolean { - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - var referenceSymbolTarget = typeInfoResolver.getRootSymbol(referenceSymbol); - - // if it is in the list, then we are done - if (searchSymbols.indexOf(referenceSymbolTarget) >= 0) { + if (searchSymbols.indexOf(referenceSymbol) >= 0) { return true; } @@ -4132,29 +4193,61 @@ module ts { // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol if (isNameOfPropertyAssignment(referenceLocation)) { - var symbolFromContextualType = getPropertySymbolFromContextualType(referenceLocation); - if (symbolFromContextualType && searchSymbols.indexOf(typeInfoResolver.getRootSymbol(symbolFromContextualType)) >= 0) { + return forEach(getPropertySymbolsFromContextualType(referenceLocation), contextualSymbol => { + return forEach(typeInfoResolver.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0); + }); + } + + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return forEach(typeInfoResolver.getRootSymbols(referenceSymbol), rootSymbol => { + // if it is in the list, then we are done + if (searchSymbols.indexOf(rootSymbol) >= 0) { return true; } - } - // Finally, try all properties with the same name in any type the containing type extend or implemented, and - // see if any is in the list - if (referenceSymbol.parent && referenceSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - var result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(referenceSymbol.parent, referenceSymbol.getName(), result); - return forEach(result, s => searchSymbols.indexOf(s) >= 0); - } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + var result: Symbol[] = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + return forEach(result, s => searchSymbols.indexOf(s) >= 0); + } - return false; + return false; + }); } - function getPropertySymbolFromContextualType(node: Node): Symbol { + function getPropertySymbolsFromContextualType(node: Node): Symbol[] { if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); + var name = (node).text; if (contextualType) { - return typeInfoResolver.getPropertyOfType(contextualType, (node).text); + if (contextualType.flags & TypeFlags.Union) { + // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) + // if not, search the constituent types for the property + var unionProperty = contextualType.getProperty(name) + if (unionProperty) { + return [unionProperty]; + } + else { + var result: Symbol[] = []; + forEach((contextualType).types, t => { + var symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); + return result; + } + } + else { + var symbol = contextualType.getProperty(name); + if (symbol) { + return [symbol]; + } + } } } return undefined; @@ -4656,7 +4749,6 @@ module ts { function classifySymbol(symbol: Symbol, meaningAtPosition: SemanticMeaning) { var flags = symbol.getFlags(); - // TODO(drosen): use meaningAtPosition. if (flags & SymbolFlags.Class) { return ClassificationTypeNames.className; } @@ -4672,10 +4764,25 @@ module ts { } } else if (flags & SymbolFlags.Module) { - return ClassificationTypeNames.moduleName; + // Only classify a module as such if + // - It appears in a namespace context. + // - There exists a module declaration which actually impacts the value side. + if (meaningAtPosition & SemanticMeaning.Namespace || + (meaningAtPosition & SemanticMeaning.Value && hasValueSideModule(symbol))) { + return ClassificationTypeNames.moduleName; + } } return undefined; + + /** + * Returns true if there exists a module that introduces entities on the value side. + */ + function hasValueSideModule(symbol: Symbol): boolean { + return forEach(symbol.declarations, declaration => { + return declaration.kind === SyntaxKind.ModuleDeclaration && isInstantiated(declaration); + }); + } } function processNode(node: Node) { @@ -5145,7 +5252,7 @@ module ts { // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) { - var kind = getSymbolKind(symbol); + var kind = getSymbolKind(symbol, typeInfoResolver); if (kind) { return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getSymbolModifiers(symbol), diff --git a/src/services/syntax/syntaxTree.ts b/src/services/syntax/syntaxTree.ts index 1e8ac95c483..1c68350d918 100644 --- a/src/services/syntax/syntaxTree.ts +++ b/src/services/syntax/syntaxTree.ts @@ -84,7 +84,6 @@ module TypeScript { private cacheSyntaxTreeInfo(): void { // If we're not keeping around the syntax tree, store the diagnostics and line // map so they don't have to be recomputed. - var sourceUnit = this.sourceUnit(); var firstToken = firstSyntaxTreeToken(this); var leadingTrivia = firstToken.leadingTrivia(this.text); diff --git a/tests/baselines/reference/aliasUsageInArray.types b/tests/baselines/reference/aliasUsageInArray.types index df657233f90..2e792d39603 100644 --- a/tests/baselines/reference/aliasUsageInArray.types +++ b/tests/baselines/reference/aliasUsageInArray.types @@ -17,7 +17,7 @@ interface IHasVisualizationModel { var xs: IHasVisualizationModel[] = [moduleA]; >xs : IHasVisualizationModel[] >IHasVisualizationModel : IHasVisualizationModel ->[moduleA] : IHasVisualizationModel[] +>[moduleA] : typeof moduleA[] >moduleA : typeof moduleA var xs2: typeof moduleA[] = [moduleA]; diff --git a/tests/baselines/reference/aliasUsageInOrExpression.types b/tests/baselines/reference/aliasUsageInOrExpression.types index fdcf0be4479..c937187f049 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.types +++ b/tests/baselines/reference/aliasUsageInOrExpression.types @@ -53,7 +53,7 @@ var f: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null ? { x >f : { x: IHasVisualizationModel; } >x : IHasVisualizationModel >IHasVisualizationModel : IHasVisualizationModel -><{ x: IHasVisualizationModel }>null ? { x: moduleA } : null : { x: IHasVisualizationModel; } +><{ x: IHasVisualizationModel }>null ? { x: moduleA } : null : { x: typeof moduleA; } ><{ x: IHasVisualizationModel }>null : { x: IHasVisualizationModel; } >x : IHasVisualizationModel >IHasVisualizationModel : IHasVisualizationModel diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index 675d84119c0..f8e158e5b02 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -1,55 +1,109 @@ //// [arrayBestCommonTypes.ts] -interface iface { } -class base implements iface { } -class base2 implements iface { } -class derived extends base { } +module EmptyTypes { + interface iface { } + class base implements iface { } + class base2 implements iface { } + class derived extends base { } -class f { - public voidIfAny(x: boolean, y?: boolean): number; - public voidIfAny(x: string, y?: boolean): number; - public voidIfAny(x: number, y?: boolean): number; - public voidIfAny(x: any, y =false): any { return null; } - - public x() { - (this.voidIfAny([4, 2][0])); - (this.voidIfAny([4, 2, undefined][0])); - (this.voidIfAny([undefined, 2, 4][0])); - (this.voidIfAny([null, 2, 4][0])); - (this.voidIfAny([2, 4, null][0])); - (this.voidIfAny([undefined, 4, null][0])); + class f { + public voidIfAny(x: boolean, y?: boolean): number; + public voidIfAny(x: string, y?: boolean): number; + public voidIfAny(x: number, y?: boolean): number; + public voidIfAny(x: any, y = false): any { return null; } - (this.voidIfAny(['', "q"][0])); - (this.voidIfAny(['', "q", undefined][0])); - (this.voidIfAny([undefined, "q", ''][0])); - (this.voidIfAny([null, "q", ''][0])); - (this.voidIfAny(["q", '', null][0])); - (this.voidIfAny([undefined, '', null][0])); + public x() { + (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); - (this.voidIfAny([[3,4],[null]][0][0])); - - - var t1: { x: number; y: base; }[] = [ { x: 7, y: new derived() }, { x: 5, y: new base() } ]; - var t2: { x: boolean; y: base; }[] = [ { x: true, y: new derived() }, { x: false, y: new base() } ]; - var t3: { x: string; y: base; }[] = [ { x: undefined, y: new base() }, { x: '', y: new derived() } ]; + (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny([undefined, '', null][0])); - var anyObj: any = null; - // Order matters here so test all the variants - var a1 = [ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ]; - var a2 = [ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ]; - var a3 = [ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ]; - - var ifaceObj: iface = null; - var baseObj = new base(); - var base2Obj = new base2(); + (this.voidIfAny([[3, 4], [null]][0][0])); - var b1 = [ baseObj, base2Obj, ifaceObj ]; - var b2 = [ base2Obj, baseObj, ifaceObj ]; - var b3 = [ baseObj, ifaceObj, base2Obj ]; - var b4 = [ ifaceObj, baseObj, base2Obj ]; + + var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; + var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }]; + var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + + var anyObj: any = null; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + + var ifaceObj: iface = null; + var baseObj = new base(); + var base2Obj = new base2(); + + var b1 = [baseObj, base2Obj, ifaceObj]; + var b2 = [base2Obj, baseObj, ifaceObj]; + var b3 = [baseObj, ifaceObj, base2Obj]; + var b4 = [ifaceObj, baseObj, base2Obj]; + } } } +module NonEmptyTypes { + interface iface { x: string; } + class base implements iface { x: string; y: string; } + class base2 implements iface { x: string; z: string; } + class derived extends base { a: string; } + + + class f { + public voidIfAny(x: boolean, y?: boolean): number; + public voidIfAny(x: string, y?: boolean): number; + public voidIfAny(x: number, y?: boolean): number; + public voidIfAny(x: any, y = false): any { return null; } + + public x() { + (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); + + (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny([undefined, '', null][0])); + + (this.voidIfAny([[3, 4], [null]][0][0])); + + + var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; + var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }]; + var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + + var anyObj: any = null; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + + var ifaceObj: iface = null; + var baseObj = new base(); + var base2Obj = new base2(); + + var b1 = [baseObj, base2Obj, ifaceObj]; + var b2 = [base2Obj, baseObj, ifaceObj]; + var b3 = [baseObj, ifaceObj, base2Obj]; + var b4 = [ifaceObj, baseObj, base2Obj]; + } + } +} @@ -60,59 +114,121 @@ var __extends = this.__extends || function (d, b) { __.prototype = b.prototype; d.prototype = new __(); }; -var base = (function () { - function base() { - } - return base; -})(); -var base2 = (function () { - function base2() { - } - return base2; -})(); -var derived = (function (_super) { - __extends(derived, _super); - function derived() { - _super.apply(this, arguments); - } - return derived; -})(base); -var f = (function () { - function f() { - } - f.prototype.voidIfAny = function (x, y) { - if (y === void 0) { y = false; } - return null; - }; - f.prototype.x = function () { - (this.voidIfAny([4, 2][0])); - (this.voidIfAny([4, 2, undefined][0])); - (this.voidIfAny([undefined, 2, 4][0])); - (this.voidIfAny([null, 2, 4][0])); - (this.voidIfAny([2, 4, null][0])); - (this.voidIfAny([undefined, 4, null][0])); - (this.voidIfAny(['', "q"][0])); - (this.voidIfAny(['', "q", undefined][0])); - (this.voidIfAny([undefined, "q", ''][0])); - (this.voidIfAny([null, "q", ''][0])); - (this.voidIfAny(["q", '', null][0])); - (this.voidIfAny([undefined, '', null][0])); - (this.voidIfAny([[3, 4], [null]][0][0])); - var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; - var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }]; - var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; - var anyObj = null; - // Order matters here so test all the variants - var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; - var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; - var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; - var ifaceObj = null; - var baseObj = new base(); - var base2Obj = new base2(); - var b1 = [baseObj, base2Obj, ifaceObj]; - var b2 = [base2Obj, baseObj, ifaceObj]; - var b3 = [baseObj, ifaceObj, base2Obj]; - var b4 = [ifaceObj, baseObj, base2Obj]; - }; - return f; -})(); +var EmptyTypes; +(function (EmptyTypes) { + var base = (function () { + function base() { + } + return base; + })(); + var base2 = (function () { + function base2() { + } + return base2; + })(); + var derived = (function (_super) { + __extends(derived, _super); + function derived() { + _super.apply(this, arguments); + } + return derived; + })(base); + var f = (function () { + function f() { + } + f.prototype.voidIfAny = function (x, y) { + if (y === void 0) { y = false; } + return null; + }; + f.prototype.x = function () { + (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); + (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny([undefined, '', null][0])); + (this.voidIfAny([[3, 4], [null]][0][0])); + var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; + var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }]; + var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + var anyObj = null; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + var ifaceObj = null; + var baseObj = new base(); + var base2Obj = new base2(); + var b1 = [baseObj, base2Obj, ifaceObj]; + var b2 = [base2Obj, baseObj, ifaceObj]; + var b3 = [baseObj, ifaceObj, base2Obj]; + var b4 = [ifaceObj, baseObj, base2Obj]; + }; + return f; + })(); +})(EmptyTypes || (EmptyTypes = {})); +var NonEmptyTypes; +(function (NonEmptyTypes) { + var base = (function () { + function base() { + } + return base; + })(); + var base2 = (function () { + function base2() { + } + return base2; + })(); + var derived = (function (_super) { + __extends(derived, _super); + function derived() { + _super.apply(this, arguments); + } + return derived; + })(base); + var f = (function () { + function f() { + } + f.prototype.voidIfAny = function (x, y) { + if (y === void 0) { y = false; } + return null; + }; + f.prototype.x = function () { + (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); + (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny([undefined, '', null][0])); + (this.voidIfAny([[3, 4], [null]][0][0])); + var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; + var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }]; + var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + var anyObj = null; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + var ifaceObj = null; + var baseObj = new base(); + var base2Obj = new base2(); + var b1 = [baseObj, base2Obj, ifaceObj]; + var b2 = [base2Obj, baseObj, ifaceObj]; + var b3 = [baseObj, ifaceObj, base2Obj]; + var b4 = [ifaceObj, baseObj, base2Obj]; + }; + return f; + })(); +})(NonEmptyTypes || (NonEmptyTypes = {})); diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index a0f407358c3..c9d39d5c1e8 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -1,47 +1,50 @@ === tests/cases/compiler/arrayBestCommonTypes.ts === -interface iface { } +module EmptyTypes { +>EmptyTypes : typeof EmptyTypes + + interface iface { } >iface : iface -class base implements iface { } + class base implements iface { } >base : base >iface : iface -class base2 implements iface { } + class base2 implements iface { } >base2 : base2 >iface : iface -class derived extends base { } + class derived extends base { } >derived : derived >base : base -class f { + class f { >f : f - public voidIfAny(x: boolean, y?: boolean): number; + public voidIfAny(x: boolean, y?: boolean): number; >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >x : boolean >y : boolean - public voidIfAny(x: string, y?: boolean): number; + public voidIfAny(x: string, y?: boolean): number; >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >x : string >y : boolean - public voidIfAny(x: number, y?: boolean): number; + public voidIfAny(x: number, y?: boolean): number; >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >x : number >y : boolean - public voidIfAny(x: any, y =false): any { return null; } + public voidIfAny(x: any, y = false): any { return null; } >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >x : any >y : boolean - - public x() { + + public x() { >x : () => void - (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2][0])); >(this.voidIfAny([4, 2][0])) : number >(this.voidIfAny([4, 2][0])) : number >this.voidIfAny([4, 2][0]) : number @@ -51,7 +54,7 @@ class f { >[4, 2][0] : number >[4, 2] : number[] - (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([4, 2, undefined][0])); >(this.voidIfAny([4, 2, undefined][0])) : number >(this.voidIfAny([4, 2, undefined][0])) : number >this.voidIfAny([4, 2, undefined][0]) : number @@ -62,7 +65,7 @@ class f { >[4, 2, undefined] : number[] >undefined : undefined - (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([undefined, 2, 4][0])); >(this.voidIfAny([undefined, 2, 4][0])) : number >(this.voidIfAny([undefined, 2, 4][0])) : number >this.voidIfAny([undefined, 2, 4][0]) : number @@ -73,7 +76,7 @@ class f { >[undefined, 2, 4] : number[] >undefined : undefined - (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); >(this.voidIfAny([null, 2, 4][0])) : number >(this.voidIfAny([null, 2, 4][0])) : number >this.voidIfAny([null, 2, 4][0]) : number @@ -83,7 +86,7 @@ class f { >[null, 2, 4][0] : number >[null, 2, 4] : number[] - (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([2, 4, null][0])); >(this.voidIfAny([2, 4, null][0])) : number >(this.voidIfAny([2, 4, null][0])) : number >this.voidIfAny([2, 4, null][0]) : number @@ -93,7 +96,7 @@ class f { >[2, 4, null][0] : number >[2, 4, null] : number[] - (this.voidIfAny([undefined, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); >(this.voidIfAny([undefined, 4, null][0])) : number >(this.voidIfAny([undefined, 4, null][0])) : number >this.voidIfAny([undefined, 4, null][0]) : number @@ -104,7 +107,7 @@ class f { >[undefined, 4, null] : number[] >undefined : undefined - (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q"][0])); >(this.voidIfAny(['', "q"][0])) : number >(this.voidIfAny(['', "q"][0])) : number >this.voidIfAny(['', "q"][0]) : number @@ -114,7 +117,7 @@ class f { >['', "q"][0] : string >['', "q"] : string[] - (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny(['', "q", undefined][0])); >(this.voidIfAny(['', "q", undefined][0])) : number >(this.voidIfAny(['', "q", undefined][0])) : number >this.voidIfAny(['', "q", undefined][0]) : number @@ -125,7 +128,7 @@ class f { >['', "q", undefined] : string[] >undefined : undefined - (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([undefined, "q", ''][0])); >(this.voidIfAny([undefined, "q", ''][0])) : number >(this.voidIfAny([undefined, "q", ''][0])) : number >this.voidIfAny([undefined, "q", ''][0]) : number @@ -136,7 +139,7 @@ class f { >[undefined, "q", ''] : string[] >undefined : undefined - (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); >(this.voidIfAny([null, "q", ''][0])) : number >(this.voidIfAny([null, "q", ''][0])) : number >this.voidIfAny([null, "q", ''][0]) : number @@ -146,7 +149,7 @@ class f { >[null, "q", ''][0] : string >[null, "q", ''] : string[] - (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny(["q", '', null][0])); >(this.voidIfAny(["q", '', null][0])) : number >(this.voidIfAny(["q", '', null][0])) : number >this.voidIfAny(["q", '', null][0]) : number @@ -156,7 +159,7 @@ class f { >["q", '', null][0] : string >["q", '', null] : string[] - (this.voidIfAny([undefined, '', null][0])); + (this.voidIfAny([undefined, '', null][0])); >(this.voidIfAny([undefined, '', null][0])) : number >(this.voidIfAny([undefined, '', null][0])) : number >this.voidIfAny([undefined, '', null][0]) : number @@ -167,26 +170,26 @@ class f { >[undefined, '', null] : string[] >undefined : undefined - (this.voidIfAny([[3,4],[null]][0][0])); ->(this.voidIfAny([[3,4],[null]][0][0])) : number ->(this.voidIfAny([[3,4],[null]][0][0])) : number ->this.voidIfAny([[3,4],[null]][0][0]) : number + (this.voidIfAny([[3, 4], [null]][0][0])); +>(this.voidIfAny([[3, 4], [null]][0][0])) : number +>(this.voidIfAny([[3, 4], [null]][0][0])) : number +>this.voidIfAny([[3, 4], [null]][0][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >this : f >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->[[3,4],[null]][0][0] : number ->[[3,4],[null]][0] : number[] ->[[3,4],[null]] : number[][] ->[3,4] : number[] +>[[3, 4], [null]][0][0] : number +>[[3, 4], [null]][0] : number[] +>[[3, 4], [null]] : number[][] +>[3, 4] : number[] >[null] : null[] - - - var t1: { x: number; y: base; }[] = [ { x: 7, y: new derived() }, { x: 5, y: new base() } ]; + + + var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; >t1 : { x: number; y: base; }[] >x : number >y : base >base : base ->[ { x: 7, y: new derived() }, { x: 5, y: new base() } ] : { x: number; y: base; }[] +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: derived; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number >y : derived @@ -198,12 +201,12 @@ class f { >new base() : base >base : typeof base - var t2: { x: boolean; y: base; }[] = [ { x: true, y: new derived() }, { x: false, y: new base() } ]; + var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }]; >t2 : { x: boolean; y: base; }[] >x : boolean >y : base >base : base ->[ { x: true, y: new derived() }, { x: false, y: new base() } ] : { x: boolean; y: base; }[] +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: derived; }[] >{ x: true, y: new derived() } : { x: boolean; y: derived; } >x : boolean >y : derived @@ -215,12 +218,12 @@ class f { >new base() : base >base : typeof base - var t3: { x: string; y: base; }[] = [ { x: undefined, y: new base() }, { x: '', y: new derived() } ]; + var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; >t3 : { x: string; y: base; }[] >x : string >y : base >base : base ->[ { x: undefined, y: new base() }, { x: '', y: new derived() } ] : { x: string; y: base; }[] +>[{ x: undefined, y: new base() }, { x: '', y: new derived() }] : { x: string; y: derived; }[] >{ x: undefined, y: new base() } : { x: undefined; y: base; } >x : undefined >undefined : undefined @@ -233,95 +236,429 @@ class f { >new derived() : derived >derived : typeof derived - var anyObj: any = null; + var anyObj: any = null; >anyObj : any - // Order matters here so test all the variants - var a1 = [ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ]; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; >a1 : { x: any; y: string; }[] ->[ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ] : { x: any; y: string; }[] ->{x: 0, y: 'a'} : { x: number; y: string; } +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] +>{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >y : string ->{x: 'a', y: 'a'} : { x: string; y: string; } +>{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string >y : string ->{x: anyObj, y: 'a'} : { x: any; y: string; } +>{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string - var a2 = [ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; >a2 : { x: any; y: string; }[] ->[ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ] : { x: any; y: string; }[] ->{x: anyObj, y: 'a'} : { x: any; y: string; } +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string ->{x: 0, y: 'a'} : { x: number; y: string; } +>{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >y : string ->{x: 'a', y: 'a'} : { x: string; y: string; } +>{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string >y : string - var a3 = [ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; >a3 : { x: any; y: string; }[] ->[ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ] : { x: any; y: string; }[] ->{x: 0, y: 'a'} : { x: number; y: string; } +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >y : string ->{x: anyObj, y: 'a'} : { x: any; y: string; } +>{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string ->{x: 'a', y: 'a'} : { x: string; y: string; } +>{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string >y : string - - var ifaceObj: iface = null; + + var ifaceObj: iface = null; >ifaceObj : iface >iface : iface - var baseObj = new base(); + var baseObj = new base(); >baseObj : base >new base() : base >base : typeof base - var base2Obj = new base2(); + var base2Obj = new base2(); >base2Obj : base2 >new base2() : base2 >base2 : typeof base2 - var b1 = [ baseObj, base2Obj, ifaceObj ]; ->b1 : base[] ->[ baseObj, base2Obj, ifaceObj ] : base[] + var b1 = [baseObj, base2Obj, ifaceObj]; +>b1 : iface[] +>[baseObj, base2Obj, ifaceObj] : iface[] >baseObj : base >base2Obj : base2 >ifaceObj : iface - var b2 = [ base2Obj, baseObj, ifaceObj ]; ->b2 : base2[] ->[ base2Obj, baseObj, ifaceObj ] : base2[] + var b2 = [base2Obj, baseObj, ifaceObj]; +>b2 : iface[] +>[base2Obj, baseObj, ifaceObj] : iface[] >base2Obj : base2 >baseObj : base >ifaceObj : iface - var b3 = [ baseObj, ifaceObj, base2Obj ]; ->b3 : base[] ->[ baseObj, ifaceObj, base2Obj ] : base[] + var b3 = [baseObj, ifaceObj, base2Obj]; +>b3 : iface[] +>[baseObj, ifaceObj, base2Obj] : iface[] >baseObj : base >ifaceObj : iface >base2Obj : base2 - var b4 = [ ifaceObj, baseObj, base2Obj ]; + var b4 = [ifaceObj, baseObj, base2Obj]; >b4 : iface[] ->[ ifaceObj, baseObj, base2Obj ] : iface[] +>[ifaceObj, baseObj, base2Obj] : iface[] >ifaceObj : iface >baseObj : base >base2Obj : base2 + } + } +} + +module NonEmptyTypes { +>NonEmptyTypes : typeof NonEmptyTypes + + interface iface { x: string; } +>iface : iface +>x : string + + class base implements iface { x: string; y: string; } +>base : base +>iface : iface +>x : string +>y : string + + class base2 implements iface { x: string; z: string; } +>base2 : base2 +>iface : iface +>x : string +>z : string + + class derived extends base { a: string; } +>derived : derived +>base : base +>a : string + + + class f { +>f : f + + public voidIfAny(x: boolean, y?: boolean): number; +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>x : boolean +>y : boolean + + public voidIfAny(x: string, y?: boolean): number; +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>x : string +>y : boolean + + public voidIfAny(x: number, y?: boolean): number; +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>x : number +>y : boolean + + public voidIfAny(x: any, y = false): any { return null; } +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>x : any +>y : boolean + + public x() { +>x : () => void + + (this.voidIfAny([4, 2][0])); +>(this.voidIfAny([4, 2][0])) : number +>(this.voidIfAny([4, 2][0])) : number +>this.voidIfAny([4, 2][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[4, 2][0] : number +>[4, 2] : number[] + + (this.voidIfAny([4, 2, undefined][0])); +>(this.voidIfAny([4, 2, undefined][0])) : number +>(this.voidIfAny([4, 2, undefined][0])) : number +>this.voidIfAny([4, 2, undefined][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[4, 2, undefined][0] : number +>[4, 2, undefined] : number[] +>undefined : undefined + + (this.voidIfAny([undefined, 2, 4][0])); +>(this.voidIfAny([undefined, 2, 4][0])) : number +>(this.voidIfAny([undefined, 2, 4][0])) : number +>this.voidIfAny([undefined, 2, 4][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[undefined, 2, 4][0] : number +>[undefined, 2, 4] : number[] +>undefined : undefined + + (this.voidIfAny([null, 2, 4][0])); +>(this.voidIfAny([null, 2, 4][0])) : number +>(this.voidIfAny([null, 2, 4][0])) : number +>this.voidIfAny([null, 2, 4][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[null, 2, 4][0] : number +>[null, 2, 4] : number[] + + (this.voidIfAny([2, 4, null][0])); +>(this.voidIfAny([2, 4, null][0])) : number +>(this.voidIfAny([2, 4, null][0])) : number +>this.voidIfAny([2, 4, null][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[2, 4, null][0] : number +>[2, 4, null] : number[] + + (this.voidIfAny([undefined, 4, null][0])); +>(this.voidIfAny([undefined, 4, null][0])) : number +>(this.voidIfAny([undefined, 4, null][0])) : number +>this.voidIfAny([undefined, 4, null][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[undefined, 4, null][0] : number +>[undefined, 4, null] : number[] +>undefined : undefined + + (this.voidIfAny(['', "q"][0])); +>(this.voidIfAny(['', "q"][0])) : number +>(this.voidIfAny(['', "q"][0])) : number +>this.voidIfAny(['', "q"][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>['', "q"][0] : string +>['', "q"] : string[] + + (this.voidIfAny(['', "q", undefined][0])); +>(this.voidIfAny(['', "q", undefined][0])) : number +>(this.voidIfAny(['', "q", undefined][0])) : number +>this.voidIfAny(['', "q", undefined][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>['', "q", undefined][0] : string +>['', "q", undefined] : string[] +>undefined : undefined + + (this.voidIfAny([undefined, "q", ''][0])); +>(this.voidIfAny([undefined, "q", ''][0])) : number +>(this.voidIfAny([undefined, "q", ''][0])) : number +>this.voidIfAny([undefined, "q", ''][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[undefined, "q", ''][0] : string +>[undefined, "q", ''] : string[] +>undefined : undefined + + (this.voidIfAny([null, "q", ''][0])); +>(this.voidIfAny([null, "q", ''][0])) : number +>(this.voidIfAny([null, "q", ''][0])) : number +>this.voidIfAny([null, "q", ''][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[null, "q", ''][0] : string +>[null, "q", ''] : string[] + + (this.voidIfAny(["q", '', null][0])); +>(this.voidIfAny(["q", '', null][0])) : number +>(this.voidIfAny(["q", '', null][0])) : number +>this.voidIfAny(["q", '', null][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>["q", '', null][0] : string +>["q", '', null] : string[] + + (this.voidIfAny([undefined, '', null][0])); +>(this.voidIfAny([undefined, '', null][0])) : number +>(this.voidIfAny([undefined, '', null][0])) : number +>this.voidIfAny([undefined, '', null][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[undefined, '', null][0] : string +>[undefined, '', null] : string[] +>undefined : undefined + + (this.voidIfAny([[3, 4], [null]][0][0])); +>(this.voidIfAny([[3, 4], [null]][0][0])) : number +>(this.voidIfAny([[3, 4], [null]][0][0])) : number +>this.voidIfAny([[3, 4], [null]][0][0]) : number +>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>this : f +>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } +>[[3, 4], [null]][0][0] : number +>[[3, 4], [null]][0] : number[] +>[[3, 4], [null]] : number[][] +>[3, 4] : number[] +>[null] : null[] + + + var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; +>t1 : { x: number; y: base; }[] +>x : number +>y : base +>base : base +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] +>{ x: 7, y: new derived() } : { x: number; y: derived; } +>x : number +>y : derived +>new derived() : derived +>derived : typeof derived +>{ x: 5, y: new base() } : { x: number; y: base; } +>x : number +>y : base +>new base() : base +>base : typeof base + + var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }]; +>t2 : { x: boolean; y: base; }[] +>x : boolean +>y : base +>base : base +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] +>{ x: true, y: new derived() } : { x: boolean; y: derived; } +>x : boolean +>y : derived +>new derived() : derived +>derived : typeof derived +>{ x: false, y: new base() } : { x: boolean; y: base; } +>x : boolean +>y : base +>new base() : base +>base : typeof base + + var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; +>t3 : { x: string; y: base; }[] +>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: undefined; y: base; } +>x : undefined +>undefined : undefined +>y : base +>new base() : base +>base : typeof base +>{ x: '', y: new derived() } : { x: string; y: derived; } +>x : string +>y : derived +>new derived() : derived +>derived : typeof derived + + var anyObj: any = null; +>anyObj : any + + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] +>{ x: 0, y: 'a' } : { x: number; y: string; } +>x : number +>y : string +>{ x: 'a', y: 'a' } : { x: string; y: string; } +>x : string +>y : string +>{ x: anyObj, y: 'a' } : { x: any; y: string; } +>x : any +>anyObj : any +>y : string + + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>{ x: anyObj, y: 'a' } : { x: any; y: string; } +>x : any +>anyObj : any +>y : string +>{ x: 0, y: 'a' } : { x: number; y: string; } +>x : number +>y : string +>{ x: 'a', y: 'a' } : { x: string; y: string; } +>x : string +>y : string + + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>{ x: 0, y: 'a' } : { x: number; y: string; } +>x : number +>y : string +>{ x: anyObj, y: 'a' } : { x: any; y: string; } +>x : any +>anyObj : any +>y : string +>{ x: 'a', y: 'a' } : { x: string; y: string; } +>x : string +>y : string + + var ifaceObj: iface = null; +>ifaceObj : iface +>iface : iface + + var baseObj = new base(); +>baseObj : base +>new base() : base +>base : typeof base + + var base2Obj = new base2(); +>base2Obj : base2 +>new base2() : base2 +>base2 : typeof base2 + + var b1 = [baseObj, base2Obj, ifaceObj]; +>b1 : iface[] +>[baseObj, base2Obj, ifaceObj] : iface[] +>baseObj : base +>base2Obj : base2 +>ifaceObj : iface + + var b2 = [base2Obj, baseObj, ifaceObj]; +>b2 : iface[] +>[base2Obj, baseObj, ifaceObj] : iface[] +>base2Obj : base2 +>baseObj : base +>ifaceObj : iface + + var b3 = [baseObj, ifaceObj, base2Obj]; +>b3 : iface[] +>[baseObj, ifaceObj, base2Obj] : iface[] +>baseObj : base +>ifaceObj : iface +>base2Obj : base2 + + var b4 = [ifaceObj, baseObj, base2Obj]; +>b4 : iface[] +>[ifaceObj, baseObj, base2Obj] : iface[] +>ifaceObj : iface +>baseObj : base +>base2Obj : base2 + } } } - diff --git a/tests/baselines/reference/arrayConcat2.types b/tests/baselines/reference/arrayConcat2.types index a4036560305..4cd02d31f9d 100644 --- a/tests/baselines/reference/arrayConcat2.types +++ b/tests/baselines/reference/arrayConcat2.types @@ -1,7 +1,7 @@ === tests/cases/compiler/arrayConcat2.ts === var a: string[] = []; >a : string[] ->[] : string[] +>[] : undefined[] a.concat("hello", 'world'); >a.concat("hello", 'world') : string[] diff --git a/tests/baselines/reference/arrayLiteral.types b/tests/baselines/reference/arrayLiteral.types index 1b356773dc7..9378a508228 100644 --- a/tests/baselines/reference/arrayLiteral.types +++ b/tests/baselines/reference/arrayLiteral.types @@ -25,7 +25,7 @@ var y = new Array(); var x2: number[] = []; >x2 : number[] ->[] : number[] +>[] : undefined[] var x2: number[] = new Array(1); >x2 : number[] diff --git a/tests/baselines/reference/arrayLiteralContextualType.errors.txt b/tests/baselines/reference/arrayLiteralContextualType.errors.txt deleted file mode 100644 index 5f661647d9f..00000000000 --- a/tests/baselines/reference/arrayLiteralContextualType.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/compiler/arrayLiteralContextualType.ts(28,5): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'IAnimal[]'. - Type '{}' is not assignable to type 'IAnimal'. -tests/cases/compiler/arrayLiteralContextualType.ts(29,5): error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ [x: number]: IAnimal; }'. - - -==== tests/cases/compiler/arrayLiteralContextualType.ts (2 errors) ==== - interface IAnimal { - name: string; - } - - class Giraffe { - name = "Giraffe"; - neckLength = "3m"; - } - - class Elephant { - name = "Elephant"; - trunkDiameter = "20cm"; - } - - function foo(animals: IAnimal[]) { } - function bar(animals: { [n: number]: IAnimal }) { } - - foo([ - new Giraffe(), - new Elephant() - ]); // Legal because of the contextual type IAnimal provided by the parameter - bar([ - new Giraffe(), - new Elephant() - ]); // Legal because of the contextual type IAnimal provided by the parameter - - var arr = [new Giraffe(), new Elephant()]; - foo(arr); // Error because of no contextual type - ~~~ -!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'IAnimal[]'. -!!! error TS2345: Type '{}' is not assignable to type 'IAnimal'. - bar(arr); // Error because of no contextual type - ~~~ -!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ [x: number]: IAnimal; }'. \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiteralContextualType.js b/tests/baselines/reference/arrayLiteralContextualType.js index a551a754204..65e4c135cba 100644 --- a/tests/baselines/reference/arrayLiteralContextualType.js +++ b/tests/baselines/reference/arrayLiteralContextualType.js @@ -26,8 +26,8 @@ bar([ ]); // Legal because of the contextual type IAnimal provided by the parameter var arr = [new Giraffe(), new Elephant()]; -foo(arr); // Error because of no contextual type -bar(arr); // Error because of no contextual type +foo(arr); // ok because arr is Array not {}[] +bar(arr); // ok because arr is Array not {}[] //// [arrayLiteralContextualType.js] var Giraffe = (function () { @@ -57,5 +57,5 @@ bar([ new Elephant() ]); // Legal because of the contextual type IAnimal provided by the parameter var arr = [new Giraffe(), new Elephant()]; -foo(arr); // Error because of no contextual type -bar(arr); // Error because of no contextual type +foo(arr); // ok because arr is Array not {}[] +bar(arr); // ok because arr is Array not {}[] diff --git a/tests/baselines/reference/arrayLiteralContextualType.types b/tests/baselines/reference/arrayLiteralContextualType.types new file mode 100644 index 00000000000..12d08e986f7 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralContextualType.types @@ -0,0 +1,86 @@ +=== tests/cases/compiler/arrayLiteralContextualType.ts === +interface IAnimal { +>IAnimal : IAnimal + + name: string; +>name : string +} + +class Giraffe { +>Giraffe : Giraffe + + name = "Giraffe"; +>name : string + + neckLength = "3m"; +>neckLength : string +} + +class Elephant { +>Elephant : Elephant + + name = "Elephant"; +>name : string + + trunkDiameter = "20cm"; +>trunkDiameter : string +} + +function foo(animals: IAnimal[]) { } +>foo : (animals: IAnimal[]) => void +>animals : IAnimal[] +>IAnimal : IAnimal + +function bar(animals: { [n: number]: IAnimal }) { } +>bar : (animals: { [x: number]: IAnimal; }) => void +>animals : { [x: number]: IAnimal; } +>n : number +>IAnimal : IAnimal + +foo([ +>foo([ new Giraffe(), new Elephant()]) : void +>foo : (animals: IAnimal[]) => void +>[ new Giraffe(), new Elephant()] : Array + + new Giraffe(), +>new Giraffe() : Giraffe +>Giraffe : typeof Giraffe + + new Elephant() +>new Elephant() : Elephant +>Elephant : typeof Elephant + +]); // Legal because of the contextual type IAnimal provided by the parameter +bar([ +>bar([ new Giraffe(), new Elephant()]) : void +>bar : (animals: { [x: number]: IAnimal; }) => void +>[ new Giraffe(), new Elephant()] : Array + + new Giraffe(), +>new Giraffe() : Giraffe +>Giraffe : typeof Giraffe + + new Elephant() +>new Elephant() : Elephant +>Elephant : typeof Elephant + +]); // Legal because of the contextual type IAnimal provided by the parameter + +var arr = [new Giraffe(), new Elephant()]; +>arr : Array +>[new Giraffe(), new Elephant()] : Array +>new Giraffe() : Giraffe +>Giraffe : typeof Giraffe +>new Elephant() : Elephant +>Elephant : typeof Elephant + +foo(arr); // ok because arr is Array not {}[] +>foo(arr) : void +>foo : (animals: IAnimal[]) => void +>arr : Array + +bar(arr); // ok because arr is Array not {}[] +>bar(arr) : void +>bar : (animals: { [x: number]: IAnimal; }) => void +>arr : Array + diff --git a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types index c4889e223bb..4743504c33e 100644 --- a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types +++ b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types @@ -7,5 +7,5 @@ function panic(val: string[], ...opt: string[]) { } panic([], 'one', 'two'); >panic([], 'one', 'two') : void >panic : (val: string[], ...opt: string[]) => void ->[] : string[] +>[] : undefined[] diff --git a/tests/baselines/reference/arrayLiteralTypeInference.types b/tests/baselines/reference/arrayLiteralTypeInference.types index 5b4d9b7fff8..c80e5e17030 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" }] : Action[] +>[ { id: 2, trueness: false }, { id: 3, name: "three" }] : Array<{ 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()] : Action[] +>[ new ActionA(), new ActionB()] : Array new ActionA(), >new ActionA() : ActionA @@ -78,7 +78,7 @@ var z1: { id: number }[] = >id : number [ ->[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : { id: number; }[] +>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : Array<{ 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() ] : { id: number; }[] +>[ new ActionA(), new ActionB() ] : Array new ActionA(), >new ActionA() : ActionA @@ -114,7 +114,7 @@ var z3: { id: number }[] = >id : number [ ->[ new Action(), new ActionA(), new ActionB() ] : { id: number; }[] +>[ new Action(), new ActionA(), new ActionB() ] : Action[] new Action(), >new Action() : Action diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 7729b280160..49b65a86aa6 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -23,8 +23,8 @@ var as = [a, b]; // { x: number; y?: number };[] >b : { x: number; z?: number; } var bs = [b, a]; // { x: number; z?: number };[] ->bs : { x: number; z?: number; }[] ->[b, a] : { x: number; z?: number; }[] +>bs : { x: number; y?: number; }[] +>[b, a] : { x: number; y?: number; }[] >b : { x: number; z?: number; } >a : { x: number; y?: number; } diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index 800d2a12550..16e5ec7eee4 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -2,28 +2,21 @@ // Empty array literal with no contextual type has type Undefined[] var arr1= [[], [1], ['']]; -var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK var arr2 = [[null], [1], ['']]; -var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK // Array literal with elements of only EveryType E has type E[] var stringArrArr = [[''], [""]]; -var stringArrArr: string[][]; var stringArr = ['', ""]; -var stringArr: string[]; var numberArr = [0, 0.0, 0x00, 1e1]; -var numberArr: number[]; var boolArr = [false, true, false, true]; -var boolArr: boolean[]; class C { private p; } var classArr = [new C(), new C()]; -var classArr: C[]; // Should be OK var classTypeArray = [C, C, C]; var classTypeArray: Array; // Should OK, not be a parse error @@ -31,7 +24,6 @@ var classTypeArray: Array; // Should OK, not be a parse error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; -var context2: Array<{}>; // Should be OK // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] class Base { private p; } @@ -53,31 +45,23 @@ var __extends = this.__extends || function (d, b) { d.prototype = new __(); }; var arr1 = [[], [1], ['']]; -var arr1; // Bug 825172: Error ({}[] does not match {}[]), but should be OK var arr2 = [[null], [1], ['']]; -var arr2; // Bug 825172: Error ({}[] does not match {}[]), but should be OK // Array literal with elements of only EveryType E has type E[] var stringArrArr = [[''], [""]]; -var stringArrArr; var stringArr = ['', ""]; -var stringArr; var numberArr = [0, 0.0, 0x00, 1e1]; -var numberArr; var boolArr = [false, true, false, true]; -var boolArr; var C = (function () { function C() { } return C; })(); var classArr = [new C(), new C()]; -var classArr; // Should be OK var classTypeArray = [C, C, C]; var classTypeArray; // Should OK, not be a parse error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; -var context2; // Should be OK // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] var Base = (function () { function Base() { diff --git a/tests/baselines/reference/arrayLiterals.types b/tests/baselines/reference/arrayLiterals.types index 29dd1b19970..8c2fd942c62 100644 --- a/tests/baselines/reference/arrayLiterals.types +++ b/tests/baselines/reference/arrayLiterals.types @@ -2,25 +2,19 @@ // Empty array literal with no contextual type has type Undefined[] var arr1= [[], [1], ['']]; ->arr1 : {}[] ->[[], [1], ['']] : {}[] +>arr1 : Array +>[[], [1], ['']] : Array >[] : undefined[] >[1] : number[] >[''] : string[] -var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK ->arr1 : {}[] - var arr2 = [[null], [1], ['']]; ->arr2 : {}[] ->[[null], [1], ['']] : {}[] +>arr2 : Array +>[[null], [1], ['']] : Array >[null] : null[] >[1] : number[] >[''] : string[] -var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK ->arr2 : {}[] - // Array literal with elements of only EveryType E has type E[] var stringArrArr = [[''], [""]]; @@ -29,30 +23,18 @@ var stringArrArr = [[''], [""]]; >[''] : string[] >[""] : string[] -var stringArrArr: string[][]; ->stringArrArr : string[][] - var stringArr = ['', ""]; >stringArr : string[] >['', ""] : string[] -var stringArr: string[]; ->stringArr : string[] - var numberArr = [0, 0.0, 0x00, 1e1]; >numberArr : number[] >[0, 0.0, 0x00, 1e1] : number[] -var numberArr: number[]; ->numberArr : number[] - var boolArr = [false, true, false, true]; >boolArr : boolean[] >[false, true, false, true] : boolean[] -var boolArr: boolean[]; ->boolArr : boolean[] - class C { private p; } >C : C >p : any @@ -65,10 +47,6 @@ var classArr = [new C(), new C()]; >new C() : C >C : typeof C -var classArr: C[]; // Should be OK ->classArr : C[] ->C : C - var classTypeArray = [C, C, C]; >classTypeArray : typeof C[] >[C, C, C] : typeof C[] @@ -87,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 }] : { 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: string; b: number; c: string; } >a : string >b : number @@ -98,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 : {}[] ->[{ 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; }> >{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } >a : string >b : number @@ -109,10 +87,6 @@ var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; >b : number >c : number -var context2: Array<{}>; // Should be OK ->context2 : {}[] ->Array : T[] - // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] class Base { private p; } >Base : Base @@ -131,7 +105,7 @@ class Derived2 extends Base { private n }; var context3: Base[] = [new Derived1(), new Derived2()]; >context3 : Base[] >Base : Base ->[new Derived1(), new Derived2()] : Base[] +>[new Derived1(), new Derived2()] : Array >new Derived1() : Derived1 >Derived1 : typeof Derived1 >new Derived2() : Derived2 @@ -141,7 +115,7 @@ var context3: Base[] = [new Derived1(), new Derived2()]; var context4: Base[] = [new Derived1(), new Derived1()]; >context4 : Base[] >Base : Base ->[new Derived1(), new Derived1()] : Base[] +>[new Derived1(), new Derived1()] : Derived1[] >new Derived1() : Derived1 >Derived1 : typeof Derived1 >new Derived1() : Derived1 diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index becff7617b7..e99ca18673e 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 : {}[] ->[list, list2] : {}[] +>ys : Array | List> +>[list, list2] : Array | List> >list : List >list2 : List diff --git a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt index 38d89bdbd78..2395f2bf364 100644 --- a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt +++ b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(17,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]': Types of property 'pop' are incompatible: - Type '() => {}' is not assignable to type '() => number': - Type '{}' is not assignable to type 'number'. + Type '() => string | number' is not assignable to type '() => number': + Type 'string | number' is not assignable to type 'number': + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(18,1): error TS2322: Type '{}[]' is not assignable to type '[{}]': Property '0' is missing in type '{}[]'. @@ -27,8 +28,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type 'number[]': !!! error TS2322: Types of property 'pop' are incompatible: -!!! error TS2322: Type '() => {}' is not assignable to type '() => number': -!!! error TS2322: Type '{}' is not assignable to type 'number'. +!!! error TS2322: Type '() => string | number' is not assignable to type '() => number': +!!! error TS2322: Type 'string | number' is not assignable to type 'number': +!!! error TS2322: Type 'string' is not assignable to type 'number'. emptyObjTuple = emptyObjArray; ~~~~~~~~~~~~~ !!! error TS2322: Type '{}[]' is not assignable to type '[{}]': diff --git a/tests/baselines/reference/badOverloadError.types b/tests/baselines/reference/badOverloadError.types index 837eb5c5c83..ba9d6e76c1c 100644 --- a/tests/baselines/reference/badOverloadError.types +++ b/tests/baselines/reference/badOverloadError.types @@ -6,6 +6,6 @@ function method() { >dictionary : { [x: string]: string; } ><{ [index: string]: string; }>{} : { [x: string]: string; } >index : string ->{} : { [x: string]: string; } +>{} : { [x: string]: undefined; } } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 3deeae69bbe..2c3ba8bc7c7 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -54,8 +54,8 @@ var r4 = true ? a : b; // typeof a >b : { x: number; z?: number; } var r5 = true ? b : a; // typeof b ->r5 : { x: number; z?: number; } ->true ? b : a : { x: number; z?: number; } +>r5 : { x: number; y?: number; } +>true ? b : a : { x: number; y?: number; } >b : { x: number; z?: number; } >a : { x: number; y?: number; } @@ -72,7 +72,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >r7 : (x: Object) => void >x : Object >Object : Object ->true ? (x: number) => { } : (x: Object) => { } : (x: Object) => void +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >(x: number) => { } : (x: number) => void >x : number >(x: Object) => { } : (x: Object) => void @@ -91,7 +91,7 @@ var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => vo var r10: Base = true ? derived : derived2; // no error since we use the contextual type in BCT >r10 : Base >Base : Base ->true ? derived : derived2 : Base +>true ? derived : derived2 : Derived | Derived2 >derived : Derived >derived2 : Derived2 @@ -112,7 +112,7 @@ function foo5(t: T, u: U): Object { >Object : Object return true ? t : u; // BCT is Object ->true ? t : u : Object +>true ? t : u : T | U >t : T >u : U } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt index 532a40becd9..83f4678c8f3 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt @@ -1,14 +1,9 @@ -tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(11,10): error TS2367: No best common type exists between 'number' and 'string'. -tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(12,10): error TS2367: No best common type exists between 'Derived' and 'Derived2'. -tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(15,12): error TS2367: No best common type exists between 'T' and 'U'. tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(18,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(19,12): error TS2367: No best common type exists between 'T' and 'U'. tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,28): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(23,12): error TS2367: No best common type exists between 'T' and 'U'. -==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (8 errors) ==== +==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (3 errors) ==== // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // these are errors @@ -20,24 +15,16 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfC var derived2: Derived2; var r2 = true ? 1 : ''; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'number' and 'string'. var r9 = true ? derived : derived2; - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Derived' and 'Derived2'. function foo(t: T, u: U) { return true ? t : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. } function foo2(t: T, u: U) { // Error for referencing own type parameter ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. return true ? t : u; // Ok because BCT(T, U) = U - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. } function foo3(t: T, u: U) { @@ -46,6 +33,4 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfC ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. return true ? t : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. } \ No newline at end of file diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.types b/tests/baselines/reference/bestCommonTypeOfTuple.types index c8a3fb98a51..87624c267aa 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple.types @@ -75,13 +75,13 @@ t4 = [E1.one, E2.two, 20]; >two : E2 var e1 = t1[2]; // {} ->e1 : {} ->t1[2] : {} +>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]; // {} ->e2 : {} ->t2[2] : {} +>e2 : E1 | E2 +>t2[2] : E1 | E2 >t2 : [E1, E2] var e3 = t3[2]; // any diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.types b/tests/baselines/reference/bestCommonTypeOfTuple2.types index 49d100ed94d..a87407e98fc 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.types @@ -69,8 +69,8 @@ var e11 = t1[4]; // base >t1 : [C, base] var e21 = t2[4]; // {} ->e21 : {} ->t2[4] : {} +>e21 : C | D +>t2[4] : C | D >t2 : [C, D] var e31 = t3[4]; // C1 @@ -84,7 +84,7 @@ var e41 = t4[2]; // base1 >t4 : [base1, C1] var e51 = t5[2]; // {} ->e51 : {} ->t5[2] : {} +>e51 : F | C1 +>t5[2] : F | C1 >t5 : [C1, F] diff --git a/tests/baselines/reference/castingTuple.errors.txt b/tests/baselines/reference/castingTuple.errors.txt index 333cd22caec..c3079699a80 100644 --- a/tests/baselines/reference/castingTuple.errors.txt +++ b/tests/baselines/reference/castingTuple.errors.txt @@ -1,3 +1,7 @@ +tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2353: Neither type '[number, string]' nor type '[number, string, boolean]' is assignable to the other: + Property '2' is missing in type '[number, string]'. +tests/cases/conformance/types/tuple/castingTuple.ts(16,21): error TS2353: Neither type '[C, D]' nor type '[C, D, A]' is assignable to the other: + Property '2' is missing in type '[C, D]'. tests/cases/conformance/types/tuple/castingTuple.ts(24,10): error TS2353: Neither type '[number, string]' nor type '[number, number]' is assignable to the other: Types of property '1' are incompatible: Type 'string' is not assignable to type 'number'. @@ -8,12 +12,13 @@ tests/cases/conformance/types/tuple/castingTuple.ts(25,10): error TS2353: Neithe tests/cases/conformance/types/tuple/castingTuple.ts(26,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. tests/cases/conformance/types/tuple/castingTuple.ts(26,14): error TS2353: Neither type '[number, string]' nor type 'number[]' is assignable to the other: Types of property 'pop' are incompatible: - Type '() => {}' is not assignable to type '() => number': - Type '{}' is not assignable to type 'number'. + Type '() => string | number' is not assignable to type '() => number': + Type 'string | number' is not assignable to type 'number': + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/castingTuple.ts(27,1): error TS2304: Cannot find name 't4'. -==== tests/cases/conformance/types/tuple/castingTuple.ts (5 errors) ==== +==== tests/cases/conformance/types/tuple/castingTuple.ts (7 errors) ==== interface I { } class A { a = 10; } class C implements I { c }; @@ -27,9 +32,15 @@ tests/cases/conformance/types/tuple/castingTuple.ts(27,1): error TS2304: Cannot var numStrTuple: [number, string] = [5, "foo"]; var emptyObjTuple = <[{}, {}]>numStrTuple; var numStrBoolTuple = <[number, string, boolean]>numStrTuple; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2353: Neither type '[number, string]' nor type '[number, string, boolean]' is assignable to the other: +!!! error TS2353: Property '2' is missing in type '[number, string]'. var classCDTuple: [C, D] = [new C(), new D()]; var interfaceIITuple = <[I, I]>classCDTuple; var classCDATuple = <[C, D, A]>classCDTuple; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2353: Neither type '[C, D]' nor type '[C, D, A]' is assignable to the other: +!!! error TS2353: Property '2' is missing in type '[C, D]'. var eleFromCDA1 = classCDATuple[2]; // A var eleFromCDA2 = classCDATuple[5]; // {} var t10: [E1, E2] = [E1.one, E2.one]; @@ -54,8 +65,9 @@ tests/cases/conformance/types/tuple/castingTuple.ts(27,1): error TS2304: Cannot ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2353: Neither type '[number, string]' nor type 'number[]' is assignable to the other: !!! error TS2353: Types of property 'pop' are incompatible: -!!! error TS2353: Type '() => {}' is not assignable to type '() => number': -!!! error TS2353: Type '{}' is not assignable to type 'number'. +!!! error TS2353: Type '() => string | number' is not assignable to type '() => number': +!!! error TS2353: Type 'string | number' is not assignable to type 'number': +!!! error TS2353: Type 'string' is not assignable to type 'number'. t4[2] = 10; ~~ !!! error TS2304: Cannot find name 't4'. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalExpression1.errors.txt b/tests/baselines/reference/conditionalExpression1.errors.txt index 542b660ba42..30703c7169e 100644 --- a/tests/baselines/reference/conditionalExpression1.errors.txt +++ b/tests/baselines/reference/conditionalExpression1.errors.txt @@ -1,10 +1,9 @@ -tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2323: Type '{}' is not assignable to type 'boolean'. -tests/cases/compiler/conditionalExpression1.ts(1,19): error TS2367: No best common type exists between 'number' and 'string'. +tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean': + Type 'string' is not assignable to type 'boolean'. -==== tests/cases/compiler/conditionalExpression1.ts (2 errors) ==== +==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ==== var x: boolean = (true ? 1 : ""); // should be an error ~ -!!! error TS2323: Type '{}' is not assignable to type 'boolean'. - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'number' and 'string'. \ No newline at end of file +!!! error TS2322: Type 'string | number' is not assignable to type 'boolean': +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index 8ad918936d2..edef88acfc3 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -80,7 +80,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >result4 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyX : (n) => n.propertyA : (t: A) => any +>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any >(m) => m.propertyX : (m: A) => any >m : A >m.propertyX : any @@ -144,7 +144,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >result8 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyA : (n) => n.propertyX : (t: A) => any +>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any >(m) => m.propertyA : (m: A) => number >m : A >m.propertyA : number @@ -161,7 +161,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; var resultIsX3: X = true ? a : b; >resultIsX3 : X >X : X ->true ? a : b : X +>true ? a : b : A | B >a : A >b : B @@ -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 : (t: X) => any +>true ? (m) => m.propertyX1 : (n) => n.propertyX2 : { (m: X): number; } | { (n: X): string; } >(m) => m.propertyX1 : (m: X) => number >m : X >m.propertyX1 : number @@ -184,5 +184,5 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2; //Expr1 and Expr2 are literals var result11: any = true ? 1 : 'string'; >result11 : any ->true ? 1 : 'string' : any +>true ? 1 : 'string' : string | number diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt index 7db921cbe1a..fb2c02d1c28 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt @@ -1,20 +1,21 @@ -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(12,1): error TS2367: No best common type exists between 'A' and 'B'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(13,15): error TS2367: No best common type exists between 'A' and 'B'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type '{}' is not assignable to type 'A': - Property 'propertyA' is missing in type '{}'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,18): error TS2366: No best common type exists between 'A', 'A', and 'B'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,5): error TS2322: Type '{}' is not assignable to type 'B': - Property 'propertyB' is missing in type '{}'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,18): error TS2366: No best common type exists between 'B', 'A', and 'B'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2323: Type '{}' is not assignable to type '(t: X) => number'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,33): error TS2366: No best common type exists between '(t: X) => number', '(m: X) => number', and '(n: X) => string'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2323: Type '{}' is not assignable to type '(t: X) => string'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,33): error TS2366: No best common type exists between '(t: X) => string', '(m: X) => number', and '(n: X) => string'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2323: Type '{}' is not assignable to type '(t: X) => boolean'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,34): error TS2366: No best common type exists between '(t: X) => boolean', '(m: X) => number', and '(n: X) => string'. +tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(15,5): error TS2322: Type 'A | B' is not assignable to type 'A': + Type 'B' is not assignable to type 'A': + Property 'propertyA' is missing in type 'B'. +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': + 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': + 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': + Type '(m: X) => number' is not assignable to type '(t: X) => boolean': + Type 'number' is not assignable to type 'boolean'. -==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (12 errors) ==== +==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (5 errors) ==== //Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type class X { propertyX: any; propertyX1: number; propertyX2: string }; class A extends X { propertyA: number }; @@ -24,41 +25,34 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou var a: A; var b: B; - //Expect to have compiler errors - //Be not contextually typed + // No errors anymore, uses union types true ? a : b; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'A' and 'B'. var result1 = true ? a : b; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'A' and 'B'. - //Be contextually typed and and bct is not identical + //Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target var result2: A = true ? a : b; ~~~~~~~ -!!! error TS2322: Type '{}' is not assignable to type 'A': -!!! error TS2322: Property 'propertyA' is missing in type '{}'. - ~~~~~~~~~~~~ -!!! error TS2366: No best common type exists between 'A', 'A', and 'B'. +!!! error TS2322: Type 'A | B' is not assignable to type 'A': +!!! error TS2322: Type 'B' is not assignable to type 'A': +!!! error TS2322: Property 'propertyA' is missing in type 'B'. var result3: B = true ? a : b; ~~~~~~~ -!!! error TS2322: Type '{}' is not assignable to type 'B': -!!! error TS2322: Property 'propertyB' is missing in type '{}'. - ~~~~~~~~~~~~ -!!! error TS2366: No best common type exists between 'B', 'A', and 'B'. +!!! error TS2322: Type 'A | B' is not assignable to type 'B': +!!! error TS2322: Type 'A' is not assignable to type 'B': +!!! error TS2322: Property 'propertyB' is missing in type 'A'. var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2; ~~~~~~~ -!!! error TS2323: Type '{}' is not assignable to type '(t: X) => number'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2366: No best common type exists between '(t: X) => number', '(m: X) => number', and '(n: X) => string'. +!!! 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 TS2323: Type '{}' is not assignable to type '(t: X) => string'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2366: No best common type exists between '(t: X) => string', '(m: X) => number', and '(n: 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 TS2323: Type '{}' is not assignable to type '(t: X) => boolean'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2366: No best common type exists between '(t: X) => boolean', '(m: X) => number', and '(n: X) => string'. \ No newline at end of file +!!! 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/conditionalOperatorWithoutIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js index 90125d4ebf6..b6376dd781f 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js @@ -8,12 +8,11 @@ var x: X; var a: A; var b: B; -//Expect to have compiler errors -//Be not contextually typed +// No errors anymore, uses union types true ? a : b; var result1 = true ? a : b; -//Be contextually typed and and bct is not identical +//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target var result2: A = true ? a : b; var result3: B = true ? a : b; @@ -54,11 +53,10 @@ var B = (function (_super) { var x; var a; var b; -//Expect to have compiler errors -//Be not contextually typed +// No errors anymore, uses union types true ? a : b; var result1 = true ? a : b; -//Be contextually typed and and bct is not identical +//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target var result2 = true ? a : b; var result3 = true ? a : b; var result4 = true ? function (m) { return m.propertyX1; } : function (n) { return n.propertyX2; }; diff --git a/tests/baselines/reference/contextualTypeArrayReturnType.types b/tests/baselines/reference/contextualTypeArrayReturnType.types index b0cd03f8510..ceb7aa53f67 100644 --- a/tests/baselines/reference/contextualTypeArrayReturnType.types +++ b/tests/baselines/reference/contextualTypeArrayReturnType.types @@ -26,18 +26,18 @@ interface Transform3D { var style: IBookStyle = { >style : IBookStyle >IBookStyle : IBookStyle ->{ initialLeftPageTransforms: (width: number) => { return [ {'ry': null } ]; }} : { initialLeftPageTransforms: (width: number) => NamedTransform[]; } +>{ initialLeftPageTransforms: (width: number) => { return [ {'ry': null } ]; }} : { initialLeftPageTransforms: (width: number) => { [x: string]: any; 'ry': any; }[]; } initialLeftPageTransforms: (width: number) => { ->initialLeftPageTransforms : (width: number) => NamedTransform[] ->(width: number) => { return [ {'ry': null } ]; } : (width: number) => NamedTransform[] +>initialLeftPageTransforms : (width: number) => { [x: string]: any; 'ry': any; }[] +>(width: number) => { return [ {'ry': null } ]; } : (width: number) => { [x: string]: any; 'ry': any; }[] >width : number return [ ->[ {'ry': null } ] : NamedTransform[] +>[ {'ry': null } ] : { [x: string]: null; 'ry': null; }[] {'ry': null } ->{'ry': null } : { [x: string]: Transform3D; 'ry': null; } +>{'ry': null } : { [x: string]: null; 'ry': null; } ]; } diff --git a/tests/baselines/reference/contextualTypeWithTuple.errors.txt b/tests/baselines/reference/contextualTypeWithTuple.errors.txt index f2f77277c5e..bd1aa155661 100644 --- a/tests/baselines/reference/contextualTypeWithTuple.errors.txt +++ b/tests/baselines/reference/contextualTypeWithTuple.errors.txt @@ -1,3 +1,10 @@ +tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]': + Types of property 'pop' are incompatible: + Type '() => string | number | boolean' is not assignable to type '() => string | number': + Type 'string | number | boolean' is not assignable to type 'string | number': + Type 'boolean' is not assignable to type 'string | number': + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(8,1): error TS2323: Type '[number, string, boolean]' is not assignable to type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(11,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]': Types of property '0' are incompatible: Type '{}' is not assignable to type '{ a: string; }': @@ -6,19 +13,29 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(12,1): error TS23 Property '2' is missing in type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(13,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]': Types of property 'pop' are incompatible: - Type '() => {}' is not assignable to type '() => string': - Type '{}' is not assignable to type 'string'. + 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'. -==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (3 errors) ==== +==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (5 errors) ==== // no error var numStrTuple: [number, string] = [5, "hello"]; var numStrTuple2: [number, string] = [5, "foo", true]; + ~~~~~~~~~~~~ +!!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]': +!!! error TS2322: Types of property 'pop' are incompatible: +!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number': +!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number': +!!! error TS2322: Type 'boolean' is not assignable to type 'string | number': +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. var numStrBoolTuple: [number, string, boolean] = [5, "foo", true]; var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5]; var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]]; numStrTuple = numStrTuple2; numStrTuple = numStrBoolTuple; + ~~~~~~~~~~~ +!!! error TS2323: Type '[number, string, boolean]' is not assignable to type '[number, string]'. // error objNumTuple = [ {}, 5]; @@ -35,6 +52,7 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(13,5): error TS23 ~~~~~~~~~~~ !!! error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]': !!! error TS2322: Types of property 'pop' are incompatible: -!!! error TS2322: Type '() => {}' is not assignable to type '() => string': -!!! error TS2322: Type '{}' 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'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping21.errors.txt b/tests/baselines/reference/contextualTyping21.errors.txt index 999cfcbd769..620b0635d12 100644 --- a/tests/baselines/reference/contextualTyping21.errors.txt +++ b/tests/baselines/reference/contextualTyping21.errors.txt @@ -1,11 +1,13 @@ -tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '{}[]' is not assignable to type '{ id: number; }[]': - Type '{}' is not assignable to type '{ id: number; }': - Property 'id' is missing in type '{}'. +tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type 'Array' 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'. ==== tests/cases/compiler/contextualTyping21.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1]; ~~~ -!!! error TS2322: Type '{}[]' is not assignable to type '{ id: number; }[]': -!!! error TS2322: Type '{}' is not assignable to type '{ id: number; }': -!!! error TS2322: Property 'id' is missing in type '{}'. \ No newline at end of file +!!! 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' 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 3b2fbc8aac6..4c8d87d41b6 100644 --- a/tests/baselines/reference/contextualTyping30.errors.txt +++ b/tests/baselines/reference/contextualTyping30.errors.txt @@ -1,9 +1,11 @@ -tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'. - Type '{}' is not assignable to type 'number'. +tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type 'Array' 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/contextualTyping30.ts (1 errors) ==== function foo(param:number[]){}; foo([1, "a"]); ~~~~~~~~ -!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type '{}' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2345: Argument of type 'Array' 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 a9d41405b93..383615aec3c 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; (i: number): 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 8f83fc37ab1..82799037ec6 100644 --- a/tests/baselines/reference/contextualTyping33.errors.txt +++ b/tests/baselines/reference/contextualTyping33.errors.txt @@ -1,9 +1,11 @@ -tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. - Type '{}' is not assignable to type '{ (): number; (i: number): number; }'. +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; }': + 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 '{}[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. -!!! error TS2345: Type '{}' is not assignable to type '{ (): number; (i: number): number; }'. \ No newline at end of file +!!! 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: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt index 0f9fc64536b..cb3b439681e 100644 --- a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt @@ -1,7 +1,8 @@ -tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '{}[]' is not assignable to type 'I': +tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type 'Array' is not assignable to type 'I': Index signatures are incompatible: - Type '{}' is not assignable to type 'Date': - Property 'toDateString' is missing in type '{}'. + Type 'number | Date' is not assignable to type 'Date': + Type 'number' is not assignable to type 'Date': + Property 'toDateString' is missing in type 'Number'. ==== tests/cases/compiler/contextualTypingOfArrayLiterals1.ts (1 errors) ==== @@ -11,10 +12,11 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ var x3: I = [new Date(), 1]; ~~ -!!! error TS2322: Type '{}[]' is not assignable to type 'I': +!!! error TS2322: Type 'Array' is not assignable to type 'I': !!! error TS2322: Index signatures are incompatible: -!!! error TS2322: Type '{}' is not assignable to type 'Date': -!!! error TS2322: Property 'toDateString' is missing in type '{}'. +!!! error TS2322: Type 'number | Date' is not assignable to type 'Date': +!!! error TS2322: Type 'number' is not assignable to type 'Date': +!!! error TS2322: Property 'toDateString' is missing in type 'Number'. var r2 = x3[1]; r2.getDate(); \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression.types b/tests/baselines/reference/contextualTypingOfConditionalExpression.types index 6c6f9b04457..2cd2b671b40 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression.types +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression.types @@ -2,7 +2,7 @@ var x: (a: number) => void = true ? (a) => a.toExponential() : (b) => b.toFixed(); >x : (a: number) => void >a : number ->true ? (a) => a.toExponential() : (b) => b.toFixed() : (a: number) => void +>true ? (a) => a.toExponential() : (b) => b.toFixed() : (a: number) => string >(a) => a.toExponential() : (a: number) => string >a : number >a.toExponential() : string @@ -41,7 +41,7 @@ var x2: (a: A) => void = true ? (a) => a.foo : (b) => b.foo; >x2 : (a: A) => void >a : A >A : A ->true ? (a) => a.foo : (b) => b.foo : (a: A) => void +>true ? (a) => a.foo : (b) => b.foo : (a: A) => number >(a) => a.foo : (a: A) => number >a : A >a.foo : number diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt index c433bd1d8ca..574e25c6f45 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt @@ -1,8 +1,11 @@ -tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2323: Type '{}' is not assignable to type '(a: A) => void'. -tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,26): error TS2366: No best common type exists between '(a: A) => void', '(a: C) => number', and '(b: number) => 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': + Property 'foo' is missing in type 'Number'. -==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (2 errors) ==== +==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ==== class A { foo: number; } @@ -15,7 +18,9 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,26): error T var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { }; ~~ -!!! error TS2323: Type '{}' is not assignable to type '(a: A) => void'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2366: No best common type exists between '(a: A) => void', '(a: C) => number', and '(b: number) => 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': +!!! error TS2322: Property 'foo' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt index e4d8a82c47e..a524fd3be31 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt @@ -1,9 +1,12 @@ tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'. +tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ==== +==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (2 errors) ==== var f10: (x: T, b: () => (a: T) => void, y: T) => T; - f10('', () => a => a.foo, ''); // a is string, fixed by first parameter + f10('', () => a => a.foo, ''); // a is string ~~~ !!! error TS2339: Property 'foo' does not exist on type 'string'. - var r9 = f10('', () => (a => a.foo), 1); // now a should be any \ No newline at end of file + var r9 = f10('', () => (a => a.foo), 1); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.js b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.js index cf7274db8a0..55f7580b3f8 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.js +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.js @@ -1,9 +1,9 @@ //// [contextualTypingWithFixedTypeParameters1.ts] var f10: (x: T, b: () => (a: T) => void, y: T) => T; -f10('', () => a => a.foo, ''); // a is string, fixed by first parameter -var r9 = f10('', () => (a => a.foo), 1); // now a should be any +f10('', () => a => a.foo, ''); // a is string +var r9 = f10('', () => (a => a.foo), 1); // error //// [contextualTypingWithFixedTypeParameters1.js] var f10; -f10('', function () { return function (a) { return a.foo; }; }, ''); // a is string, fixed by first parameter -var r9 = f10('', function () { return (function (a) { return a.foo; }); }, 1); // now a should be any +f10('', function () { return function (a) { return a.foo; }; }, ''); // a is string +var r9 = f10('', function () { return (function (a) { return a.foo; }); }, 1); // error diff --git a/tests/baselines/reference/contextuallyTypingOrOperator.types b/tests/baselines/reference/contextuallyTypingOrOperator.types index ee1ac4b0bba..4b47ea763bc 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator.types @@ -3,7 +3,7 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; >v : { a: (_: string) => number; } >a : (_: string) => number >_ : string ->{ a: s => s.length } || { a: s => 1 } : { a: (_: string) => number; } +>{ a: s => s.length } || { a: s => 1 } : { a: (s: string) => number; } >{ a: s => s.length } : { a: (s: string) => number; } >a : (s: string) => number >s => s.length : (s: string) => number @@ -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) => {} ->(s: string) => s.length || function (s) { s.length } : (s: string) => {} +>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 } : {} +>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) => {} ->(s: string) => s.length || function (s: number) { return 1 } : (s: string) => {} +>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 } : {} +>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) => {} ->(s: number) => 1 || function (s: string) { return s.length } : (s: 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 } : {} +>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 57c9992436d..c233066d6dc 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator2.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator2.types @@ -3,7 +3,7 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; >v : { a: (_: string) => number; } >a : (_: string) => number >_ : string ->{ a: s => s.length } || { a: s => 1 } : { a: (_: string) => number; } +>{ a: s => s.length } || { a: s => 1 } : { a: (s: string) => number; } >{ a: s => s.length } : { a: (s: string) => number; } >a : (s: string) => number >s => s.length : (s: string) => number @@ -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) => {} ->(s: string) => s.length || function (s) { s.aaa } : (s: string) => {} +>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 } : {} +>s.length || function (s) { s.aaa } : number | { (s: any): void; } >s.length : number >s : string >length : number diff --git a/tests/baselines/reference/declFileGenericType2.types b/tests/baselines/reference/declFileGenericType2.types index a6b6546326c..f9345b5ff11 100644 --- a/tests/baselines/reference/declFileGenericType2.types +++ b/tests/baselines/reference/declFileGenericType2.types @@ -131,11 +131,11 @@ module templa.dom.mvc.composite { >super : typeof AbstractElementController this._controllers = []; ->this._controllers = [] : templa.mvc.IController[] +>this._controllers = [] : undefined[] >this._controllers : templa.mvc.IController[] >this : AbstractCompositeElementController >_controllers : templa.mvc.IController[] ->[] : templa.mvc.IController[] +>[] : undefined[] } } } diff --git a/tests/baselines/reference/decrementOperatorWithAnyOtherType.types b/tests/baselines/reference/decrementOperatorWithAnyOtherType.types index 4e8387f9066..ab21dd9db5c 100644 --- a/tests/baselines/reference/decrementOperatorWithAnyOtherType.types +++ b/tests/baselines/reference/decrementOperatorWithAnyOtherType.types @@ -9,7 +9,7 @@ var ANY1; var ANY2: any[] = ["", ""]; >ANY2 : any[] ->["", ""] : any[] +>["", ""] : string[] var obj = {x:1,y:null}; >obj : { x: number; y: any; } diff --git a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt index ada7f83af3d..21296783f28 100644 --- a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt +++ b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt @@ -1,31 +1,27 @@ -tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(4,6): error TS2339: Property 'length' does not exist on type '{}'. -tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(10,6): error TS2339: Property 'length' does not exist on type 'Object'. -tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(18,27): error TS2339: Property 'length' does not exist on type '{}'. +tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(2,6): error TS2339: Property 'length' does not exist on type '{}'. +tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(5,6): error TS2339: Property 'length' does not exist on type 'Object'. +tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ==== - var obj1: {}; - obj1.length; ~~~~~~ !!! error TS2339: Property 'length' does not exist on type '{}'. - - var obj2: Object; - obj2.length; ~~~~~~ !!! error TS2339: Property 'length' does not exist on type 'Object'. - - function concat(x: T, y: T): T { return null; } + var result = concat(1, ""); // error + ~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var elementCount = result.length; - var result = concat(1, ""); + function concat2(x: T, y: U) { return null; } + var result2 = concat2(1, ""); // result2 will be number|string + var elementCount2 = result.length; - var elementCount = result.length; // would like to get an error by now - ~~~~~~ -!!! error TS2339: Property 'length' does not exist on type '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.js b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.js index 59935cc53af..98e135cc712 100644 --- a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.js +++ b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.js @@ -1,22 +1,18 @@ //// [defaultBestCommonTypesHaveDecls.ts] - var obj1: {}; - obj1.length; - - var obj2: Object; - obj2.length; - - function concat(x: T, y: T): T { return null; } +var result = concat(1, ""); // error +var elementCount = result.length; -var result = concat(1, ""); +function concat2(x: T, y: U) { return null; } +var result2 = concat2(1, ""); // result2 will be number|string +var elementCount2 = result.length; -var elementCount = result.length; // would like to get an error by now //// [defaultBestCommonTypesHaveDecls.js] @@ -27,5 +23,10 @@ obj2.length; function concat(x, y) { return null; } -var result = concat(1, ""); -var elementCount = result.length; // would like to get an error by now +var result = concat(1, ""); // error +var elementCount = result.length; +function concat2(x, y) { + return null; +} +var result2 = concat2(1, ""); // result2 will be number|string +var elementCount2 = result.length; diff --git a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.types b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.types index 9821ff91123..47b7ed95dc6 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] : Base[] +>[d1, d2] : Array >d1 : Derived >d2 : Derived2 diff --git a/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types b/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types index 225bca8de63..cd8c03fd6a6 100644 --- a/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types +++ b/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types @@ -21,7 +21,7 @@ interface IIntervalTreeNode { var test: IIntervalTreeNode[] = [{ interval: { begin: 0 }, children: null }]; // was error here because best common type is {} >test : IIntervalTreeNode[] >IIntervalTreeNode : IIntervalTreeNode ->[{ interval: { begin: 0 }, children: null }] : IIntervalTreeNode[] +>[{ interval: { begin: 0 }, children: null }] : { interval: { begin: number; }; children: null; }[] >{ interval: { begin: 0 }, children: null } : { interval: { begin: number; }; children: null; } >interval : { begin: number; } >{ begin: 0 } : { begin: number; } diff --git a/tests/baselines/reference/enumBasics.types b/tests/baselines/reference/enumBasics.types index f775295891a..696e68eded2 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 : {}[] ->[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : {}[] +>doNotPropagate : Array +>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : Array 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 : {}[] ->[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : {}[] +>doPropagate : Array +>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : Array 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/extendingClassFromAliasAndUsageInIndexer.types b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types index fefa692b509..991d324e822 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types @@ -25,7 +25,7 @@ var moduleMap: { [key: string]: IHasVisualizationModel } = { >moduleMap : { [x: string]: IHasVisualizationModel; } >key : string >IHasVisualizationModel : IHasVisualizationModel ->{ "moduleA": moduleA, "moduleB": moduleB} : { [x: string]: IHasVisualizationModel; "moduleA": typeof moduleA; "moduleB": typeof moduleB; } +>{ "moduleA": moduleA, "moduleB": moduleB} : { [x: string]: typeof moduleA; "moduleA": typeof moduleA; "moduleB": typeof moduleB; } "moduleA": moduleA, >moduleA : typeof moduleA diff --git a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt new file mode 100644 index 00000000000..d9416eb4c25 --- /dev/null +++ b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts (1 errors) ==== + function bar(item1: T, item2: T) { } + bar(1, ""); // Should be ok + ~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.types b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.types deleted file mode 100644 index 95214571df9..00000000000 --- a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts === -function bar(item1: T, item2: T) { } ->bar : (item1: T, item2: T) => void ->T : T ->item1 : T ->T : T ->item2 : T ->T : T - -bar(1, ""); // Should be ok ->bar(1, "") : void ->bar : (item1: T, item2: T) => void - diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index b653bc01f55..66e8a2a66df 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 '{}[]'. +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(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 '{}[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array>'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.types b/tests/baselines/reference/forStatementsMultipleValidDecl.types index 2f3bfd70cea..c2458a306c7 100644 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.types +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.types @@ -109,11 +109,11 @@ for (var a = ['a', 'b']; ;) { } for (var a = []; ;) { } >a : string[] >[] : string[] ->[] : string[] +>[] : undefined[] for (var a: string[] = []; ;) { } >a : string[] ->[] : string[] +>[] : undefined[] for (var a = new Array(); ;) { } >a : string[] diff --git a/tests/baselines/reference/functionCall3.types b/tests/baselines/reference/functionCall3.types index a9b8e46069c..ea47de3e6d9 100644 --- a/tests/baselines/reference/functionCall3.types +++ b/tests/baselines/reference/functionCall3.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionCall3.ts === function foo():any[]{return [1];} >foo : () => any[] ->[1] : any[] +>[1] : number[] var x = foo(); >x : any[] diff --git a/tests/baselines/reference/functionOverloads42.types b/tests/baselines/reference/functionOverloads42.types index dec6a041440..6641a28c87a 100644 --- a/tests/baselines/reference/functionOverloads42.types +++ b/tests/baselines/reference/functionOverloads42.types @@ -19,7 +19,7 @@ var x = foo([{a:'s'}]); >x : number >foo([{a:'s'}]) : number >foo : { (bar: { a: number; }[]): string; (bar: { a: any; }[]): number; } ->[{a:'s'}] : { a: any; }[] +>[{a:'s'}] : { a: string; }[] >{a:'s'} : { a: string; } >a : string diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.types b/tests/baselines/reference/functionSubtypingOfVarArgs2.types index 2fef933594d..2f81898c7de 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.types +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.types @@ -5,7 +5,7 @@ class EventBase { private _listeners: { (...args: any[]): void; }[] = []; >_listeners : { (...args: any[]): void; }[] >args : any[] ->[] : { (...args: any[]): void; }[] +>[] : undefined[] add(listener: (...args: any[]) => void): void { >add : (listener: (...args: any[]) => void) => void diff --git a/tests/baselines/reference/functionTypeArgumentArrayAssignment.types b/tests/baselines/reference/functionTypeArgumentArrayAssignment.types index 73375ac5e21..588dfd506ef 100644 --- a/tests/baselines/reference/functionTypeArgumentArrayAssignment.types +++ b/tests/baselines/reference/functionTypeArgumentArrayAssignment.types @@ -21,7 +21,7 @@ module test { var ys: U[] = []; >ys : U[] >U : U ->[] : U[] +>[] : undefined[] } } diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 57b5408eabe..78fc6f6cfef 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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x2: () => Base[] = function() { return [d1, d2] }; >x2 : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x3: () => Base[] = function named() { return [d1, d2] }; >x3 : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x4: { (): Base[]; } = () => [d1, d2]; >x4 : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x5: { (): Base[]; } = function() { return [d1, d2] }; >x5 : () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x6: { (): Base[]; } = function named() { return [d1, d2] }; >x6 : () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x7: Base[] = [d1, d2]; >x7 : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -92,7 +92,7 @@ var x8: Array = [d1, d2]; >x8 : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -139,8 +139,8 @@ class x13 { member: () => Base[] = () => [d1, d2] } >x13 : x13 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -167,8 +167,8 @@ class x16 { member: { (): Base[]; } = () => [d1, d2] } >x16 : x16 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -195,7 +195,7 @@ class x19 { member: Base[] = [d1, d2] } >x19 : x19 >member : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -204,7 +204,7 @@ class x20 { member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -255,8 +255,8 @@ class x25 { private member: () => Base[] = () => [d1, d2] } >x25 : x25 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -283,8 +283,8 @@ class x28 { private member: { (): Base[]; } = () => [d1, d2] } >x28 : x28 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -311,7 +311,7 @@ class x31 { private member: Base[] = [d1, d2] } >x31 : x31 >member : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -320,7 +320,7 @@ class x32 { private member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -371,8 +371,8 @@ class x37 { public member: () => Base[] = () => [d1, d2] } >x37 : x37 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -399,8 +399,8 @@ class x40 { public member: { (): Base[]; } = () => [d1, d2] } >x40 : x40 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -427,7 +427,7 @@ class x43 { public member: Base[] = [d1, d2] } >x43 : x43 >member : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -436,7 +436,7 @@ class x44 { public member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -487,8 +487,8 @@ class x49 { static member: () => Base[] = () => [d1, d2] } >x49 : x49 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -515,8 +515,8 @@ class x52 { static member: { (): Base[]; } = () => [d1, d2] } >x52 : x52 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -543,7 +543,7 @@ class x55 { static member: Base[] = [d1, d2] } >x55 : x55 >member : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -552,7 +552,7 @@ class x56 { static member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -603,8 +603,8 @@ class x61 { private static member: () => Base[] = () => [d1, d2] } >x61 : x61 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -631,8 +631,8 @@ class x64 { private static member: { (): Base[]; } = () => [d1, d2] } >x64 : x64 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -659,7 +659,7 @@ class x67 { private static member: Base[] = [d1, d2] } >x67 : x67 >member : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -668,7 +668,7 @@ class x68 { private static member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -719,8 +719,8 @@ class x73 { public static member: () => Base[] = () => [d1, d2] } >x73 : x73 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -747,8 +747,8 @@ class x76 { public static member: { (): Base[]; } = () => [d1, d2] } >x76 : x76 >member : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -775,7 +775,7 @@ class x79 { public static member: Base[] = [d1, d2] } >x79 : x79 >member : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -784,7 +784,7 @@ class x80 { public static member: Array = [d1, d2] } >member : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -835,8 +835,8 @@ class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } >x85 : x85 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -863,8 +863,8 @@ class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } >x88 : x88 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -891,7 +891,7 @@ class x91 { constructor(parm: Base[] = [d1, d2]) { } } >x91 : x91 >parm : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -900,7 +900,7 @@ class x92 { constructor(parm: Array = [d1, d2]) { } } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -951,8 +951,8 @@ class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } >x97 : x97 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -979,8 +979,8 @@ class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } >x100 : x100 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1007,7 +1007,7 @@ class x103 { constructor(public parm: Base[] = [d1, d2]) { } } >x103 : x103 >parm : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1016,7 +1016,7 @@ class x104 { constructor(public parm: Array = [d1, d2]) { } } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1067,8 +1067,8 @@ class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } >x109 : x109 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1095,8 +1095,8 @@ class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } >x112 : x112 >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1123,7 +1123,7 @@ class x115 { constructor(private parm: Base[] = [d1, d2]) { } } >x115 : x115 >parm : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1132,7 +1132,7 @@ class x116 { constructor(private parm: Array = [d1, d2]) { } } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1183,8 +1183,8 @@ function x121(parm: () => Base[] = () => [d1, d2]) { } >x121 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1211,8 +1211,8 @@ function x124(parm: { (): Base[]; } = () => [d1, d2]) { } >x124 : (parm?: () => Base[]) => void >parm : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1239,7 +1239,7 @@ function x127(parm: Base[] = [d1, d2]) { } >x127 : (parm?: Base[]) => void >parm : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1248,7 +1248,7 @@ function x128(parm: Array = [d1, d2]) { } >parm : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x133(): () => Base[] { return () => [d1, d2]; } >x133 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x134(): () => Base[] { return function() { return [d1, d2] }; } >x134 : () => () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x135(): () => Base[] { return function named() { return [d1, d2] }; } >x135 : () => () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x136(): { (): Base[]; } { return () => [d1, d2]; } >x136 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } >x137 : () => () => Base[] >Base : Base ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } >x138 : () => () => Base[] >Base : Base ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x139(): Base[] { return [d1, d2]; } >x139 : () => Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1356,7 +1356,7 @@ function x140(): Array { return [d1, d2]; } >x140 : () => Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } >x145 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } >x148 : () => () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 function x151(): Base[] { return [d1, d2]; return [d1, d2]; } >x151 : () => Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x157: () => () => Base[] = () => { return () => [d1, d2]; }; >x157 : () => () => Base[] >Base : Base ->() => { return () => [d1, d2]; } : () => () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => { return () => [d1, d2]; } : () => () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; >x158 : () => () => Base[] >Base : Base ->() => { return function() { return [d1, d2] }; } : () => () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>() => { return function() { return [d1, d2] }; } : () => () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; >x159 : () => () => Base[] >Base : Base ->() => { return function named() { return [d1, d2] }; } : () => () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>() => { return function named() { return [d1, d2] }; } : () => () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; >x160 : () => () => Base[] >Base : Base ->() => { return () => [d1, d2]; } : () => () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => { return () => [d1, d2]; } : () => () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; >x161 : () => () => Base[] >Base : Base ->() => { return function() { return [d1, d2] }; } : () => () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>() => { return function() { return [d1, d2] }; } : () => () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; >x162 : () => () => Base[] >Base : Base ->() => { return function named() { return [d1, d2] }; } : () => () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>() => { return function named() { return [d1, d2] }; } : () => () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x163: () => Base[] = () => { return [d1, d2]; }; >x163 : () => Base[] >Base : Base ->() => { return [d1, d2]; } : () => Base[] ->[d1, d2] : Base[] +>() => { return [d1, d2]; } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1622,8 +1622,8 @@ var x164: () => Array = () => { return [d1, d2]; }; >x164 : () => Base[] >Array : T[] >Base : Base ->() => { return [d1, d2]; } : () => Base[] ->[d1, d2] : Base[] +>() => { return [d1, d2]; } : () => Array +>[d1, d2] : Array >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]; } : () => Base[] ->[d1, d2] : Base[] +>() => { return [d1, d2]; } : () => Array +>[d1, d2] : Array >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: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>() => { return { n: [d1, d2] }; } : () => { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: 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 >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x169: () => () => Base[] = function() { return () => [d1, d2]; }; >x169 : () => () => Base[] >Base : Base ->function() { return () => [d1, d2]; } : () => () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>function() { return () => [d1, d2]; } : () => () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; >x170 : () => () => Base[] >Base : Base ->function() { return function() { return [d1, d2] }; } : () => () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return function() { return [d1, d2] }; } : () => () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] }; } : () => () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function() { return function named() { return [d1, d2] }; } : () => () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; >x172 : () => () => Base[] >Base : Base ->function() { return () => [d1, d2]; } : () => () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>function() { return () => [d1, d2]; } : () => () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; >x173 : () => () => Base[] >Base : Base ->function() { return function() { return [d1, d2] }; } : () => () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return function() { return [d1, d2] }; } : () => () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] }; } : () => () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function() { return function named() { return [d1, d2] }; } : () => () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x175: () => Base[] = function() { return [d1, d2]; }; >x175 : () => Base[] >Base : Base ->function() { return [d1, d2]; } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2]; } : () => Array +>[d1, d2] : Array >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]; } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2]; } : () => Array +>[d1, d2] : Array >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]; } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2]; } : () => Array +>[d1, d2] : Array >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: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>function() { return { n: [d1, d2] }; } : () => { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: 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 >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1790,8 +1790,8 @@ module x181 { var t: () => Base[] = () => [d1, d2]; } >x181 : typeof x181 >t : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1818,8 +1818,8 @@ module x184 { var t: { (): Base[]; } = () => [d1, d2]; } >x184 : typeof x184 >t : () => Base[] >Base : Base ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1846,7 +1846,7 @@ module x187 { var t: Base[] = [d1, d2]; } >x187 : typeof x187 >t : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1855,7 +1855,7 @@ module x188 { var t: Array = [d1, d2]; } >t : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1971,7 +1971,7 @@ module x200 { export var t: Array = [d1, d2]; } >t : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2060,7 +2060,7 @@ var x211 = [d1, d2]; >x211 : Base[] >[d1, d2] : Base[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2069,7 +2069,7 @@ var x212 = >[d1, d2]; >>[d1, d2] : Base[] >Array : T[] >Base : Base ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2163,7 +2163,7 @@ var x221 = (undefined) || [d1, d2]; >undefined : Base[] >Base : Base >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2175,7 +2175,7 @@ var x222 = (>undefined) || [d1, d2]; >Array : T[] >Base : Base >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2187,7 +2187,7 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >n : number >Base : Base >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x225: () => Base[]; x225 = () => [d1, d2]; >x225 : () => Base[] >Base : Base ->x225 = () => [d1, d2] : () => Base[] +>x225 = () => [d1, d2] : () => Array >x225 : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x226: () => Base[]; x226 = function() { return [d1, d2] }; >x226 : () => Base[] >Base : Base ->x226 = function() { return [d1, d2] } : () => Base[] +>x226 = function() { return [d1, d2] } : () => Array >x226 : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x227: () => Base[]; x227 = function named() { return [d1, d2] }; >x227 : () => Base[] >Base : Base ->x227 = function named() { return [d1, d2] } : () => Base[] +>x227 = function named() { return [d1, d2] } : () => Array >x227 : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x228: { (): Base[]; }; x228 = () => [d1, d2]; >x228 : () => Base[] >Base : Base ->x228 = () => [d1, d2] : () => Base[] +>x228 = () => [d1, d2] : () => Array >x228 : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; >x229 : () => Base[] >Base : Base ->x229 = function() { return [d1, d2] } : () => Base[] +>x229 = function() { return [d1, d2] } : () => Array >x229 : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; >x230 : () => Base[] >Base : Base ->x230 = function named() { return [d1, d2] } : () => Base[] +>x230 = function named() { return [d1, d2] } : () => Array >x230 : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x231: Base[]; x231 = [d1, d2]; >x231 : Base[] >Base : Base ->x231 = [d1, d2] : Base[] +>x231 = [d1, d2] : Array >x231 : Base[] ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2280,9 +2280,9 @@ var x232: Array; x232 = [d1, d2]; >x232 : Base[] >Array : T[] >Base : Base ->x232 = [d1, d2] : Base[] +>x232 = [d1, d2] : Array >x232 : Base[] ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>x233 = [d1, d2] : Array >x233 : { [x: number]: Base; } ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } +>x234 = { n: [d1, d2] } : { n: Array; } >x234 : { n: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } +>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } >x236 : Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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: () => Base[]; } ->n : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>{ n: () => [d1, d2] } : { n: () => Array; } +>n : () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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: () => Base[]; } ->n : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>{ n: function() { return [d1, d2] } } : { n: () => Array; } +>n : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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: () => Base[]; } ->n : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>{ n: function named() { return [d1, d2] } } : { n: () => Array; } +>n : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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: () => Base[]; } ->n : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>{ n: () => [d1, d2] } : { n: () => Array; } +>n : () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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: () => Base[]; } ->n : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>{ n: function() { return [d1, d2] } } : { n: () => Array; } +>n : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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: () => Base[]; } ->n : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>{ n: function named() { return [d1, d2] } } : { n: () => Array; } +>n : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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: Base[]; }; } ->n : { n: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: { n: [d1, d2] } } : { n: { n: Array; }; } +>n : { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; }; } ->n : { func: (n: Base[]) => {}[]; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: 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 : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x252: { (): Base[]; }[] = [() => [d1, d2]]; >x252 : { (): Base[]; }[] >Base : Base ->[() => [d1, d2]] : { (): Base[]; }[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>[() => [d1, d2]] : { (): Array; }[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; >x253 : { (): Base[]; }[] >Base : Base ->[function() { return [d1, d2] }] : { (): Base[]; }[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>[function() { return [d1, d2] }] : { (): Array; }[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; >x254 : { (): Base[]; }[] >Base : Base ->[function named() { return [d1, d2] }] : { (): Base[]; }[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>[function named() { return [d1, d2] }] : { (): Array; }[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x255: Base[][] = [[d1, d2]]; >x255 : Base[][] >Base : Base ->[[d1, d2]] : Base[][] ->[d1, d2] : Base[] +>[[d1, d2]] : Array[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2513,8 +2513,8 @@ var x256: Array[] = [[d1, d2]]; >x256 : Base[][] >Array : T[] >Base : Base ->[[d1, d2]] : Base[][] ->[d1, d2] : Base[] +>[[d1, d2]] : Array[] +>[d1, d2] : Array >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]] : { [x: number]: Base; }[] ->[d1, d2] : Base[] +>[[d1, d2]] : Array[] +>[d1, d2] : Array >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: Base[]; }[] ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>[{ n: [d1, d2] }] : { n: Array; }[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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]; } }] : Genric[] ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: 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 >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x261: () => Base[] = function() { return [d1, d2] } || undefined; >x261 : () => Base[] >Base : Base ->function() { return [d1, d2] } || undefined : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } || undefined : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } || undefined : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } || undefined : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } || undefined : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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 : Base[] ->[d1, d2] : Base[] +>[d1, d2] || undefined : Array +>[d1, d2] : Array >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 : Base[] ->[d1, d2] : Base[] +>[d1, d2] || undefined : Array +>[d1, d2] : Array >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 : { [x: number]: Base; } ->[d1, d2] : Base[] +>[d1, d2] || undefined : Array +>[d1, d2] : Array >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: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } || undefined : { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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] } : () => Base[] +>undefined || function() { return [d1, d2] } : () => Array >undefined : undefined ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x270: () => Base[] = undefined || function named() { return [d1, d2] }; >x270 : () => Base[] >Base : Base ->undefined || function named() { return [d1, d2] } : () => Base[] +>undefined || function named() { return [d1, d2] } : () => Array >undefined : undefined ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; >x271 : () => Base[] >Base : Base ->undefined || function() { return [d1, d2] } : () => Base[] +>undefined || function() { return [d1, d2] } : () => Array >undefined : undefined ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; >x272 : () => Base[] >Base : Base ->undefined || function named() { return [d1, d2] } : () => Base[] +>undefined || function named() { return [d1, d2] } : () => Array >undefined : undefined ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x273: Base[] = undefined || [d1, d2]; >x273 : Base[] >Base : Base ->undefined || [d1, d2] : Base[] +>undefined || [d1, d2] : Array >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2689,9 +2689,9 @@ var x274: Array = undefined || [d1, d2]; >x274 : Base[] >Array : T[] >Base : Base ->undefined || [d1, d2] : Base[] +>undefined || [d1, d2] : Array >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : { [x: number]: Base; } +>undefined || [d1, d2] : Array >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } +>undefined || { n: [d1, d2] } : { n: Array; } >undefined : undefined ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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] } : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } || function() { return [d1, d2] } : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } || function() { return [d1, d2] } : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x281: Base[] = [d1, d2] || [d1, d2]; >x281 : Base[] >Base : Base ->[d1, d2] || [d1, d2] : Base[] ->[d1, d2] : Base[] +>[d1, d2] || [d1, d2] : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] ->[d1, d2] : Base[] +>[d1, d2] || [d1, d2] : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : { [x: number]: Base; } ->[d1, d2] : Base[] +>[d1, d2] || [d1, d2] : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } || { n: [d1, d2] } : { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; >x285 : () => Base[] >Base : Base ->true ? () => [d1, d2] : () => [d1, d2] : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>true ? () => [d1, d2] : () => [d1, d2] : () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; >x288 : () => Base[] >Base : Base ->true ? () => [d1, d2] : () => [d1, d2] : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>true ? () => [d1, d2] : () => [d1, d2] : () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x291: Base[] = true ? [d1, d2] : [d1, d2]; >x291 : Base[] >Base : Base ->true ? [d1, d2] : [d1, d2] : Base[] ->[d1, d2] : Base[] +>true ? [d1, d2] : [d1, d2] : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] ->[d1, d2] : Base[] +>true ? [d1, d2] : [d1, d2] : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : { [x: number]: Base; } ->[d1, d2] : Base[] +>true ? [d1, d2] : [d1, d2] : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>true ? { n: [d1, d2] } : { n: [d1, d2] } : { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2961,7 +2961,7 @@ var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n = >x295 : (s: Base[]) => any >s : Base[] >Base : Base ->true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (s: Base[]) => any +>true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (n: Base[]) => any >n => { var n: Base[]; return null; } : (n: Base[]) => any >n : Base[] >n : Base[] @@ -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]; } } : Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: 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 >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x297: () => Base[] = true ? undefined : () => [d1, d2]; >x297 : () => Base[] >Base : Base ->true ? undefined : () => [d1, d2] : () => Base[] +>true ? undefined : () => [d1, d2] : () => Array >undefined : undefined ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; >x298 : () => Base[] >Base : Base ->true ? undefined : function() { return [d1, d2] } : () => Base[] +>true ? undefined : function() { return [d1, d2] } : () => Array >undefined : undefined ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] +>true ? undefined : function named() { return [d1, d2] } : () => Array >undefined : undefined ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; >x300 : () => Base[] >Base : Base ->true ? undefined : () => [d1, d2] : () => Base[] +>true ? undefined : () => [d1, d2] : () => Array >undefined : undefined ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; >x301 : () => Base[] >Base : Base ->true ? undefined : function() { return [d1, d2] } : () => Base[] +>true ? undefined : function() { return [d1, d2] } : () => Array >undefined : undefined ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] +>true ? undefined : function named() { return [d1, d2] } : () => Array >undefined : undefined ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x303: Base[] = true ? undefined : [d1, d2]; >x303 : Base[] >Base : Base ->true ? undefined : [d1, d2] : Base[] +>true ? undefined : [d1, d2] : Array >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : Base[] +>true ? undefined : [d1, d2] : Array >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >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] : { [x: number]: Base; } +>true ? undefined : [d1, d2] : Array >undefined : undefined ->[d1, d2] : Base[] +>[d1, d2] : Array >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: Base[]; } +>true ? undefined : { n: [d1, d2] } : { n: Array; } >undefined : undefined ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -3098,7 +3098,7 @@ var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return n >x307 : (s: Base[]) => any >s : Base[] >Base : Base ->true ? undefined : n => { var n: Base[]; return null; } : (s: Base[]) => any +>true ? undefined : n => { var n: Base[]; return null; } : (n: Base[]) => any >undefined : undefined >n => { var n: Base[]; return null; } : (n: Base[]) => any >n : Base[] @@ -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]; } } : Genric +>true ? undefined : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } >undefined : undefined ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 var x309: () => Base[] = true ? () => [d1, d2] : undefined; >x309 : () => Base[] >Base : Base ->true ? () => [d1, d2] : undefined : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>true ? () => [d1, d2] : undefined : () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>true ? function() { return [d1, d2] } : undefined : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>true ? function named() { return [d1, d2] } : undefined : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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 : () => Base[] ->() => [d1, d2] : () => Base[] ->[d1, d2] : Base[] +>true ? () => [d1, d2] : undefined : () => Array +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function() { return [d1, d2] } : () => Base[] ->[d1, d2] : Base[] +>true ? function() { return [d1, d2] } : undefined : () => Array +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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 : () => Base[] ->function named() { return [d1, d2] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>true ? function named() { return [d1, d2] } : undefined : () => Array +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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 : Base[] ->[d1, d2] : Base[] +>true ? [d1, d2] : undefined : Array +>[d1, d2] : Array >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 : Base[] ->[d1, d2] : Base[] +>true ? [d1, d2] : undefined : Array +>[d1, d2] : Array >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 : { [x: number]: Base; } ->[d1, d2] : Base[] +>true ? [d1, d2] : undefined : Array +>[d1, d2] : Array >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: Base[]; } ->{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>true ? { n: [d1, d2] } : undefined : { n: Array; } +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3226,7 +3226,7 @@ var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : und >x319 : (s: Base[]) => any >s : Base[] >Base : Base ->true ? n => { var n: Base[]; return null; } : undefined : (s: Base[]) => any +>true ? n => { var n: Base[]; return null; } : undefined : (n: Base[]) => any >n => { var n: Base[]; return null; } : (n: Base[]) => any >n : Base[] >n : Base[] @@ -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 : Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: 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 >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : () => Base[] ->[d1, d2] : Base[] +>() => [d1, d2] : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->[d1, d2] : Base[] +>function() { return [d1, d2] } : () => Array +>[d1, d2] : Array >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] } : () => Base[] ->named : () => Base[] ->[d1, d2] : Base[] +>function named() { return [d1, d2] } : () => Array +>named : () => Array +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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] : Base[] +>[d1, d2] : Array >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: Base[]; } ->n : Base[] ->[d1, d2] : Base[] +>{ n: [d1, d2] } : { n: Array; } +>n : Array +>[d1, d2] : Array >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[]) => {}[]; } ->func : (n: Base[]) => {}[] ->n => { return [d1, d2]; } : (n: Base[]) => {}[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 diff --git a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types index 2ac2483c405..f16e747d41e 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'] : {}[] +>[true, 1, null, 'yes'] : Array >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericArray0.types b/tests/baselines/reference/genericArray0.types index 80a9d5199bd..bf0155bb9ba 100644 --- a/tests/baselines/reference/genericArray0.types +++ b/tests/baselines/reference/genericArray0.types @@ -16,6 +16,6 @@ function map() { var ys: U[] = []; >ys : U[] >U : U ->[] : U[] +>[] : undefined[] } diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.types b/tests/baselines/reference/genericBaseClassLiteralProperty2.types index b2d156e3c16..9caa45b8b8f 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.types @@ -14,11 +14,11 @@ class BaseCollection2 { constructor() { this._itemsByKey = {}; ->this._itemsByKey = {} : { [x: string]: TItem; } +>this._itemsByKey = {} : { [x: string]: undefined; } >this._itemsByKey : { [x: string]: TItem; } >this : BaseCollection2 >_itemsByKey : { [x: string]: TItem; } ->{} : { [x: string]: TItem; } +>{} : { [x: string]: undefined; } } } diff --git a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types index c79efb0792c..84082a68ebd 100644 --- a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types +++ b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types @@ -25,36 +25,36 @@ var ra = foo([1, 2]); // any[] >ra : any[] >foo([1, 2]) : any[] >foo : (t: T) => T ->[1, 2] : any[] +>[1, 2] : number[] var r2 = foo([]); // any[] >r2 : any[] >foo([]) : any[] >foo : (t: T) => T ->[] : any[] +>[] : undefined[] var r3 = foo([]); // number[] >r3 : number[] >foo([]) : number[] >foo : (t: T) => T ->[] : number[] +>[] : undefined[] var r4 = foo([1, '']); // {}[] ->r4 : {}[] ->foo([1, '']) : {}[] +>r4 : Array +>foo([1, '']) : Array >foo : (t: T) => T ->[1, ''] : {}[] +>[1, ''] : Array var r5 = foo([1, '']); // any[] >r5 : any[] >foo([1, '']) : any[] >foo : (t: T) => T ->[1, ''] : any[] +>[1, ''] : Array var r6 = foo([1, '']); // Object[] >r6 : Object[] >foo([1, '']) : Object[] >foo : (t: T) => T >Object : Object ->[1, ''] : Object[] +>[1, ''] : Array diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt new file mode 100644 index 00000000000..36a22868333 --- /dev/null +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt @@ -0,0 +1,58 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,18): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts (5 errors) ==== + // Generic functions used as arguments for function typed parameters are not used to make inferences from + // Using function arguments, no errors expected + + function foo(x: (a: T) => T) { + return x(null); + } + + var r = foo((x: U) => ''); // {} + var r2 = foo((x: U) => ''); // string + var r3 = foo(x => ''); // {} + + function foo2(x: T, cb: (a: T) => U) { + return cb(x); + } + + var r4 = foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions + var r5 = foo2(1, (a) => ''); // string + var r6 = foo2('', (a: Z) => 1); + + function foo3(x: T, cb: (a: T) => U, y: U) { + return cb(x); + } + + var r7 = foo3(1, (a: Z) => '', ''); // string + + var r8 = foo3(1, function (a) { return '' }, 1); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var r9 = foo3(1, (a) => '', ''); // string + + function other(t: T, u: U) { + var r10 = foo2(1, (x: T) => ''); // error + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r10 = foo2(1, (x) => ''); // string + + var r11 = foo3(1, (x: T) => '', ''); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r11b = foo3(1, (x: T) => '', 1); // error + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r12 = foo3(1, function (a) { return '' }, 1); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.js b/tests/baselines/reference/genericCallWithFunctionTypedArguments.js index 8e844cfbc5a..fed1d4ca990 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.js +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.js @@ -24,16 +24,16 @@ function foo3(x: T, cb: (a: T) => U, y: U) { var r7 = foo3(1, (a: Z) => '', ''); // string -var r8 = foo3(1, function (a) { return '' }, 1); // {} +var r8 = foo3(1, function (a) { return '' }, 1); // error var r9 = foo3(1, (a) => '', ''); // string function other(t: T, u: U) { - var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made + var r10 = foo2(1, (x: T) => ''); // error var r10 = foo2(1, (x) => ''); // string - var r11 = foo3(1, (x: T) => '', ''); // string - var r11b = foo3(1, (x: T) => '', 1); // {} - var r12 = foo3(1, function (a) { return '' }, 1); // {} + var r11 = foo3(1, (x: T) => '', ''); // error + var r11b = foo3(1, (x: T) => '', 1); // error + var r12 = foo3(1, function (a) { return '' }, 1); // error } //// [genericCallWithFunctionTypedArguments.js] @@ -59,14 +59,14 @@ function foo3(x, cb, y) { var r7 = foo3(1, function (a) { return ''; }, ''); // string var r8 = foo3(1, function (a) { return ''; -}, 1); // {} +}, 1); // error var r9 = foo3(1, function (a) { return ''; }, ''); // string function other(t, u) { - var r10 = foo2(1, function (x) { return ''; }); // string, non-generic signature allows inferences to be made + var r10 = foo2(1, function (x) { return ''; }); // error var r10 = foo2(1, function (x) { return ''; }); // string - var r11 = foo3(1, function (x) { return ''; }, ''); // string - var r11b = foo3(1, function (x) { return ''; }, 1); // {} + var r11 = foo3(1, function (x) { return ''; }, ''); // error + var r11b = foo3(1, function (x) { return ''; }, 1); // error var r12 = foo3(1, function (a) { return ''; - }, 1); // {} + }, 1); // error } diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.types b/tests/baselines/reference/genericCallWithFunctionTypedArguments.types deleted file mode 100644 index 2d3b234d0e1..00000000000 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.types +++ /dev/null @@ -1,173 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts === -// Generic functions used as arguments for function typed parameters are not used to make inferences from -// Using function arguments, no errors expected - -function foo(x: (a: T) => T) { ->foo : (x: (a: T) => T) => T ->T : T ->x : (a: T) => T ->a : T ->T : T ->T : T - - return x(null); ->x(null) : T ->x : (a: T) => T -} - -var r = foo((x: U) => ''); // {} ->r : {} ->foo((x: U) => '') : {} ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - -var r2 = foo((x: U) => ''); // string ->r2 : string ->foo((x: U) => '') : string ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - -var r3 = foo(x => ''); // {} ->r3 : {} ->foo(x => '') : {} ->foo : (x: (a: T) => T) => T ->x => '' : (x: {}) => string ->x : {} - -function foo2(x: T, cb: (a: T) => U) { ->foo2 : (x: T, cb: (a: T) => U) => U ->T : T ->U : U ->x : T ->T : T ->cb : (a: T) => U ->a : T ->T : T ->U : U - - return cb(x); ->cb(x) : U ->cb : (a: T) => U ->x : T -} - -var r4 = foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions ->r4 : string ->foo2(1, function (a: Z) { return '' }) : string ->foo2 : (x: T, cb: (a: T) => U) => U ->function (a: Z) { return '' } : (a: Z) => string ->Z : Z ->a : Z ->Z : Z - -var r5 = foo2(1, (a) => ''); // string ->r5 : string ->foo2(1, (a) => '') : string ->foo2 : (x: T, cb: (a: T) => U) => U ->(a) => '' : (a: number) => string ->a : number - -var r6 = foo2('', (a: Z) => 1); ->r6 : number ->foo2('', (a: Z) => 1) : number ->foo2 : (x: T, cb: (a: T) => U) => U ->(a: Z) => 1 : (a: Z) => number ->Z : Z ->a : Z ->Z : Z - -function foo3(x: T, cb: (a: T) => U, y: U) { ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->T : T ->U : U ->x : T ->T : T ->cb : (a: T) => U ->a : T ->T : T ->U : U ->y : U ->U : U - - return cb(x); ->cb(x) : U ->cb : (a: T) => U ->x : T -} - -var r7 = foo3(1, (a: Z) => '', ''); // string ->r7 : string ->foo3(1, (a: Z) => '', '') : string ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(a: Z) => '' : (a: Z) => string ->Z : Z ->a : Z ->Z : Z - -var r8 = foo3(1, function (a) { return '' }, 1); // {} ->r8 : {} ->foo3(1, function (a) { return '' }, 1) : {} ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->function (a) { return '' } : (a: number) => string ->a : number - -var r9 = foo3(1, (a) => '', ''); // string ->r9 : string ->foo3(1, (a) => '', '') : string ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(a) => '' : (a: number) => string ->a : number - -function other(t: T, u: U) { ->other : (t: T, u: U) => void ->T : T ->U : U ->t : T ->T : T ->u : U ->U : U - - var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made ->r10 : string ->foo2(1, (x: T) => '') : string ->foo2 : (x: T, cb: (a: T) => U) => U ->(x: T) => '' : (x: T) => string ->x : T ->T : T - - var r10 = foo2(1, (x) => ''); // string ->r10 : string ->foo2(1, (x) => '') : string ->foo2 : (x: T, cb: (a: T) => U) => U ->(x) => '' : (x: number) => string ->x : number - - var r11 = foo3(1, (x: T) => '', ''); // string ->r11 : string ->foo3(1, (x: T) => '', '') : string ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(x: T) => '' : (x: T) => string ->x : T ->T : T - - var r11b = foo3(1, (x: T) => '', 1); // {} ->r11b : {} ->foo3(1, (x: T) => '', 1) : {} ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(x: T) => '' : (x: T) => string ->x : T ->T : T - - var r12 = foo3(1, function (a) { return '' }, 1); // {} ->r12 : {} ->foo3(1, function (a) { return '' }, 1) : {} ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->function (a) { return '' } : (a: number) => string ->a : number -} diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt new file mode 100644 index 00000000000..083d197bbb4 --- /dev/null +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts (2 errors) ==== + // Generic functions used as arguments for function typed parameters are not used to make inferences from + // Using construct signature arguments, no errors expected + + function foo(x: new(a: T) => T) { + return new x(null); + } + + interface I { + new (x: T): T; + } + interface I2 { + new (x: T): T; + } + var i: I; + var i2: I2; + var a: { + new (x: T): T; + } + + var r = foo(i); // any + var r2 = foo(i); // string + var r3 = foo(i2); // string + var r3b = foo(a); // any + + function foo2(x: T, cb: new(a: T) => U) { + return new cb(x); + } + + var r4 = foo2(1, i2); // error + ~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r4b = foo2(1, a); // any + var r5 = foo2(1, i); // any + var r6 = foo2('', i2); // string + + function foo3(x: T, cb: new(a: T) => U, y: U) { + return new cb(x); + } + + var r7 = foo3(null, i, ''); // any + var r7b = foo3(null, a, ''); // any + var r8 = foo3(1, i2, 1); // error + ~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r9 = foo3('', i2, ''); // string \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.js b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.js index ca9b79c3507..7e9b7886fb4 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.js +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.js @@ -27,7 +27,7 @@ function foo2(x: T, cb: new(a: T) => U) { return new cb(x); } -var r4 = foo2(1, i2); // string, instantiated generic +var r4 = foo2(1, i2); // error var r4b = foo2(1, a); // any var r5 = foo2(1, i); // any var r6 = foo2('', i2); // string @@ -38,7 +38,7 @@ function foo3(x: T, cb: new(a: T) => U, y: U) { var r7 = foo3(null, i, ''); // any var r7b = foo3(null, a, ''); // any -var r8 = foo3(1, i2, 1); // {} +var r8 = foo3(1, i2, 1); // error var r9 = foo3('', i2, ''); // string //// [genericCallWithFunctionTypedArguments2.js] @@ -57,7 +57,7 @@ var r3b = foo(a); // any function foo2(x, cb) { return new cb(x); } -var r4 = foo2(1, i2); // string, instantiated generic +var r4 = foo2(1, i2); // error var r4b = foo2(1, a); // any var r5 = foo2(1, i); // any var r6 = foo2('', i2); // string @@ -66,5 +66,5 @@ function foo3(x, cb, y) { } var r7 = foo3(null, i, ''); // any var r7b = foo3(null, a, ''); // any -var r8 = foo3(1, i2, 1); // {} +var r8 = foo3(1, i2, 1); // error var r9 = foo3('', i2, ''); // string diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types deleted file mode 100644 index 89d7afd94e2..00000000000 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types +++ /dev/null @@ -1,161 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts === -// Generic functions used as arguments for function typed parameters are not used to make inferences from -// Using construct signature arguments, no errors expected - -function foo(x: new(a: T) => T) { ->foo : (x: new (a: T) => T) => T ->T : T ->x : new (a: T) => T ->a : T ->T : T ->T : T - - return new x(null); ->new x(null) : T ->x : new (a: T) => T -} - -interface I { ->I : I - - new (x: T): T; ->T : T ->x : T ->T : T ->T : T -} -interface I2 { ->I2 : I2 ->T : T - - new (x: T): T; ->x : T ->T : T ->T : T -} -var i: I; ->i : I ->I : I - -var i2: I2; ->i2 : I2 ->I2 : I2 - -var a: { ->a : new (x: T) => T - - new (x: T): T; ->T : T ->x : T ->T : T ->T : T -} - -var r = foo(i); // any ->r : any ->foo(i) : any ->foo : (x: new (a: T) => T) => T ->i : I - -var r2 = foo(i); // string ->r2 : string ->foo(i) : string ->foo : (x: new (a: T) => T) => T ->i : I - -var r3 = foo(i2); // string ->r3 : string ->foo(i2) : string ->foo : (x: new (a: T) => T) => T ->i2 : I2 - -var r3b = foo(a); // any ->r3b : any ->foo(a) : any ->foo : (x: new (a: T) => T) => T ->a : new (x: T) => T - -function foo2(x: T, cb: new(a: T) => U) { ->foo2 : (x: T, cb: new (a: T) => U) => U ->T : T ->U : U ->x : T ->T : T ->cb : new (a: T) => U ->a : T ->T : T ->U : U - - return new cb(x); ->new cb(x) : U ->cb : new (a: T) => U ->x : T -} - -var r4 = foo2(1, i2); // string, instantiated generic ->r4 : string ->foo2(1, i2) : string ->foo2 : (x: T, cb: new (a: T) => U) => U ->i2 : I2 - -var r4b = foo2(1, a); // any ->r4b : any ->foo2(1, a) : any ->foo2 : (x: T, cb: new (a: T) => U) => U ->a : new (x: T) => T - -var r5 = foo2(1, i); // any ->r5 : any ->foo2(1, i) : any ->foo2 : (x: T, cb: new (a: T) => U) => U ->i : I - -var r6 = foo2('', i2); // string ->r6 : string ->foo2('', i2) : string ->foo2 : (x: T, cb: new (a: T) => U) => U ->i2 : I2 - -function foo3(x: T, cb: new(a: T) => U, y: U) { ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->T : T ->U : U ->x : T ->T : T ->cb : new (a: T) => U ->a : T ->T : T ->U : U ->y : U ->U : U - - return new cb(x); ->new cb(x) : U ->cb : new (a: T) => U ->x : T -} - -var r7 = foo3(null, i, ''); // any ->r7 : any ->foo3(null, i, '') : any ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->i : I - -var r7b = foo3(null, a, ''); // any ->r7b : any ->foo3(null, a, '') : any ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->a : new (x: T) => T - -var r8 = foo3(1, i2, 1); // {} ->r8 : {} ->foo3(1, i2, 1) : {} ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->i2 : I2 - -var r9 = foo3('', i2, ''); // string ->r9 : string ->foo3('', i2, '') : string ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->i2 : I2 - diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index 7f4fa26aad1..55318f268bd 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -1,51 +1,106 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(14,17): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(24,19): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(36,32): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(10,29): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,36): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(50,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(60,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(67,51): error TS2304: Cannot find name 'U'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(67,57): error TS2304: Cannot find name 'U'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts (4 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts (10 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; - } + module onlyT { + function foo(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } - var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); + var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. - function other2(x: T) { - var r7 = foo((a: T) => a, (b: T) => b); // T => T - // BUG 835518 - var r9 = r7(new Date()); // should be ok - ~~~~~~~~~~ + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); // T => T + // BUG 835518 + var r9 = r7(new Date()); // should be ok + ~~~~~~~~~~ !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. - var r10 = r7(1); // error - ~ + var r10 = r7(1); // error + ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. - } + } - function foo2(a: (x: T) => T, b: (x: T) => T) { - var r: (x: T) => T; - return r; - } + function foo2(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } - function other3(x: T) { - var r7 = foo2((a: T) => a, (b: T) => b); // error - ~~~~~~~~~~~ + function other3(x: T) { + var r7 = foo2((a: T) => a, (b: T) => b); // error + ~~~~~~~~~~~ !!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. - var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date + var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date + } + + enum E { A } + enum F { A } + + function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error + ~~~~~~~~~~ +!!! error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'. } - enum E { A } - enum F { A } + module TU { + function foo(a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } - function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { - var r: (x: T) => T; - return r; - } + var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); - var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error - ~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'. \ No newline at end of file + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); + var r9 = r7(new Date()); + ~~~~~~~~~~ +!!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. + var r10 = r7(1); + ~ +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. + } + + function foo2(a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } + + function other3(x: T) { + var r7 = foo2((a: T) => a, (b: T) => b); + ~~~~~~~~~~~ +!!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. + var r7b = foo2((a) => a, (b) => b); + } + + enum E { A } + enum F { A } + + function foo3(x: T, a: (x: T) => T, b: (x: U) => U) { + ~ +!!! error TS2304: Cannot find name 'U'. + ~ +!!! error TS2304: Cannot find name 'U'. + var r: (x: T) => T; + return r; + } + + var r7 = foo3(E.A, (x) => E.A, (x) => F.A); + } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js index 7dc955b6172..7acdcc32536 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js @@ -2,72 +2,146 @@ // 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; +module onlyT { + function foo(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); + + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); // T => T + // BUG 835518 + var r9 = r7(new Date()); // should be ok + var r10 = r7(1); // error + } + + function foo2(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + function other3(x: T) { + var r7 = foo2((a: T) => a, (b: T) => b); // error + var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date + } + + enum E { A } + enum F { A } + + function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error } -var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); +module TU { + function foo(a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } -function other2(x: T) { - var r7 = foo((a: T) => a, (b: T) => b); // T => T - // BUG 835518 - var r9 = r7(new Date()); // should be ok - var r10 = r7(1); // error -} + var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); -function foo2(a: (x: T) => T, b: (x: T) => T) { - var r: (x: T) => T; - return r; -} + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); + var r9 = r7(new Date()); + var r10 = r7(1); + } -function other3(x: T) { - var r7 = foo2((a: T) => a, (b: T) => b); // error - var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date -} + function foo2(a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } -enum E { A } -enum F { A } + function other3(x: T) { + var r7 = foo2((a: T) => a, (b: T) => b); + var r7b = foo2((a) => a, (b) => b); + } -function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { - var r: (x: T) => T; - return r; -} + enum E { A } + enum F { A } -var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error + function foo3(x: T, a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } + + var r7 = foo3(E.A, (x) => E.A, (x) => F.A); +} //// [genericCallWithGenericSignatureArguments2.js] // 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, b) { - var r; - return r; -} -var r1 = foo(function (x) { return 1; }, function (x) { return ''; }); -function other2(x) { - var r7 = foo(function (a) { return a; }, function (b) { return b; }); // T => T - // BUG 835518 - var r9 = r7(new Date()); // should be ok - var r10 = r7(1); // error -} -function foo2(a, b) { - var r; - return r; -} -function other3(x) { - var r7 = foo2(function (a) { return a; }, function (b) { return b; }); // error - var r7b = foo2(function (a) { return a; }, function (b) { return b; }); // valid, T is inferred to be Date -} -var E; -(function (E) { - E[E["A"] = 0] = "A"; -})(E || (E = {})); -var F; -(function (F) { - F[F["A"] = 0] = "A"; -})(F || (F = {})); -function foo3(x, a, b) { - var r; - return r; -} -var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); // error +var onlyT; +(function (onlyT) { + function foo(a, b) { + var r; + return r; + } + var r1 = foo(function (x) { return 1; }, function (x) { return ''; }); + function other2(x) { + var r7 = foo(function (a) { return a; }, function (b) { return b; }); // T => T + // BUG 835518 + var r9 = r7(new Date()); // should be ok + var r10 = r7(1); // error + } + function foo2(a, b) { + var r; + return r; + } + function other3(x) { + var r7 = foo2(function (a) { return a; }, function (b) { return b; }); // error + var r7b = foo2(function (a) { return a; }, function (b) { return b; }); // valid, T is inferred to be Date + } + var E; + (function (E) { + E[E["A"] = 0] = "A"; + })(E || (E = {})); + var F; + (function (F) { + F[F["A"] = 0] = "A"; + })(F || (F = {})); + function foo3(x, a, b) { + var r; + return r; + } + var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); // error +})(onlyT || (onlyT = {})); +var TU; +(function (TU) { + function foo(a, b) { + var r; + return r; + } + var r1 = foo(function (x) { return 1; }, function (x) { return ''; }); + function other2(x) { + var r7 = foo(function (a) { return a; }, function (b) { return b; }); + var r9 = r7(new Date()); + var r10 = r7(1); + } + function foo2(a, b) { + var r; + return r; + } + function other3(x) { + var r7 = foo2(function (a) { return a; }, function (b) { return b; }); + var r7b = foo2(function (a) { return a; }, function (b) { return b; }); + } + var E; + (function (E) { + E[E["A"] = 0] = "A"; + })(E || (E = {})); + var F; + (function (F) { + F[F["A"] = 0] = "A"; + })(F || (F = {})); + function foo3(x, a, b) { + var r; + return r; + } + var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); +})(TU || (TU = {})); diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.errors.txt new file mode 100644 index 00000000000..0a42d940625 --- /dev/null +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(32,11): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(33,11): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.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(x: T, a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any + var r1ii = foo('', (x) => '', (x) => null); // string => string + var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string + var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object + var r4 = foo(null, (x) => '', (x) => ''); // any => any + var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object + + enum E { A } + enum F { A } + + var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number + + + function foo2(x: T, a: (x: T) => U, b: (x: T) => U) { + var r: (x: T) => U; + return r; + } + + var r8 = foo2('', (x) => '', (x) => null); // string => string + var r9 = foo2(null, (x) => '', (x) => ''); // any => any + var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object + + var x: (a: string) => boolean; + var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js index 8ffb4f9970b..ca28878daa3 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js @@ -30,8 +30,8 @@ var r9 = foo2(null, (x) => '', (x) => ''); // any => any var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object var x: (a: string) => boolean; -var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {} -var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {} +var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error +var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error //// [genericCallWithGenericSignatureArguments3.js] // 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, @@ -63,5 +63,5 @@ var r8 = foo2('', function (x) { return ''; }, function (x) { return null; }); / var r9 = foo2(null, function (x) { return ''; }, function (x) { return ''; }); // any => any var r10 = foo2(null, function (x) { return ''; }, function (x) { return ''; }); // Object => Object var x; -var r11 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // {} => {} -var r12 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // (string => boolean) => {} +var r11 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // error +var r12 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // error diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types deleted file mode 100644 index 2c0d21a5a07..00000000000 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types +++ /dev/null @@ -1,202 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.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(x: T, a: (x: T) => T, b: (x: T) => T) { ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->T : T ->x : 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: string) => '', (x: Object) => null); // any => any ->r1 : (x: any) => any ->foo('', (x: string) => '', (x: Object) => null) : (x: any) => any ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: string) => '' : (x: string) => string ->x : string ->(x: Object) => null : (x: Object) => any ->x : Object ->Object : Object - -var r1ii = foo('', (x) => '', (x) => null); // string => string ->r1ii : (x: string) => string ->foo('', (x) => '', (x) => null) : (x: string) => string ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x) => '' : (x: string) => string ->x : string ->(x) => null : (x: string) => any ->x : string - -var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string ->r2 : (x: Object) => Object ->foo('', (x: string) => '', (x: Object) => '') : (x: Object) => Object ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: string) => '' : (x: string) => string ->x : string ->(x: Object) => '' : (x: Object) => string ->x : Object ->Object : Object - -var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object ->r3 : (x: Object) => Object ->foo(null, (x: Object) => '', (x: string) => '') : (x: Object) => Object ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: Object) => '' : (x: Object) => string ->x : Object ->Object : Object ->(x: string) => '' : (x: string) => string ->x : string - -var r4 = foo(null, (x) => '', (x) => ''); // any => any ->r4 : (x: any) => any ->foo(null, (x) => '', (x) => '') : (x: any) => any ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x) => '' : (x: any) => string ->x : any ->(x) => '' : (x: any) => string ->x : any - -var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object ->r5 : (x: Object) => Object ->foo(new Object(), (x) => '', (x) => '') : (x: Object) => Object ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->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[]; } ->(x) => '' : (x: Object) => string ->x : Object ->(x) => '' : (x: Object) => string ->x : Object - -enum E { A } ->E : E ->A : E - -enum F { A } ->F : F ->A : F - -var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number ->r6 : (x: number) => number ->foo(E.A, (x: number) => E.A, (x: F) => F.A) : (x: number) => number ->foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->E.A : E ->E : typeof E ->A : E ->(x: number) => E.A : (x: number) => E ->x : number ->E.A : E ->E : typeof E ->A : E ->(x: F) => F.A : (x: F) => F ->x : F ->F : F ->F.A : F ->F : typeof F ->A : F - - -function foo2(x: T, a: (x: T) => U, b: (x: T) => U) { ->foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U ->T : T ->U : U ->x : T ->T : T ->a : (x: T) => U ->x : T ->T : T ->U : U ->b : (x: T) => U ->x : T ->T : T ->U : U - - var r: (x: T) => U; ->r : (x: T) => U ->x : T ->T : T ->U : U - - return r; ->r : (x: T) => U -} - -var r8 = foo2('', (x) => '', (x) => null); // string => string ->r8 : (x: string) => any ->foo2('', (x) => '', (x) => null) : (x: string) => any ->foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U ->(x) => '' : (x: string) => string ->x : string ->(x) => null : (x: string) => any ->x : string - -var r9 = foo2(null, (x) => '', (x) => ''); // any => any ->r9 : (x: any) => string ->foo2(null, (x) => '', (x) => '') : (x: any) => string ->foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U ->(x) => '' : (x: any) => string ->x : any ->(x) => '' : (x: any) => string ->x : any - -var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object ->r10 : (x: Object) => string ->foo2(null, (x: Object) => '', (x: string) => '') : (x: Object) => string ->foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U ->(x: Object) => '' : (x: Object) => string ->x : Object ->Object : Object ->(x: string) => '' : (x: string) => string ->x : string - -var x: (a: string) => boolean; ->x : (a: string) => boolean ->a : string - -var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {} ->r11 : (x: {}) => {} ->foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2) : (x: {}) => {} ->foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U ->x : (a: string) => boolean ->(a1: (y: string) => string) => (n: Object) => 1 : (a1: (y: string) => string) => (n: Object) => number ->a1 : (y: string) => string ->y : string ->(n: Object) => 1 : (n: Object) => number ->n : Object ->Object : Object ->(a2: (z: string) => string) => 2 : (a2: (z: string) => string) => number ->a2 : (z: string) => string ->z : string - -var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {} ->r12 : (x: (a: string) => boolean) => {} ->foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2) : (x: (a: string) => boolean) => {} ->foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U ->x : (a: string) => boolean ->(a1: (y: string) => boolean) => (n: Object) => 1 : (a1: (y: string) => boolean) => (n: Object) => number ->a1 : (y: string) => boolean ->y : string ->(n: Object) => 1 : (n: Object) => number ->n : Object ->Object : Object ->(a2: (z: string) => boolean) => 2 : (a2: (z: string) => boolean) => number ->a2 : (z: string) => boolean ->z : string - diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt new file mode 100644 index 00000000000..856f35a57f6 --- /dev/null +++ b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ==== + function foo(x: { bar: T; baz: T }) { + return x; + } + + var r = foo({ bar: 1, baz: '' }); // error + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r2 = foo({ bar: 1, baz: 1 }); // T = number + var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo + var r4 = foo({ bar: 1, baz: '' }); // T = Object \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.js b/tests/baselines/reference/genericCallWithObjectLiteralArgs.js index 84a630425be..2515bbef293 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArgs.js +++ b/tests/baselines/reference/genericCallWithObjectLiteralArgs.js @@ -3,7 +3,7 @@ function foo(x: { bar: T; baz: T }) { return x; } -var r = foo({ bar: 1, baz: '' }); // T = {} +var r = foo({ bar: 1, baz: '' }); // error var r2 = foo({ bar: 1, baz: 1 }); // T = number var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo var r4 = foo({ bar: 1, baz: '' }); // T = Object @@ -12,7 +12,7 @@ var r4 = foo({ bar: 1, baz: '' }); // T = Object function foo(x) { return x; } -var r = foo({ bar: 1, baz: '' }); // T = {} +var r = foo({ bar: 1, baz: '' }); // error var r2 = foo({ bar: 1, baz: 1 }); // T = number var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo var r4 = foo({ bar: 1, baz: '' }); // T = Object diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.types b/tests/baselines/reference/genericCallWithObjectLiteralArgs.types deleted file mode 100644 index d23445ecbca..00000000000 --- a/tests/baselines/reference/genericCallWithObjectLiteralArgs.types +++ /dev/null @@ -1,49 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts === -function foo(x: { bar: T; baz: T }) { ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->T : T ->x : { bar: T; baz: T; } ->bar : T ->T : T ->baz : T ->T : T - - return x; ->x : { bar: T; baz: T; } -} - -var r = foo({ bar: 1, baz: '' }); // T = {} ->r : { bar: {}; baz: {}; } ->foo({ bar: 1, baz: '' }) : { bar: {}; baz: {}; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->{ bar: 1, baz: '' } : { bar: number; baz: string; } ->bar : number ->baz : string - -var r2 = foo({ bar: 1, baz: 1 }); // T = number ->r2 : { bar: number; baz: number; } ->foo({ bar: 1, baz: 1 }) : { bar: number; baz: number; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->{ bar: 1, baz: 1 } : { bar: number; baz: number; } ->bar : number ->baz : number - -var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo ->r3 : { bar: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; } ->foo({ bar: foo, baz: foo }) : { bar: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->{ bar: foo, baz: foo } : { bar: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; } ->bar : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->baz : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } - -var r4 = foo({ bar: 1, baz: '' }); // T = Object ->r4 : { bar: Object; baz: Object; } ->foo({ bar: 1, baz: '' }) : { bar: Object; baz: Object; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->Object : Object ->{ bar: 1, baz: '' } : { bar: number; baz: string; } ->bar : number ->baz : string - diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt index 3b3f8d43ff9..4ac64500bd1 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(2,9): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. Types of property 'y' are incompatible: Type 'string' is not assignable to type 'number'. @@ -12,9 +13,11 @@ tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS23 Type 'number' is not assignable to type 'string'. -==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (4 errors) ==== +==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (5 errors) ==== function foo(n: { x: T; y: T }, m: T) { return m; } var x = foo({ x: 3, y: "" }, 4); // no error, x is Object, the best common type + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. // these are all errors var x2 = foo({ x: 3, y: "" }, 4); ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgs.errors.txt new file mode 100644 index 00000000000..dce9562a8f5 --- /dev/null +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts(20,9): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts (1 errors) ==== + class C { + private x: string; + } + + class D { + private x: string; + } + + class X { + x: T; + } + + function foo(t: X, t2: X) { + var x: T; + return x; + } + + var c1 = new X(); + var d1 = new X(); + var r = foo(c1, d1); // error + ~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r2 = foo(c1, c1); // ok \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs.types b/tests/baselines/reference/genericCallWithObjectTypeArgs.types deleted file mode 100644 index ddbd7d83054..00000000000 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs.types +++ /dev/null @@ -1,68 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts === -class C { ->C : C - - private x: string; ->x : string -} - -class D { ->D : D - - private x: string; ->x : string -} - -class X { ->X : X ->T : T - - x: T; ->x : T ->T : T -} - -function foo(t: X, t2: X) { ->foo : (t: X, t2: X) => T ->T : T ->t : X ->X : X ->T : T ->t2 : X ->X : X ->T : T - - var x: T; ->x : T ->T : T - - return x; ->x : T -} - -var c1 = new X(); ->c1 : X ->new X() : X ->X : typeof X ->C : C - -var d1 = new X(); ->d1 : X ->new X() : X ->X : typeof X ->D : D - -var r = foo(c1, d1); // error ->r : {} ->foo(c1, d1) : {} ->foo : (t: X, t2: X) => T ->c1 : X ->d1 : X - -var r2 = foo(c1, c1); // ok ->r2 : C ->foo(c1, c1) : C ->foo : (t: X, t2: X) => T ->c1 : X ->c1 : X - diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.types b/tests/baselines/reference/genericCallWithObjectTypeArgs2.types index 0065811fdc1..aa1eeaf4670 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; }) => {}[] +>f : (a: { x: T; y: U; }) => Array >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] : {}[] +>[a.x, a.y] : Array >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 : {}[] ->f({ x: new Derived(), y: new Derived2() }) : {}[] ->f : (a: { x: T; y: U; }) => {}[] +>r : Array +>f({ x: new Derived(), y: new Derived2() }) : Array +>f : (a: { x: T; y: U; }) => Array >{ x: new Derived(), y: new Derived2() } : { x: Derived; y: Derived2; } >x : Derived >new Derived() : Derived @@ -56,9 +56,9 @@ var r = f({ x: new Derived(), y: new Derived2() }); // {}[] >Derived2 : typeof Derived2 var r2 = f({ x: new Base(), y: new Derived2() }); // {}[] ->r2 : {}[] ->f({ x: new Base(), y: new Derived2() }) : {}[] ->f : (a: { x: T; y: U; }) => {}[] +>r2 : Base[] +>f({ x: new Base(), y: new Derived2() }) : Array +>f : (a: { x: T; y: U; }) => Array >{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; } >x : Base >new Base() : Base diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt index c41ca0e8875..9cb190ddecd 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt @@ -1,7 +1,8 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,10): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(20,29): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (2 errors) ==== // Generic call with constraints infering type parameter from object member properties class Base { @@ -20,6 +21,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj } var r1 = f({ x: new Derived(), y: new Derived2() }); // ok, both extend Base + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. function f2(a: U) { ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.errors.txt new file mode 100644 index 00000000000..3ddb094970a --- /dev/null +++ b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts(36,14): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts (1 errors) ==== + // Function typed arguments with multiple signatures must be passed an implementation that matches all of them + // Inferences are made quadratic-pairwise to and from these overload sets + + module NonGenericParameter { + var a: { + new(x: boolean): boolean; + new(x: string): string; + } + + function foo4(cb: typeof a) { + return new cb(null); + } + + var r = foo4(a); + var b: { new (x: T): T }; + var r2 = foo4(b); + } + + module GenericParameter { + function foo5(cb: { new(x: T): string; new(x: number): T }) { + return cb; + } + + var a: { + new (x: boolean): string; + new (x: number): boolean; + } + var r5 = foo5(a); // new{} => string; new(x:number) => {} + var b: { new(x: T): string; new(x: number): T; } + var r7 = foo5(b); // new any => string; new(x:number) => any + + function foo6(cb: { new(x: T): string; new(x: T, y?: T): string }) { + return cb; + } + + var r8 = foo6(a); // error + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string + + function foo7(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) { + return cb; + } + + var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string + var c: { new (x: T): string; (x: number): T; } + var c2: { new (x: T): string; new(x: number): T; } + var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string + var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string + } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.js b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.js index 9da34ebad86..4f74b043bd9 100644 --- a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.js +++ b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.js @@ -34,7 +34,7 @@ module GenericParameter { return cb; } - var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string + var r8 = foo6(a); // error var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string function foo7(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) { @@ -73,7 +73,7 @@ var GenericParameter; function foo6(cb) { return cb; } - var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string + var r8 = foo6(a); // error var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string function foo7(x, cb) { return cb; diff --git a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.types b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.types deleted file mode 100644 index 6c16ad0259c..00000000000 --- a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.types +++ /dev/null @@ -1,173 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts === -// Function typed arguments with multiple signatures must be passed an implementation that matches all of them -// Inferences are made quadratic-pairwise to and from these overload sets - -module NonGenericParameter { ->NonGenericParameter : typeof NonGenericParameter - - var a: { ->a : { new (x: boolean): boolean; new (x: string): string; } - - new(x: boolean): boolean; ->x : boolean - - new(x: string): string; ->x : string - } - - function foo4(cb: typeof a) { ->foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean ->cb : { new (x: boolean): boolean; new (x: string): string; } ->a : { new (x: boolean): boolean; new (x: string): string; } - - return new cb(null); ->new cb(null) : boolean ->cb : { new (x: boolean): boolean; new (x: string): string; } - } - - var r = foo4(a); ->r : boolean ->foo4(a) : boolean ->foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean ->a : { new (x: boolean): boolean; new (x: string): string; } - - var b: { new (x: T): T }; ->b : new (x: T) => T ->T : T ->x : T ->T : T ->T : T - - var r2 = foo4(b); ->r2 : boolean ->foo4(b) : boolean ->foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean ->b : new (x: T) => T -} - -module GenericParameter { ->GenericParameter : typeof GenericParameter - - function foo5(cb: { new(x: T): string; new(x: number): T }) { ->foo5 : (cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; } ->T : T ->cb : { new (x: T): string; new (x: number): T; } ->x : T ->T : T ->x : number ->T : T - - return cb; ->cb : { new (x: T): string; new (x: number): T; } - } - - var a: { ->a : { new (x: boolean): string; new (x: number): boolean; } - - new (x: boolean): string; ->x : boolean - - new (x: number): boolean; ->x : number - } - var r5 = foo5(a); // new{} => string; new(x:number) => {} ->r5 : { new (x: boolean): string; new (x: number): boolean; } ->foo5(a) : { new (x: boolean): string; new (x: number): boolean; } ->foo5 : (cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; } ->a : { new (x: boolean): string; new (x: number): boolean; } - - var b: { new(x: T): string; new(x: number): T; } ->b : { new (x: T): string; new (x: number): T; } ->T : T ->x : T ->T : T ->T : T ->x : number ->T : T - - var r7 = foo5(b); // new any => string; new(x:number) => any ->r7 : { new (x: any): string; new (x: number): any; } ->foo5(b) : { new (x: any): string; new (x: number): any; } ->foo5 : (cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; } ->b : { new (x: T): string; new (x: number): T; } - - function foo6(cb: { new(x: T): string; new(x: T, y?: T): string }) { ->foo6 : (cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->T : T ->cb : { new (x: T): string; new (x: T, y?: T): string; } ->x : T ->T : T ->x : T ->T : T ->y : T ->T : T - - return cb; ->cb : { new (x: T): string; new (x: T, y?: T): string; } - } - - var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string ->r8 : { new (x: {}): string; new (x: {}, y?: {}): string; } ->foo6(a) : { new (x: {}): string; new (x: {}, y?: {}): string; } ->foo6 : (cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->a : { new (x: boolean): string; new (x: number): boolean; } - - var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string ->r9 : { new (x: any): string; new (x: any, y?: any): string; } ->foo6(b) : { new (x: any): string; new (x: any, y?: any): string; } ->foo6 : (cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->b : { new (x: T): string; new (x: number): T; } - - function foo7(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) { ->foo7 : (x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->T : T ->x : T ->T : T ->cb : { new (x: T): string; new (x: T, y?: T): string; } ->x : T ->T : T ->x : T ->T : T ->y : T ->T : T - - return cb; ->cb : { new (x: T): string; new (x: T, y?: T): string; } - } - - var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string ->r13 : { new (x: any): string; new (x: any, y?: any): string; } ->foo7(1, b) : { new (x: any): string; new (x: any, y?: any): string; } ->foo7 : (x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->b : { new (x: T): string; new (x: number): T; } - - var c: { new (x: T): string; (x: number): T; } ->c : { (x: number): T; new (x: T): string; } ->T : T ->x : T ->T : T ->T : T ->x : number ->T : T - - var c2: { new (x: T): string; new(x: number): T; } ->c2 : { new (x: T): string; new (x: number): T; } ->T : T ->x : T ->T : T ->T : T ->x : number ->T : T - - var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string ->r14 : { new (x: any): string; new (x: any, y?: any): string; } ->foo7(1, c) : { new (x: any): string; new (x: any, y?: any): string; } ->foo7 : (x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->c : { (x: number): T; new (x: T): string; } - - var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string ->r15 : { new (x: any): string; new (x: any, y?: any): string; } ->foo7(1, c2) : { new (x: any): string; new (x: any, y?: any): string; } ->foo7 : (x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->c2 : { new (x: T): string; new (x: number): T; } -} diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index 8ddeb93435f..abfe5087131 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -1,3 +1,11 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(12,1): error TS2322: Type '[string, number, boolean, boolean]' is not assignable to type '[string, number]': + Types of property 'pop' are incompatible: + Type '() => string | number | boolean' is not assignable to type '() => string | number': + Type 'string | number | boolean' is not assignable to type 'string | number': + Type 'boolean' is not assignable to type 'string | number': + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number': + Type '{ a: string; }' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]': Types of property '0' are incompatible: Type 'number' is not assignable to type 'string'. @@ -8,7 +16,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup Property '1' is missing in type '[{}]'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (5 errors) ==== interface I { tuple1: [T, U]; } @@ -21,8 +29,18 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup var e1 = i1.tuple1[0]; // string var e2 = i1.tuple1[1]; // number i1.tuple1 = ["foo", 5, false, true]; + ~~~~~~~~~ +!!! error TS2322: Type '[string, number, boolean, boolean]' is not assignable to type '[string, number]': +!!! error TS2322: Types of property 'pop' are incompatible: +!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number': +!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number': +!!! error TS2322: Type 'boolean' is not assignable to type 'string | number': +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. var e3 = i1.tuple1[2]; // {} i1.tuple1[3] = { a: "string" }; + ~~~~~~~~~~~~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type 'string | number': +!!! error TS2322: Type '{ a: string; }' is not assignable to type 'number'. var e4 = i1.tuple1[3]; // {} i2.tuple1 = ["foo", 5]; i2.tuple1 = ["foo", "bar"]; diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt new file mode 100644 index 00000000000..30ed4bc431f --- /dev/null +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,19): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,19): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,20): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,30): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts (4 errors) ==== + // Generic functions used as arguments for function typed parameters are not used to make inferences from + // Using function arguments, no errors expected + + module ImmediatelyFix { + class C { + foo(x: (a: T) => T) { + return x(null); + } + } + + var c = new C(); + var r = c.foo((x: U) => ''); // {} + var r2 = c.foo((x: U) => ''); // string + var r3 = c.foo(x => ''); // {} + + class C2 { + foo(x: (a: T) => T) { + return x(null); + } + } + + var c2 = new C2(); + var ra = c2.foo((x: U) => 1); // number + var r3a = c2.foo(x => 1); // number + } + + module WithCandidates { + class C { + foo2(x: T, cb: (a: T) => U) { + return cb(x); + } + } + + var c: C; + var r4 = c.foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions + var r5 = c.foo2(1, (a) => ''); // string + var r6 = c.foo2('', (a: Z) => 1); // number + + class C2 { + foo3(x: T, cb: (a: T) => U, y: U) { + return cb(x); + } + } + + var c2: C2; + var r7 = c2.foo3(1, (a: Z) => '', ''); // string + var r8 = c2.foo3(1, function (a) { return '' }, ''); // string + + class C3 { + foo3(x: T, cb: (a: T) => U, y: U) { + return cb(x); + } + } + var c3: C3; + + function other(t: T, u: U) { + var r10 = c.foo2(1, (x: T) => ''); // error + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r10 = c.foo2(1, (x) => ''); // string + + var r11 = c3.foo3(1, (x: T) => '', ''); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r11b = c3.foo3(1, (x: T) => '', 1); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r12 = c3.foo3(1, function (a) { return '' }, 1); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.js b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.js index 1af5f0ea6e6..7ec25949534 100644 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.js +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.js @@ -55,12 +55,12 @@ module WithCandidates { var c3: C3; function other(t: T, u: U) { - var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made + var r10 = c.foo2(1, (x: T) => ''); // error var r10 = c.foo2(1, (x) => ''); // string - var r11 = c3.foo3(1, (x: T) => '', ''); // string - var r11b = c3.foo3(1, (x: T) => '', 1); // {} - var r12 = c3.foo3(1, function (a) { return '' }, 1); // {} + var r11 = c3.foo3(1, (x: T) => '', ''); // error + var r11b = c3.foo3(1, (x: T) => '', 1); // error + var r12 = c3.foo3(1, function (a) { return '' }, 1); // error } } @@ -132,12 +132,12 @@ var WithCandidates; })(); var c3; function other(t, u) { - var r10 = c.foo2(1, function (x) { return ''; }); // string, non-generic signature allows inferences to be made + var r10 = c.foo2(1, function (x) { return ''; }); // error var r10 = c.foo2(1, function (x) { return ''; }); // string - var r11 = c3.foo3(1, function (x) { return ''; }, ''); // string - var r11b = c3.foo3(1, function (x) { return ''; }, 1); // {} + var r11 = c3.foo3(1, function (x) { return ''; }, ''); // error + var r11b = c3.foo3(1, function (x) { return ''; }, 1); // error var r12 = c3.foo3(1, function (a) { return ''; - }, 1); // {} + }, 1); // error } })(WithCandidates || (WithCandidates = {})); diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.types b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.types deleted file mode 100644 index 68b94d81d02..00000000000 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.types +++ /dev/null @@ -1,297 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts === -// Generic functions used as arguments for function typed parameters are not used to make inferences from -// Using function arguments, no errors expected - -module ImmediatelyFix { ->ImmediatelyFix : typeof ImmediatelyFix - - class C { ->C : C ->T : T - - foo(x: (a: T) => T) { ->foo : (x: (a: T) => T) => T ->T : T ->x : (a: T) => T ->a : T ->T : T ->T : T - - return x(null); ->x(null) : T ->x : (a: T) => T - } - } - - var c = new C(); ->c : C ->new C() : C ->C : typeof C - - var r = c.foo((x: U) => ''); // {} ->r : {} ->c.foo((x: U) => '') : {} ->c.foo : (x: (a: T) => T) => T ->c : C ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - - var r2 = c.foo((x: U) => ''); // string ->r2 : string ->c.foo((x: U) => '') : string ->c.foo : (x: (a: T) => T) => T ->c : C ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - - var r3 = c.foo(x => ''); // {} ->r3 : {} ->c.foo(x => '') : {} ->c.foo : (x: (a: T) => T) => T ->c : C ->foo : (x: (a: T) => T) => T ->x => '' : (x: {}) => string ->x : {} - - class C2 { ->C2 : C2 ->T : T - - foo(x: (a: T) => T) { ->foo : (x: (a: T) => T) => T ->x : (a: T) => T ->a : T ->T : T ->T : T - - return x(null); ->x(null) : T ->x : (a: T) => T - } - } - - var c2 = new C2(); ->c2 : C2 ->new C2() : C2 ->C2 : typeof C2 - - var ra = c2.foo((x: U) => 1); // number ->ra : number ->c2.foo((x: U) => 1) : number ->c2.foo : (x: (a: number) => number) => number ->c2 : C2 ->foo : (x: (a: number) => number) => number ->(x: U) => 1 : (x: U) => number ->U : U ->x : U ->U : U - - var r3a = c2.foo(x => 1); // number ->r3a : number ->c2.foo(x => 1) : number ->c2.foo : (x: (a: number) => number) => number ->c2 : C2 ->foo : (x: (a: number) => number) => number ->x => 1 : (x: number) => number ->x : number -} - -module WithCandidates { ->WithCandidates : typeof WithCandidates - - class C { ->C : C ->T : T - - foo2(x: T, cb: (a: T) => U) { ->foo2 : (x: T, cb: (a: T) => U) => U ->T : T ->U : U ->x : T ->T : T ->cb : (a: T) => U ->a : T ->T : T ->U : U - - return cb(x); ->cb(x) : U ->cb : (a: T) => U ->x : T - } - } - - var c: C; ->c : C ->C : C - - var r4 = c.foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions ->r4 : string ->c.foo2(1, function (a: Z) { return '' }) : string ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->function (a: Z) { return '' } : (a: Z) => string ->Z : Z ->a : Z ->Z : Z - - var r5 = c.foo2(1, (a) => ''); // string ->r5 : string ->c.foo2(1, (a) => '') : string ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->(a) => '' : (a: number) => string ->a : number - - var r6 = c.foo2('', (a: Z) => 1); // number ->r6 : number ->c.foo2('', (a: Z) => 1) : number ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->(a: Z) => 1 : (a: Z) => number ->Z : Z ->a : Z ->Z : Z - - class C2 { ->C2 : C2 ->T : T ->U : U - - foo3(x: T, cb: (a: T) => U, y: U) { ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->x : T ->T : T ->cb : (a: T) => U ->a : T ->T : T ->U : U ->y : U ->U : U - - return cb(x); ->cb(x) : U ->cb : (a: T) => U ->x : T - } - } - - var c2: C2; ->c2 : C2 ->C2 : C2 - - var r7 = c2.foo3(1, (a: Z) => '', ''); // string ->r7 : string ->c2.foo3(1, (a: Z) => '', '') : string ->c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string ->c2 : C2 ->foo3 : (x: number, cb: (a: number) => string, y: string) => string ->(a: Z) => '' : (a: Z) => string ->Z : Z ->a : Z ->Z : Z - - var r8 = c2.foo3(1, function (a) { return '' }, ''); // string ->r8 : string ->c2.foo3(1, function (a) { return '' }, '') : string ->c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string ->c2 : C2 ->foo3 : (x: number, cb: (a: number) => string, y: string) => string ->function (a) { return '' } : (a: number) => string ->a : number - - class C3 { ->C3 : C3 ->T : T ->U : U - - foo3(x: T, cb: (a: T) => U, y: U) { ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->T : T ->U : U ->x : T ->T : T ->cb : (a: T) => U ->a : T ->T : T ->U : U ->y : U ->U : U - - return cb(x); ->cb(x) : U ->cb : (a: T) => U ->x : T - } - } - var c3: C3; ->c3 : C3 ->C3 : C3 - - function other(t: T, u: U) { ->other : (t: T, u: U) => void ->T : T ->U : U ->t : T ->T : T ->u : U ->U : U - - var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made ->r10 : string ->c.foo2(1, (x: T) => '') : string ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->(x: T) => '' : (x: T) => string ->x : T ->T : T - - var r10 = c.foo2(1, (x) => ''); // string ->r10 : string ->c.foo2(1, (x) => '') : string ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->(x) => '' : (x: number) => string ->x : number - - var r11 = c3.foo3(1, (x: T) => '', ''); // string ->r11 : string ->c3.foo3(1, (x: T) => '', '') : string ->c3.foo3 : (x: T, cb: (a: T) => U, y: U) => U ->c3 : C3 ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(x: T) => '' : (x: T) => string ->x : T ->T : T - - var r11b = c3.foo3(1, (x: T) => '', 1); // {} ->r11b : {} ->c3.foo3(1, (x: T) => '', 1) : {} ->c3.foo3 : (x: T, cb: (a: T) => U, y: U) => U ->c3 : C3 ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(x: T) => '' : (x: T) => string ->x : T ->T : T - - var r12 = c3.foo3(1, function (a) { return '' }, 1); // {} ->r12 : {} ->c3.foo3(1, function (a) { return '' }, 1) : {} ->c3.foo3 : (x: T, cb: (a: T) => U, y: U) => U ->c3 : C3 ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->function (a) { return '' } : (a: number) => string ->a : number - } -} diff --git a/tests/baselines/reference/genericRestArgs.errors.txt b/tests/baselines/reference/genericRestArgs.errors.txt index db36a9a0162..49f61de325f 100644 --- a/tests/baselines/reference/genericRestArgs.errors.txt +++ b/tests/baselines/reference/genericRestArgs.errors.txt @@ -1,10 +1,14 @@ +tests/cases/compiler/genericRestArgs.ts(2,12): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/genericRestArgs.ts(10,12): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'. -==== tests/cases/compiler/genericRestArgs.ts (2 errors) ==== +==== tests/cases/compiler/genericRestArgs.ts (4 errors) ==== function makeArrayG(...items: T[]): T[] { return items; } var a1Ga = makeArrayG(1, ""); // no error + ~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var a1Gb = makeArrayG(1, ""); var a1Gc = makeArrayG(1, ""); var a1Gd = makeArrayG(1, ""); // error @@ -15,6 +19,8 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type ' return [item1, item2, item3]; } var a2Ga = makeArrayGOpt(1, ""); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var a2Gb = makeArrayG(1, ""); var a2Gc = makeArrayG(1, ""); // error ~ diff --git a/tests/baselines/reference/genericTypeArgumentInference1.types b/tests/baselines/reference/genericTypeArgumentInference1.types index 20a9a0ca8f9..be7a3e9226d 100644 --- a/tests/baselines/reference/genericTypeArgumentInference1.types +++ b/tests/baselines/reference/genericTypeArgumentInference1.types @@ -42,12 +42,12 @@ declare var _: Underscore.Static; >Static : Underscore.Static var r = _.all([true, 1, null, 'yes'], _.identity); ->r : {} ->_.all([true, 1, null, 'yes'], _.identity) : {} +>r : string | number | boolean +>_.all([true, 1, null, 'yes'], _.identity) : string | number | boolean >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true, 1, null, 'yes'] : {}[] +>[true, 1, null, 'yes'] : Array >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T @@ -69,7 +69,7 @@ var r3 = _.all([], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[] : any[] +>[] : undefined[] >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types index 05697f1e1f9..f0cab6e7467 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types @@ -8,7 +8,7 @@ class LazyArray { ><{ [objectId: string]: T; }>{} : { [x: string]: T; } >objectId : string >T : T ->{} : { [x: string]: T; } +>{} : { [x: string]: undefined; } array() { >array : () => { [x: string]: T; } diff --git a/tests/baselines/reference/genericsManyTypeParameters.types b/tests/baselines/reference/genericsManyTypeParameters.types index 65f9a7c115e..df2144de866 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) => {}[] +>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 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] : {}[] +>[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 : a1 >y1 : a21 >z1 : a31 diff --git a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt index 072d06e8686..985aaa7948c 100644 --- a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt +++ b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt @@ -1,5 +1,6 @@ -tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'string[]'. - Type '{}' is not assignable to type 'string'. +tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type 'Array' 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'. ==== tests/cases/compiler/heterogeneousArrayAndOverloads.ts (1 errors) ==== @@ -13,7 +14,8 @@ tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argu this.test([]); this.test([1, 2, "hi", 5]); // Error ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'string[]'. -!!! error TS2345: Type '{}' is not assignable to type 'string'. +!!! error TS2345: Argument of type 'Array' 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'. } } \ No newline at end of file diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 81770731633..c236fe7ff6d 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 : {}[] ->[1, ''] : {}[] +>a : Array +>[1, ''] : Array var b = [1, null]; // number[] >b : number[] >[1, null] : number[] var c = [1, '', null]; // {}[] ->c : {}[] ->[1, '', null] : {}[] +>c : Array +>[1, '', null] : Array var d = [{}, 1]; // {}[] >d : {}[] @@ -31,8 +31,8 @@ var f = [[], [1]]; // number[][] >[1] : number[] var g = [[1], ['']]; // {}[] ->g : {}[] ->[[1], ['']] : {}[] +>g : Array +>[[1], ['']] : Array >[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 : {}[] ->[{ foo: 1, bar: '' }, { foo: '' }] : {}[] +>i : Array<{ foo: number; bar: string; } | { foo: string; }> +>[{ foo: 1, bar: '' }, { foo: '' }] : Array<{ foo: number; bar: string; } | { foo: string; }> >{ foo: 1, bar: '' } : { foo: number; bar: string; } >foo : number >bar : string @@ -55,8 +55,8 @@ var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[] >foo : string var j = [() => 1, () => '']; // {}[] ->j : {}[] ->[() => 1, () => ''] : {}[] +>j : Array<{ (): number; } | { (): string; }> +>[() => 1, () => ''] : Array<{ (): number; } | { (): string; }> >() => 1 : () => number >() => '' : () => string @@ -80,8 +80,8 @@ var m = [() => 1, () => '', () => null]; // { (): any }[] >() => null : () => any var n = [[() => 1], [() => '']]; // {}[] ->n : {}[] ->[[() => 1], [() => '']] : {}[] +>n : Array<{ (): number; }[] | { (): string; }[]> +>[[() => 1], [() => '']] : Array<{ (): number; }[] | { (): string; }[]> >[() => 1] : { (): number; }[] >() => 1 : () => number >[() => ''] : { (): string; }[] @@ -129,8 +129,8 @@ module Derived { >base : Base var i = [{ foo: base, basear: derived }, { foo: derived }]; // {foo: Derived}[] ->i : {}[] ->[{ foo: base, basear: derived }, { foo: derived }] : {}[] +>i : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }> +>[{ foo: base, basear: derived }, { foo: derived }] : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }> >{ foo: base, basear: derived } : { foo: Base; basear: Derived; } >foo : Base >base : Base @@ -149,8 +149,8 @@ module Derived { >derived : Derived var k = [() => base, () => 1]; // {}[]~ ->k : {}[] ->[() => base, () => 1] : {}[] +>k : Array<{ (): Base; } | { (): number; }> +>[() => base, () => 1] : Array<{ (): Base; } | { (): number; }> >() => base : () => Base >base : Base >() => 1 : () => number @@ -182,8 +182,8 @@ module Derived { >derived : Derived var o = [derived, derived2]; // {}[] ->o : {}[] ->[derived, derived2] : {}[] +>o : Array +>[derived, derived2] : Array >derived : Derived >derived2 : Derived2 @@ -195,8 +195,8 @@ module Derived { >base : Base var q = [[() => derived2], [() => derived]]; // {}[] ->q : {}[] ->[[() => derived2], [() => derived]] : {}[] +>q : Array<{ (): Derived2; }[] | { (): Derived; }[]> +>[[() => derived2], [() => derived]] : Array<{ (): Derived2; }[] | { (): Derived; }[]> >[() => derived2] : { (): Derived2; }[] >() => derived2 : () => Derived2 >derived2 : Derived2 @@ -212,24 +212,24 @@ module WithContextualType { var a: Base[] = [derived, derived2]; >a : Base[] >Base : Base ->[derived, derived2] : Base[] +>[derived, derived2] : Array >derived : Derived >derived2 : Derived2 var b: Derived[] = [null]; >b : Derived[] >Derived : Derived ->[null] : Derived[] +>[null] : null[] var c: Derived[] = []; >c : Derived[] >Derived : Derived ->[] : Derived[] +>[] : undefined[] var d: { (): Base }[] = [() => derived, () => derived2]; >d : { (): Base; }[] >Base : Base ->[() => derived, () => derived2] : { (): Base; }[] +>[() => derived, () => derived2] : Array<{ (): Derived; } | { (): Derived2; }> >() => derived : () => Derived >derived : Derived >() => derived2 : () => Derived2 @@ -257,19 +257,19 @@ function foo(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >t : T var e = [() => t, () => u]; // {}[] ->e : {}[] ->[() => t, () => u] : {}[] +>e : Array<{ (): T; } | { (): U; }> +>[() => t, () => u] : Array<{ (): T; } | { (): U; }> >() => t : () => T >t : T >() => u : () => U @@ -308,19 +308,19 @@ function foo2(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >t : T var e = [() => t, () => u]; // {}[] ->e : {}[] ->[() => t, () => u] : {}[] +>e : Array<{ (): T; } | { (): U; }> +>[() => t, () => u] : Array<{ (): T; } | { (): U; }> >() => t : () => T >t : T >() => u : () => U @@ -342,8 +342,8 @@ function foo2(t: T, u: U) { >base : Base var h = [t, derived]; // Derived[] ->h : {}[] ->[t, derived] : {}[] +>h : Array +>[t, derived] : Array >t : T >derived : Derived @@ -383,19 +383,19 @@ function foo3(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >t : T var e = [() => t, () => u]; // {}[] ->e : {}[] ->[() => t, () => u] : {}[] +>e : Array<{ (): T; } | { (): U; }> +>[() => t, () => u] : Array<{ (): T; } | { (): U; }> >() => t : () => T >t : T >() => u : () => U @@ -458,19 +458,19 @@ function foo4(t: T, u: U) { >t : T var c = [t, u]; // BUG 821629 ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >t : T var e = [() => t, () => u]; // {}[] ->e : {}[] ->[() => t, () => u] : {}[] +>e : Array<{ (): T; } | { (): U; }> +>[() => t, () => u] : Array<{ (): T; } | { (): U; }> >() => t : () => T >t : T >() => u : () => U @@ -492,8 +492,8 @@ function foo4(t: T, u: U) { >base : Base var h = [t, derived]; // Derived[] ->h : {}[] ->[t, derived] : {}[] +>h : Array +>[t, derived] : Array >t : T >derived : Derived @@ -504,15 +504,15 @@ function foo4(t: T, u: U) { >base : Base var j = [u, derived]; // Derived[] ->j : {}[] ->[u, derived] : {}[] +>j : Array +>[u, derived] : Array >u : U >derived : Derived var k: Base[] = [t, u]; >k : Base[] >Base : Base ->[t, u] : Base[] +>[t, u] : Array >t : T >u : U } diff --git a/tests/baselines/reference/incrementOperatorWithAnyOtherType.types b/tests/baselines/reference/incrementOperatorWithAnyOtherType.types index 165c166941c..930c87274d0 100644 --- a/tests/baselines/reference/incrementOperatorWithAnyOtherType.types +++ b/tests/baselines/reference/incrementOperatorWithAnyOtherType.types @@ -9,7 +9,7 @@ var ANY1; var ANY2: any[] = ["", ""]; >ANY2 : any[] ->["", ""] : any[] +>["", ""] : string[] var obj = {x:1,y:null}; >obj : { x: number; y: any; } diff --git a/tests/baselines/reference/indexSignaturesInferentialTyping.types b/tests/baselines/reference/indexSignaturesInferentialTyping.types index 3c16db3a2bf..4054ccca227 100644 --- a/tests/baselines/reference/indexSignaturesInferentialTyping.types +++ b/tests/baselines/reference/indexSignaturesInferentialTyping.types @@ -24,10 +24,10 @@ var x1 = foo({ 0: 0, 1: 1 }); // type should be number >{ 0: 0, 1: 1 } : { [x: number]: number; 0: number; 1: number; } var x2 = foo({ zero: 0, one: 1 }); ->x2 : {} ->foo({ zero: 0, one: 1 }) : {} +>x2 : any +>foo({ zero: 0, one: 1 }) : any >foo : (items: { [x: number]: T; }) => T ->{ zero: 0, one: 1 } : { [x: number]: {}; zero: number; one: number; } +>{ zero: 0, one: 1 } : { [x: number]: undefined; zero: number; one: number; } >zero : number >one : number diff --git a/tests/baselines/reference/indexer.types b/tests/baselines/reference/indexer.types index 236113cfaa8..9987fdde0b1 100644 --- a/tests/baselines/reference/indexer.types +++ b/tests/baselines/reference/indexer.types @@ -17,7 +17,7 @@ interface JQuery { var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; >jq : JQuery >JQuery : JQuery ->{ 0: { id : "a" }, 1: { id : "b" } } : { [x: number]: JQueryElement; 0: { id: string; }; 1: { id: string; }; } +>{ 0: { id : "a" }, 1: { id : "b" } } : { [x: number]: { id: string; }; 0: { id: string; }; 1: { id: string; }; } >{ id : "a" } : { id: string; } >id : string >{ id : "b" } : { id: string; } diff --git a/tests/baselines/reference/indexer2.errors.txt b/tests/baselines/reference/indexer2.errors.txt new file mode 100644 index 00000000000..9587bb6bb75 --- /dev/null +++ b/tests/baselines/reference/indexer2.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/indexer2.ts(6,25): error TS2353: Neither type '{ [x: number]: undefined; }' nor type 'IDirectChildrenMap' is assignable to the other: + Types of property 'hasOwnProperty' are incompatible: + Type '(v: string) => boolean' is not assignable to type '(objectId: number) => boolean': + Types of parameters 'v' and 'objectId' are incompatible: + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/compiler/indexer2.ts (1 errors) ==== + interface IHeapObjectProperty {} + interface IDirectChildrenMap { + hasOwnProperty(objectId: number) : boolean; + [objectId: number] : IHeapObjectProperty[]; + } + var directChildrenMap = {}; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2353: Neither type '{ [x: number]: undefined; }' nor type 'IDirectChildrenMap' is assignable to the other: +!!! error TS2353: Types of property 'hasOwnProperty' are incompatible: +!!! error TS2353: Type '(v: string) => boolean' is not assignable to type '(objectId: number) => boolean': +!!! error TS2353: Types of parameters 'v' and 'objectId' are incompatible: +!!! error TS2353: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/indexer2.types b/tests/baselines/reference/indexer2.types deleted file mode 100644 index 498ade679a8..00000000000 --- a/tests/baselines/reference/indexer2.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/indexer2.ts === -interface IHeapObjectProperty {} ->IHeapObjectProperty : IHeapObjectProperty - -interface IDirectChildrenMap { ->IDirectChildrenMap : IDirectChildrenMap - - hasOwnProperty(objectId: number) : boolean; ->hasOwnProperty : (objectId: number) => boolean ->objectId : number - - [objectId: number] : IHeapObjectProperty[]; ->objectId : number ->IHeapObjectProperty : IHeapObjectProperty -} -var directChildrenMap = {}; ->directChildrenMap : IDirectChildrenMap ->{} : IDirectChildrenMap ->IDirectChildrenMap : IDirectChildrenMap ->{} : { [x: number]: IHeapObjectProperty[]; } - diff --git a/tests/baselines/reference/indexer2A.errors.txt b/tests/baselines/reference/indexer2A.errors.txt index adf90fb743f..548ed5e565b 100644 --- a/tests/baselines/reference/indexer2A.errors.txt +++ b/tests/baselines/reference/indexer2A.errors.txt @@ -1,7 +1,12 @@ tests/cases/compiler/indexer2A.ts(4,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/compiler/indexer2A.ts(7,25): error TS2353: Neither type '{ [x: number]: undefined; }' nor type 'IDirectChildrenMap' is assignable to the other: + Types of property 'hasOwnProperty' are incompatible: + Type '(v: string) => boolean' is not assignable to type '(objectId: number) => boolean': + Types of parameters 'v' and 'objectId' are incompatible: + Type 'string' is not assignable to type 'number'. -==== tests/cases/compiler/indexer2A.ts (1 errors) ==== +==== tests/cases/compiler/indexer2A.ts (2 errors) ==== class IHeapObjectProperty { } class IDirectChildrenMap { // Decided to enforce a semicolon after declarations @@ -10,4 +15,10 @@ tests/cases/compiler/indexer2A.ts(4,5): error TS2391: Function implementation is !!! error TS2391: Function implementation is missing or not immediately following the declaration. [objectId: number]: IHeapObjectProperty[] } - var directChildrenMap = {}; \ No newline at end of file + var directChildrenMap = {}; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2353: Neither type '{ [x: number]: undefined; }' nor type 'IDirectChildrenMap' is assignable to the other: +!!! error TS2353: Types of property 'hasOwnProperty' are incompatible: +!!! error TS2353: Type '(v: string) => boolean' is not assignable to type '(objectId: number) => boolean': +!!! error TS2353: Types of parameters 'v' and 'objectId' are incompatible: +!!! error TS2353: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/indexer3.types b/tests/baselines/reference/indexer3.types index 2b23ac85885..7f660ab6aa9 100644 --- a/tests/baselines/reference/indexer3.types +++ b/tests/baselines/reference/indexer3.types @@ -3,7 +3,7 @@ var dateMap: { [x: string]: Date; } = {} >dateMap : { [x: string]: Date; } >x : string >Date : Date ->{} : { [x: string]: Date; } +>{} : { [x: string]: undefined; } var r: Date = dateMap["hello"] // result type includes indexer using BCT >r : Date diff --git a/tests/baselines/reference/indexerA.types b/tests/baselines/reference/indexerA.types index 7b409ecedc0..39f7372c839 100644 --- a/tests/baselines/reference/indexerA.types +++ b/tests/baselines/reference/indexerA.types @@ -17,7 +17,7 @@ class JQuery { var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; >jq : JQuery >JQuery : JQuery ->{ 0: { id : "a" }, 1: { id : "b" } } : { [x: number]: JQueryElement; 0: { id: string; }; 1: { id: string; }; } +>{ 0: { id : "a" }, 1: { id : "b" } } : { [x: number]: { id: string; }; 0: { id: string; }; 1: { id: string; }; } >{ id : "a" } : { id: string; } >id : string >{ id : "b" } : { id: string; } diff --git a/tests/baselines/reference/indexerWithTuple.types b/tests/baselines/reference/indexerWithTuple.types index 0a2de09b2c8..28053a33081 100644 --- a/tests/baselines/reference/indexerWithTuple.types +++ b/tests/baselines/reference/indexerWithTuple.types @@ -26,19 +26,19 @@ var ele11 = strNumTuple[1]; // number >strNumTuple : [string, number] var ele12 = strNumTuple[2]; // {} ->ele12 : {} ->strNumTuple[2] : {} +>ele12 : string | number +>strNumTuple[2] : string | number >strNumTuple : [string, number] var ele13 = strNumTuple[idx0]; // {} ->ele13 : {} ->strNumTuple[idx0] : {} +>ele13 : string | number +>strNumTuple[idx0] : string | number >strNumTuple : [string, number] >idx0 : number var ele14 = strNumTuple[idx1]; // {} ->ele14 : {} ->strNumTuple[idx1] : {} +>ele14 : string | number +>strNumTuple[idx1] : string | number >strNumTuple : [string, number] >idx1 : number @@ -58,7 +58,7 @@ var strNumTuple1 = numTupleTuple[1]; //[string, number]; >numTupleTuple : [number, [string, number]] var ele17 = numTupleTuple[2]; // {} ->ele17 : {} ->numTupleTuple[2] : {} +>ele17 : number | [string, number] +>numTupleTuple[2] : number | [string, number] >numTupleTuple : [number, [string, number]] diff --git a/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types b/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types index 11e017d6661..53a9dff0b48 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types @@ -34,7 +34,7 @@ var result = zipWith([1, 2], ['a', 'b'], pair); >zipWith([1, 2], ['a', 'b'], pair) : { x: number; y: {}; }[] >zipWith : (a: T[], b: S[], f: (x: T) => (y: S) => U) => U[] >[1, 2] : number[] ->['a', 'b'] : {}[] +>['a', 'b'] : string[] >pair : (x: T) => (y: S) => { x: T; y: S; } var i = result[0].x; // number diff --git a/tests/baselines/reference/inferentiallyTypingAnEmptyArray.types b/tests/baselines/reference/inferentiallyTypingAnEmptyArray.types index c8f51c985e6..451280ee16f 100644 --- a/tests/baselines/reference/inferentiallyTypingAnEmptyArray.types +++ b/tests/baselines/reference/inferentiallyTypingAnEmptyArray.types @@ -25,6 +25,6 @@ foo([]).bar; >foo([]).bar : any >foo([]) : any >foo : (arr: T[]) => T ->[] : any[] +>[] : undefined[] >bar : any diff --git a/tests/baselines/reference/interfaceContextualType.types b/tests/baselines/reference/interfaceContextualType.types index 88ba9dcbc24..3078ecfdfa4 100644 --- a/tests/baselines/reference/interfaceContextualType.types +++ b/tests/baselines/reference/interfaceContextualType.types @@ -27,11 +27,11 @@ class Bug { >ok : () => void this.values = {}; ->this.values = {} : { [x: string]: IOptions; } +>this.values = {} : { [x: string]: undefined; } >this.values : IMap >this : Bug >values : IMap ->{} : { [x: string]: IOptions; } +>{} : { [x: string]: undefined; } this.values['comments'] = { italic: true }; >this.values['comments'] = { italic: true } : { italic: boolean; } @@ -46,11 +46,11 @@ class Bug { >shouldBeOK : () => void this.values = { ->this.values = { comments: { italic: true } } : { [x: string]: IOptions; comments: { italic: boolean; }; } +>this.values = { comments: { italic: true } } : { [x: string]: { italic: boolean; }; comments: { italic: boolean; }; } >this.values : IMap >this : Bug >values : IMap ->{ comments: { italic: true } } : { [x: string]: IOptions; comments: { italic: boolean; }; } +>{ comments: { italic: true } } : { [x: string]: { italic: boolean; }; comments: { italic: boolean; }; } comments: { italic: true } >comments : { italic: boolean; } diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 0a4761994dd..b82c82b9eb5 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 '{}[]'. +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(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 '{}[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array>'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types index d44b220e818..95c9643c29a 100644 --- a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types +++ b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types @@ -7,7 +7,7 @@ var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; >r : { a: string; } >a : string ->{ a: '', b: 123 } || { a: '', b: true } : { a: string; } +>{ a: '', b: 123 } || { a: '', b: true } : { a: string; b: number; } | { a: string; b: boolean; } >{ a: '', b: 123 } : { a: string; b: number; } >a : string >b : number diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 3cf0399f437..3e3b0dcf37f 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -108,38 +108,38 @@ var rb2 = a2 || a2; // boolean || boolean is boolean >a2 : boolean var rb3 = a3 || a2; // number || boolean is {} ->rb3 : {} ->a3 || a2 : {} +>rb3 : number | boolean +>a3 || a2 : number | boolean >a3 : number >a2 : boolean var rb4 = a4 || a2; // string || boolean is {} ->rb4 : {} ->a4 || a2 : {} +>rb4 : string | boolean +>a4 || a2 : string | boolean >a4 : string >a2 : boolean var rb5 = a5 || a2; // void || boolean is {} ->rb5 : {} ->a5 || a2 : {} +>rb5 : boolean | void +>a5 || a2 : boolean | void >a5 : void >a2 : boolean var rb6 = a6 || a2; // enum || boolean is {} ->rb6 : {} ->a6 || a2 : {} +>rb6 : boolean | E +>a6 || a2 : boolean | E >a6 : E >a2 : boolean var rb7 = a7 || a2; // object || boolean is {} ->rb7 : {} ->a7 || a2 : {} +>rb7 : boolean | { a: string; } +>a7 || a2 : boolean | { a: string; } >a7 : { a: string; } >a2 : boolean var rb8 = a8 || a2; // array || boolean is {} ->rb8 : {} ->a8 || a2 : {} +>rb8 : boolean | string[] +>a8 || a2 : boolean | string[] >a8 : string[] >a2 : boolean @@ -161,8 +161,8 @@ var rc1 = a1 || a3; // any || number is any >a3 : number var rc2 = a2 || a3; // boolean || number is {} ->rc2 : {} ->a2 || a3 : {} +>rc2 : number | boolean +>a2 || a3 : number | boolean >a2 : boolean >a3 : number @@ -173,14 +173,14 @@ var rc3 = a3 || a3; // number || number is number >a3 : number var rc4 = a4 || a3; // string || number is {} ->rc4 : {} ->a4 || a3 : {} +>rc4 : string | number +>a4 || a3 : string | number >a4 : string >a3 : number var rc5 = a5 || a3; // void || number is {} ->rc5 : {} ->a5 || a3 : {} +>rc5 : number | void +>a5 || a3 : number | void >a5 : void >a3 : number @@ -191,14 +191,14 @@ var rc6 = a6 || a3; // enum || number is number >a3 : number var rc7 = a7 || a3; // object || number is {} ->rc7 : {} ->a7 || a3 : {} +>rc7 : number | { a: string; } +>a7 || a3 : number | { a: string; } >a7 : { a: string; } >a3 : number var rc8 = a8 || a3; // array || number is {} ->rc8 : {} ->a8 || a3 : {} +>rc8 : number | string[] +>a8 || a3 : number | string[] >a8 : string[] >a3 : number @@ -220,14 +220,14 @@ var rd1 = a1 || a4; // any || string is any >a4 : string var rd2 = a2 || a4; // boolean || string is {} ->rd2 : {} ->a2 || a4 : {} +>rd2 : string | boolean +>a2 || a4 : string | boolean >a2 : boolean >a4 : string var rd3 = a3 || a4; // number || string is {} ->rd3 : {} ->a3 || a4 : {} +>rd3 : string | number +>a3 || a4 : string | number >a3 : number >a4 : string @@ -238,26 +238,26 @@ var rd4 = a4 || a4; // string || string is string >a4 : string var rd5 = a5 || a4; // void || string is {} ->rd5 : {} ->a5 || a4 : {} +>rd5 : string | void +>a5 || a4 : string | void >a5 : void >a4 : string var rd6 = a6 || a4; // enum || string is {} ->rd6 : {} ->a6 || a4 : {} +>rd6 : string | E +>a6 || a4 : string | E >a6 : E >a4 : string var rd7 = a7 || a4; // object || string is {} ->rd7 : {} ->a7 || a4 : {} +>rd7 : string | { a: string; } +>a7 || a4 : string | { a: string; } >a7 : { a: string; } >a4 : string var rd8 = a8 || a4; // array || string is {} ->rd8 : {} ->a8 || a4 : {} +>rd8 : string | string[] +>a8 || a4 : string | string[] >a8 : string[] >a4 : string @@ -279,20 +279,20 @@ var re1 = a1 || a5; // any || void is any >a5 : void var re2 = a2 || a5; // boolean || void is {} ->re2 : {} ->a2 || a5 : {} +>re2 : boolean | void +>a2 || a5 : boolean | void >a2 : boolean >a5 : void var re3 = a3 || a5; // number || void is {} ->re3 : {} ->a3 || a5 : {} +>re3 : number | void +>a3 || a5 : number | void >a3 : number >a5 : void var re4 = a4 || a5; // string || void is {} ->re4 : {} ->a4 || a5 : {} +>re4 : string | void +>a4 || a5 : string | void >a4 : string >a5 : void @@ -303,20 +303,20 @@ var re5 = a5 || a5; // void || void is void >a5 : void var re6 = a6 || a5; // enum || void is {} ->re6 : {} ->a6 || a5 : {} +>re6 : void | E +>a6 || a5 : void | E >a6 : E >a5 : void var re7 = a7 || a5; // object || void is {} ->re7 : {} ->a7 || a5 : {} +>re7 : void | { a: string; } +>a7 || a5 : void | { a: string; } >a7 : { a: string; } >a5 : void var re8 = a8 || a5; // array || void is {} ->re8 : {} ->a8 || a5 : {} +>re8 : void | string[] +>a8 || a5 : void | string[] >a8 : string[] >a5 : void @@ -338,8 +338,8 @@ var rg1 = a1 || a6; // any || enum is any >a6 : E var rg2 = a2 || a6; // boolean || enum is {} ->rg2 : {} ->a2 || a6 : {} +>rg2 : boolean | E +>a2 || a6 : boolean | E >a2 : boolean >a6 : E @@ -350,14 +350,14 @@ var rg3 = a3 || a6; // number || enum is number >a6 : E var rg4 = a4 || a6; // string || enum is {} ->rg4 : {} ->a4 || a6 : {} +>rg4 : string | E +>a4 || a6 : string | E >a4 : string >a6 : E var rg5 = a5 || a6; // void || enum is {} ->rg5 : {} ->a5 || a6 : {} +>rg5 : void | E +>a5 || a6 : void | E >a5 : void >a6 : E @@ -368,14 +368,14 @@ var rg6 = a6 || a6; // enum || enum is E >a6 : E var rg7 = a7 || a6; // object || enum is {} ->rg7 : {} ->a7 || a6 : {} +>rg7 : E | { a: string; } +>a7 || a6 : E | { a: string; } >a7 : { a: string; } >a6 : E var rg8 = a8 || a6; // array || enum is {} ->rg8 : {} ->a8 || a6 : {} +>rg8 : string[] | E +>a8 || a6 : string[] | E >a8 : string[] >a6 : E @@ -397,32 +397,32 @@ var rh1 = a1 || a7; // any || object is any >a7 : { a: string; } var rh2 = a2 || a7; // boolean || object is {} ->rh2 : {} ->a2 || a7 : {} +>rh2 : boolean | { a: string; } +>a2 || a7 : boolean | { a: string; } >a2 : boolean >a7 : { a: string; } var rh3 = a3 || a7; // number || object is {} ->rh3 : {} ->a3 || a7 : {} +>rh3 : number | { a: string; } +>a3 || a7 : number | { a: string; } >a3 : number >a7 : { a: string; } var rh4 = a4 || a7; // string || object is {} ->rh4 : {} ->a4 || a7 : {} +>rh4 : string | { a: string; } +>a4 || a7 : string | { a: string; } >a4 : string >a7 : { a: string; } var rh5 = a5 || a7; // void || object is {} ->rh5 : {} ->a5 || a7 : {} +>rh5 : void | { a: string; } +>a5 || a7 : void | { a: string; } >a5 : void >a7 : { a: string; } var rh6 = a6 || a7; // enum || object is {} ->rh6 : {} ->a6 || a7 : {} +>rh6 : E | { a: string; } +>a6 || a7 : E | { a: string; } >a6 : E >a7 : { a: string; } @@ -433,8 +433,8 @@ var rh7 = a7 || a7; // object || object is object >a7 : { a: string; } var rh8 = a8 || a7; // array || object is {} ->rh8 : {} ->a8 || a7 : {} +>rh8 : string[] | { a: string; } +>a8 || a7 : string[] | { a: string; } >a8 : string[] >a7 : { a: string; } @@ -456,38 +456,38 @@ var ri1 = a1 || a8; // any || array is any >a8 : string[] var ri2 = a2 || a8; // boolean || array is {} ->ri2 : {} ->a2 || a8 : {} +>ri2 : boolean | string[] +>a2 || a8 : boolean | string[] >a2 : boolean >a8 : string[] var ri3 = a3 || a8; // number || array is {} ->ri3 : {} ->a3 || a8 : {} +>ri3 : number | string[] +>a3 || a8 : number | string[] >a3 : number >a8 : string[] var ri4 = a4 || a8; // string || array is {} ->ri4 : {} ->a4 || a8 : {} +>ri4 : string | string[] +>a4 || a8 : string | string[] >a4 : string >a8 : string[] var ri5 = a5 || a8; // void || array is {} ->ri5 : {} ->a5 || a8 : {} +>ri5 : void | string[] +>a5 || a8 : void | string[] >a5 : void >a8 : string[] var ri6 = a6 || a8; // enum || array is {} ->ri6 : {} ->a6 || a8 : {} +>ri6 : string[] | E +>a6 || a8 : string[] | E >a6 : E >a8 : string[] var ri7 = a7 || a8; // object || array is {} ->ri7 : {} ->a7 || a8 : {} +>ri7 : string[] | { a: string; } +>a7 || a8 : string[] | { a: string; } >a7 : { a: string; } >a8 : string[] diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index ff0e0ce568a..4008fbbff50 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -22,14 +22,14 @@ function fn1(t: T, u: U) { >t : T var r3 = t || u; ->r3 : {} ->t || u : {} +>r3 : T | U +>t || u : T | U >t : T >u : U var r4: {} = t || u; >r4 : {} ->t || u : {} +>t || u : T | U >t : T >u : U } @@ -47,8 +47,8 @@ function fn2(t: T, u: U, v: V) { >V : V var r1 = t || u; ->r1 : {} ->t || u : {} +>r1 : T | U +>t || u : T | U >t : T >u : U @@ -67,14 +67,14 @@ function fn2(t: T, u: U, v: V) { >u : U var r5 = u || v; ->r5 : {} ->u || v : {} +>r5 : U | V +>u || v : U | V >u : U >v : V var r6: {} = u || v; >r6 : {} ->u || v : {} +>u || v : U | V >u : U >v : V @@ -95,14 +95,14 @@ function fn3U : U var r1 = t || u; ->r1 : {} ->t || u : {} +>r1 : T | U +>t || u : T | U >t : T >u : U var r2: {} = t || u; >r2 : {} ->t || u : {} +>t || u : T | U >t : T >u : U @@ -116,7 +116,7 @@ function fn3r4 : { a: string; } >a : string ->t || u : { a: string; } +>t || u : T | U >t : T >u : U } diff --git a/tests/baselines/reference/memberVariableDeclarations1.types b/tests/baselines/reference/memberVariableDeclarations1.types index 10ec78d69dc..4dd68cdeb35 100644 --- a/tests/baselines/reference/memberVariableDeclarations1.types +++ b/tests/baselines/reference/memberVariableDeclarations1.types @@ -20,7 +20,7 @@ class Employee { public reports: Employee[] = []; >reports : Employee[] >Employee : Employee ->[] : Employee[] +>[] : undefined[] } class Employee2 { @@ -57,11 +57,11 @@ class Employee2 { >manager : Employee this.reports = []; ->this.reports = [] : Employee[] +>this.reports = [] : undefined[] >this.reports : Employee[] >this : Employee2 >reports : Employee[] ->[] : Employee[] +>[] : undefined[] } } diff --git a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt index 557f60967a6..ed4f45ec1de 100644 --- a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt +++ b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt @@ -1,5 +1,6 @@ -tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'. - Type '{}' is not assignable to type 'number'. +tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type 'Array' 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. @@ -15,8 +16,9 @@ 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 '{}[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type '{}' is not assignable to type 'number'. +!!! error TS2345: Argument of type 'Array' 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/negateOperatorWithAnyOtherType.types b/tests/baselines/reference/negateOperatorWithAnyOtherType.types index 8785ab073b2..85a2d9c9233 100644 --- a/tests/baselines/reference/negateOperatorWithAnyOtherType.types +++ b/tests/baselines/reference/negateOperatorWithAnyOtherType.types @@ -9,7 +9,7 @@ var ANY1; var ANY2: any[] = ["", ""]; >ANY2 : any[] ->["", ""] : any[] +>["", ""] : string[] var obj: () => {} >obj : () => {} diff --git a/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.errors.txt b/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.errors.txt deleted file mode 100644 index d53f12fd504..00000000000 --- a/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/noImplicitAnyFunctionExpressionAssignment.ts(2,27): error TS7011: Function expression, which lacks return-type annotation, implicitly has an 'any' return type. -tests/cases/compiler/noImplicitAnyFunctionExpressionAssignment.ts(6,28): error TS7010: 'f', which lacks return-type annotation, implicitly has an 'any' return type. - - -==== tests/cases/compiler/noImplicitAnyFunctionExpressionAssignment.ts (2 errors) ==== - - var x: (a: any) => void = function (x: T) { - ~~~~~~~~~~~~~~~~~~~~ - return null; - ~~~~~~~~~~~~~~~~ - }; - ~ -!!! error TS7011: Function expression, which lacks return-type annotation, implicitly has an 'any' return type. - - var x2: (a: any) => void = function f(x: T) { - ~~~~~~~~~~~~~~~~~~~~~ - return null; - ~~~~~~~~~~~~~~~~ - }; - ~ -!!! error TS7010: 'f', which lacks return-type annotation, implicitly has an 'any' return type. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types b/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types new file mode 100644 index 00000000000..b07252dac6d --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/noImplicitAnyFunctionExpressionAssignment.ts === + +var x: (a: any) => void = function (x: T) { +>x : (a: any) => void +>a : any +>function (x: T) { return null;} : (x: T) => any +>T : T +>x : T +>T : T + + return null; +}; + +var x2: (a: any) => void = function f(x: T) { +>x2 : (a: any) => void +>a : any +>function f(x: T) { return null;} : (x: T) => any +>f : (x: T) => any +>T : T +>x : T +>T : T + + return null; +}; diff --git a/tests/baselines/reference/nonContextuallyTypedLogicalOr.errors.txt b/tests/baselines/reference/nonContextuallyTypedLogicalOr.errors.txt deleted file mode 100644 index ca4dc9f67e3..00000000000 --- a/tests/baselines/reference/nonContextuallyTypedLogicalOr.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -tests/cases/compiler/nonContextuallyTypedLogicalOr.ts(16,10): error TS2339: Property 'dummy' does not exist on type '{}'. - - -==== tests/cases/compiler/nonContextuallyTypedLogicalOr.ts (1 errors) ==== - interface Contextual { - dummy; - p?: number; - } - - interface Ellement { - dummy; - p: any; - } - - var c: Contextual; - var e: Ellement; - - // This should error. Even though we are contextually typing e with Contextual, the RHS still - // needs to be a supertype of the LHS to win as the best common type. - (c || e).dummy; - ~~~~~ -!!! error TS2339: Property 'dummy' does not exist on type '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/nonContextuallyTypedLogicalOr.js b/tests/baselines/reference/nonContextuallyTypedLogicalOr.js index a29390bcf7f..e3ec95533fd 100644 --- a/tests/baselines/reference/nonContextuallyTypedLogicalOr.js +++ b/tests/baselines/reference/nonContextuallyTypedLogicalOr.js @@ -12,13 +12,9 @@ interface Ellement { var c: Contextual; var e: Ellement; -// This should error. Even though we are contextually typing e with Contextual, the RHS still -// needs to be a supertype of the LHS to win as the best common type. (c || e).dummy; //// [nonContextuallyTypedLogicalOr.js] var c; var e; -// This should error. Even though we are contextually typing e with Contextual, the RHS still -// needs to be a supertype of the LHS to win as the best common type. (c || e).dummy; diff --git a/tests/baselines/reference/nonContextuallyTypedLogicalOr.types b/tests/baselines/reference/nonContextuallyTypedLogicalOr.types new file mode 100644 index 00000000000..aeb9d1409c6 --- /dev/null +++ b/tests/baselines/reference/nonContextuallyTypedLogicalOr.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/nonContextuallyTypedLogicalOr.ts === +interface Contextual { +>Contextual : Contextual + + dummy; +>dummy : any + + p?: number; +>p : number +} + +interface Ellement { +>Ellement : Ellement + + dummy; +>dummy : any + + p: any; +>p : any +} + +var c: Contextual; +>c : Contextual +>Contextual : Contextual + +var e: Ellement; +>e : Ellement +>Ellement : Ellement + +(c || e).dummy; +>(c || e).dummy : any +>(c || e) : Contextual | Ellement +>c || e : Contextual | Ellement +>c : Contextual +>e : Ellement +>dummy : any + diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index 1560a284702..b59b734b3d0 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -10,9 +10,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 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]: {}; 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; }': +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 '{}' is not assignable to type 'string'. + Type 'string | number' is not assignable to type 'string': + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. @@ -116,9 +117,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: string; } = { ~ -!!! error TS2322: Type '{ [x: 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; }': +!!! 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; }': !!! error TS2322: Index signatures are incompatible: -!!! error TS2322: Type '{}' 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'. a: '', b: 1, c: () => { }, diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 0e9cff15560..4d0488ec80f 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,10 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 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]: {}; 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]: 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; }': Index signatures are incompatible: - Type '{}' is not assignable to type 'A': - Property 'foo' is missing in type '{}'. + Type 'string | number | A' is not assignable to type 'A': + Type 'string' is not assignable to type 'A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== @@ -63,10 +63,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: {}; 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]: 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: Index signatures are incompatible: -!!! error TS2322: Type '{}' is not assignable to type 'A': -!!! error TS2322: Property 'foo' is missing in type '{}'. +!!! error TS2322: Type 'string | number | A' is not assignable to type 'A': +!!! error TS2322: Type 'string' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), "2.5": new B(), diff --git a/tests/baselines/reference/numericIndexerConstraint4.types b/tests/baselines/reference/numericIndexerConstraint4.types index f0004e52b45..78b57d4179e 100644 --- a/tests/baselines/reference/numericIndexerConstraint4.types +++ b/tests/baselines/reference/numericIndexerConstraint4.types @@ -22,7 +22,7 @@ var x: { >A : A } = { data: new B() } ->{ data: new B() } : { [x: number]: A; data: B; } +>{ data: new B() } : { [x: number]: undefined; data: B; } >data : B >new B() : B >B : typeof B diff --git a/tests/baselines/reference/objectIndexer.types b/tests/baselines/reference/objectIndexer.types index a2a7f99cf5d..7b42ea51b56 100644 --- a/tests/baselines/reference/objectIndexer.types +++ b/tests/baselines/reference/objectIndexer.types @@ -23,11 +23,11 @@ class Emitter { constructor () { this.listeners = {}; ->this.listeners = {} : { [x: string]: Callback; } +>this.listeners = {} : { [x: string]: undefined; } >this.listeners : IMap >this : Emitter >listeners : IMap ->{} : { [x: string]: Callback; } +>{} : { [x: string]: undefined; } } } diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types index ab83b0c78f0..a0603ae0777 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types @@ -50,7 +50,7 @@ var a: { var b: { [x: number]: string; } = { foo: '' }; >b : { [x: number]: string; } >x : number ->{ foo: '' } : { [x: number]: string; foo: string; } +>{ foo: '' } : { [x: number]: undefined; foo: string; } >foo : string function foo1(x: A); diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types index cd8f19b2b7e..9e4ccb5c43b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types @@ -64,7 +64,7 @@ var b: { [x: number]: Derived; } = { foo: null }; >b : { [x: number]: Derived; } >x : number >Derived : Derived ->{ foo: null } : { [x: number]: Derived; foo: Derived; } +>{ foo: null } : { [x: number]: undefined; foo: Derived; } >foo : Derived >null : Derived >Derived : Derived diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types index 6a73749fc84..3553f5f7252 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types @@ -50,7 +50,7 @@ var a: { var b: { [x: number]: string; } = { foo: '' }; >b : { [x: number]: string; } >x : number ->{ foo: '' } : { [x: number]: string; foo: string; } +>{ foo: '' } : { [x: number]: undefined; foo: string; } >foo : string function foo1(x: A); diff --git a/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types b/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types index 846190010b4..7ad68cefa4f 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types @@ -37,7 +37,7 @@ module Bugs { var tokens:IToken[]= []; >tokens : IToken[] >IToken : IToken ->[] : IToken[] +>[] : undefined[] tokens.push({ startIndex: 1, type: '', bracket: 3 }); >tokens.push({ startIndex: 1, type: '', bracket: 3 }) : number diff --git a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt index ab9bab7890c..237541b40f7 100644 --- a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt +++ b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt @@ -1,7 +1,8 @@ +tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error TS2304: Cannot find name 'runTestCase'. -==== tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts (2 errors) ==== /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -18,6 +19,8 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error T var one = 1; var _float = -(4/3); var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3)); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3) a.indexOf(0) === 7 && // a[7] = +0, 0===+0 a.indexOf(-0) === 7 && // a[7] = +0, -0===+0 diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index ee723821cce..0b2aa01bb5c 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/promisePermutations.ts(74,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. tests/cases/compiler/promisePermutations.ts(79,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations.ts(83,19): error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => Promise'. @@ -19,13 +20,20 @@ tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of t tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(129,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(137,11): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations.ts(144,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations.ts(152,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -==== tests/cases/compiler/promisePermutations.ts (25 errors) ==== +==== tests/cases/compiler/promisePermutations.ts (33 errors) ==== interface Promise { then(success?: (value: T) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; then(success?: (value: T) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; @@ -39,7 +47,7 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -99,7 +107,9 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); var s3c = s3.then(testFunction3P, testFunction3, testFunction3); - var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); + var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error + ~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -118,7 +128,7 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => IPromise'. - var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); + var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -197,6 +207,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -210,7 +222,9 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok - var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok + var s9f = s9.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); @@ -218,6 +232,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -225,17 +241,25 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok - var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok + var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; - var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok + var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. - var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok - var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok + var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. + var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/baselines/reference/promisePermutations.js b/tests/baselines/reference/promisePermutations.js index 189ef40335e..e59e49d6f8c 100644 --- a/tests/baselines/reference/promisePermutations.js +++ b/tests/baselines/reference/promisePermutations.js @@ -12,7 +12,7 @@ interface IPromise { then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -72,7 +72,7 @@ var s3: Promise; var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); var s3c = s3.then(testFunction3P, testFunction3, testFunction3); -var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); +var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -83,7 +83,7 @@ var s4: Promise; var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error -var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); +var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -135,7 +135,7 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); @@ -150,15 +150,15 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; -var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok +var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok -var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok -var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok +var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error +var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok @@ -192,7 +192,7 @@ var s3; var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); var s3c = s3.then(testFunction3P, testFunction3, testFunction3); -var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); +var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error var r4; var sIPromise; var sPromise; @@ -249,7 +249,7 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(function (x) { return x; }); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok @@ -263,14 +263,14 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11; -var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok +var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error var s11; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok -var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok -var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok +var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error +var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error var r12 = testFunction12(function (x) { return x; }); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok var s12 = testFunction12(function (x) { return x; }); diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index f85a3eb925f..e512ca73277 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -20,15 +20,20 @@ tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations2.ts(128,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations2.ts(136,11): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations2.ts(143,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations2.ts(151,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -==== tests/cases/compiler/promisePermutations2.ts (28 errors) ==== +==== tests/cases/compiler/promisePermutations2.ts (33 errors) ==== // same as promisePermutations but without the same overloads in Promise interface Promise { @@ -41,7 +46,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -122,7 +127,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => IPromise'. - var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); + var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -200,7 +205,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok - var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok + var r9d = r9.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -214,14 +221,18 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok - var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok + var s9f = s9.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok - var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok + var r10d = r10.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -229,11 +240,15 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok - var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok + var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; - var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok + var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/promisePermutations2.js b/tests/baselines/reference/promisePermutations2.js index 008594ee120..a7b5d8cf835 100644 --- a/tests/baselines/reference/promisePermutations2.js +++ b/tests/baselines/reference/promisePermutations2.js @@ -11,7 +11,7 @@ interface IPromise { then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -82,7 +82,7 @@ var s4: Promise; var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error -var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); +var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -126,7 +126,7 @@ var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok -var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok +var r9d = r9.then(testFunction, sIPromise, nIPromise); // error var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -134,14 +134,14 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok -var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok +var r10d = r10.then(testFunction, sIPromise, nIPromise); // error var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -149,11 +149,11 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; -var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok +var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok @@ -241,7 +241,7 @@ var r9; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok -var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok +var r9d = r9.then(testFunction, sIPromise, nIPromise); // error var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -249,13 +249,13 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(function (x) { return x; }); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok -var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok +var r10d = r10.then(testFunction, sIPromise, nIPromise); // error var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(function (x) { return x; }); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -263,10 +263,10 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11; -var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok +var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error var s11; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index edd5f879043..97d47cc7f7f 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/promisePermutations3.ts(68,69): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. tests/cases/compiler/promisePermutations3.ts(78,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations3.ts(81,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations3.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => Promise'. @@ -20,15 +21,21 @@ tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(128,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(136,11): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations3.ts(143,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/promisePermutations3.ts(151,12): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. -==== tests/cases/compiler/promisePermutations3.ts (28 errors) ==== +==== tests/cases/compiler/promisePermutations3.ts (35 errors) ==== // same as promisePermutations but without the same overloads in IPromise interface Promise { @@ -41,7 +48,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of interface IPromise { then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -104,6 +111,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); var s3c = s3.then(testFunction3P, testFunction3, testFunction3); var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); + ~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -122,7 +131,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => IPromise'. - var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); + var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -200,7 +209,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok - var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok + var r9d = r9.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -214,14 +225,18 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok - var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok + var s9f = s9.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok - var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok + var r10d = r10.then(testFunction, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -229,7 +244,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok - var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok + var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; @@ -240,8 +257,12 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. - var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok - var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok + var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. + var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/baselines/reference/promisePermutations3.js b/tests/baselines/reference/promisePermutations3.js index d65d8c233f8..eb9c882b971 100644 --- a/tests/baselines/reference/promisePermutations3.js +++ b/tests/baselines/reference/promisePermutations3.js @@ -11,7 +11,7 @@ interface Promise { interface IPromise { then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -82,7 +82,7 @@ var s4: Promise; var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error -var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); +var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -126,7 +126,7 @@ var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok -var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok +var r9d = r9.then(testFunction, sIPromise, nIPromise); // error var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -134,14 +134,14 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok -var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok +var r10d = r10.then(testFunction, sIPromise, nIPromise); // error var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -149,15 +149,15 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok -var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok -var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok +var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error +var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok @@ -241,7 +241,7 @@ var r9; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok -var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok +var r9d = r9.then(testFunction, sIPromise, nIPromise); // error var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -249,13 +249,13 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(function (x) { return x; }); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok -var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok +var r10d = r10.then(testFunction, sIPromise, nIPromise); // error var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(function (x) { return x; }); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -263,14 +263,14 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11; var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok var s11; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok -var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok -var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok +var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error +var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error var r12 = testFunction12(function (x) { return x; }); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok var s12 = testFunction12(function (x) { return x; }); diff --git a/tests/baselines/reference/returnTypeParameterWithModules.types b/tests/baselines/reference/returnTypeParameterWithModules.types index adcc1b4bcee..4be0efcd2a5 100644 --- a/tests/baselines/reference/returnTypeParameterWithModules.types +++ b/tests/baselines/reference/returnTypeParameterWithModules.types @@ -21,7 +21,7 @@ module M1 { >reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } >apply : (thisArg: any, argArray?: any) => any >ar : any ->e ? [f, e] : [f] : any +>e ? [f, e] : [f] : any[] >e : any >[f, e] : any[] >f : any diff --git a/tests/baselines/reference/sourceMapValidationClasses.types b/tests/baselines/reference/sourceMapValidationClasses.types index d53cdcb9974..4f391c86f65 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.types +++ b/tests/baselines/reference/sourceMapValidationClasses.types @@ -56,7 +56,7 @@ module Foo.Bar { var greeters: Greeter[] = []; /* inline block comment */ >greeters : Greeter[] >Greeter : Greeter ->[] : Greeter[] +>[] : undefined[] greeters[0] = new Greeter(greeting); >greeters[0] = new Greeter(greeting) : Greeter diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index a731dcca188..b71b04263b1 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -24,9 +24,10 @@ 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]: {}; 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 '{}' 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'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts (27 errors) ==== @@ -159,9 +160,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: {}; 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 '{}' 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, c: () => { }, diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index a986258bf11..bdb3c9a056f 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,46 +1,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(7,7): error TS2416: Class 'D1' incorrectly extends base class 'C3': Types of property 'foo' are incompatible: Type 'U' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(12,13): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(13,13): error TS2367: No best common type exists between 'U' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(38,14): error TS2367: No best common type exists between 'number' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(39,14): error TS2367: No best common type exists between 'T' and 'number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(41,14): error TS2367: No best common type exists between 'string' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(42,14): error TS2367: No best common type exists between 'T' and 'string'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(44,14): error TS2367: No best common type exists between 'boolean' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(45,14): error TS2367: No best common type exists between 'T' and 'boolean'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(47,14): error TS2367: No best common type exists between 'Date' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(48,14): error TS2367: No best common type exists between 'T' and 'Date'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(50,14): error TS2367: No best common type exists between 'RegExp' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(51,14): error TS2367: No best common type exists between 'T' and 'RegExp'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(53,14): error TS2367: No best common type exists between '{ foo: number; }' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(54,14): error TS2367: No best common type exists between 'T' and '{ foo: number; }'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(56,14): error TS2367: No best common type exists between '() => void' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(57,14): error TS2367: No best common type exists between 'T' and '() => void'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(59,14): error TS2367: No best common type exists between '(x: T) => T' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(60,15): error TS2367: No best common type exists between 'T' and '(x: T) => T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(63,14): error TS2367: No best common type exists between 'I1' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(64,14): error TS2367: No best common type exists between 'T' and 'I1'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(67,15): error TS2367: No best common type exists between 'C1' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(68,15): error TS2367: No best common type exists between 'T' and 'C1'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(72,15): error TS2367: No best common type exists between 'C2' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(73,15): error TS2367: No best common type exists between 'T' and 'C2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(76,15): error TS2367: No best common type exists between 'typeof E' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(77,15): error TS2367: No best common type exists between 'T' and 'typeof E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(79,15): error TS2367: No best common type exists between 'E' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(80,15): error TS2367: No best common type exists between 'T' and 'E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(83,15): error TS2367: No best common type exists between 'typeof f' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(84,15): error TS2367: No best common type exists between 'T' and 'typeof f'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(87,15): error TS2367: No best common type exists between 'typeof c' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(88,15): error TS2367: No best common type exists between 'T' and 'typeof c'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(91,19): error TS2367: No best common type exists between 'T' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(92,19): error TS2367: No best common type exists between 'T' and 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(95,21): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(96,19): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(97,19): error TS2367: No best common type exists between 'U' and 'T'. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (38 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ==== // checking whether other types are subtypes of type parameters class C3 { @@ -57,11 +21,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf function f1(x: T, y: U) { var r = true ? x : y; // error - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r = true ? y : x; // error - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. } interface I1 { foo: number; } @@ -87,135 +47,67 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf var r0b = true ? x : u; var r1 = true ? 1 : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'number' and 'T'. var r1 = true ? x : 1; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'number'. var r2 = true ? '' : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'string' and 'T'. var r2 = true ? x : ''; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'string'. var r3 = true ? true : x; - ~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'boolean' and 'T'. var r3 = true ? x : true; - ~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'boolean'. var r4 = true ? new Date() : x; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Date' and 'T'. var r4 = true ? x : new Date(); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Date'. var r5 = true ? /1/ : x; - ~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'RegExp' and 'T'. var r5 = true ? x : /1/; - ~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'RegExp'. var r6 = true ? { foo: 1 } : x; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between '{ foo: number; }' and 'T'. var r6 = true ? x : { foo: 1 }; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and '{ foo: number; }'. var r7 = true ? () => { } : x; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between '() => void' and 'T'. var r7 = true ? x : () => { }; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and '() => void'. var r8 = true ? (x: T) => { return x } : x; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between '(x: T) => T' and 'T'. var r8b = true ? x : (x: T) => { return x }; // type parameters not identical across declarations - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and '(x: T) => T'. var i1: I1; var r9 = true ? i1 : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'I1' and 'T'. var r9 = true ? x : i1; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'I1'. var c1: C1; var r10 = true ? c1 : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'C1' and 'T'. var r10 = true ? x : c1; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'C1'. var c2: C2; var r12 = true ? c2 : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'C2' and 'T'. var r12 = true ? x : c2; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'C2'. var r13 = true ? E : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'typeof E' and 'T'. var r13 = true ? x : E; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'typeof E'. var r14 = true ? E.A : x; - ~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'E' and 'T'. var r14 = true ? x : E.A; - ~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'E'. var af: typeof f; var r15 = true ? af : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'typeof f' and 'T'. var r15 = true ? x : af; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'typeof f'. var ac: typeof c; var r16 = true ? ac : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'typeof c' and 'T'. var r16 = true ? x : ac; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'typeof c'. function f17(a: T) { var r17 = true ? x : a; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'T'. var r17 = true ? a : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'T'. } function f18(a: U) { ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. var r18 = true ? x : a; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r18 = true ? a : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. } var r19 = true ? new Object() : x; // BCT is Object diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt index c2b429c08bb..1a2ced3b6f2 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt @@ -1,46 +1,18 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(3,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(4,13): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(5,13): error TS2367: No best common type exists between 'U' and 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(10,13): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(11,13): error TS2367: No best common type exists between 'U' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(18,14): error TS2367: No best common type exists between 'V' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(19,14): error TS2367: No best common type exists between 'T' and 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(23,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(24,13): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(25,13): error TS2367: No best common type exists between 'U' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(28,14): error TS2367: No best common type exists between 'T' and 'Date'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(29,14): error TS2367: No best common type exists between 'Date' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(60,14): error TS2367: No best common type exists between 'number' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(61,14): error TS2367: No best common type exists between 'T' and 'number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(65,14): error TS2367: No best common type exists between 'string' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(66,14): error TS2367: No best common type exists between 'T' and 'string'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(70,14): error TS2367: No best common type exists between 'boolean' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(71,14): error TS2367: No best common type exists between 'T' and 'boolean'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(118,15): error TS2367: No best common type exists between 'typeof E' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(119,15): error TS2367: No best common type exists between 'T' and 'typeof E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(121,15): error TS2367: No best common type exists between 'E' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(122,15): error TS2367: No best common type exists between 'T' and 'E'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(143,18): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(144,19): error TS2367: No best common type exists between 'T' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(145,19): error TS2367: No best common type exists between 'V' and 'T'. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (29 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (5 errors) ==== // checking whether other types are subtypes of type parameters with constraints function f1(x: T, y: U) { ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. var r = true ? x : y; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r = true ? y : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. } // V > U > T @@ -50,27 +22,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. var r = true ? x : y; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r = true ? y : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. // ok var r2 = true ? z : y; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'U'. var r2 = true ? y : z; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'V'. // ok - var r2 = true ? z : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'T'. - var r2 = true ? x : z; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'V'. + var r2a = true ? z : x; + var r2b = true ? x : z; } // Date > U > T @@ -78,19 +38,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. var r = true ? x : y; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r = true ? y : x; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. // ok var r2 = true ? x : new Date(); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Date'. var r2 = true ? new Date() : x; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Date' and 'T'. // ok var r3 = true ? y : new Date(); @@ -121,30 +73,18 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } function f5(x: T) { - var r1 = true ? 1 : x; // error - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'number' and 'T'. - var r1 = true ? x : 1; // error - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'number'. + var r1 = true ? 1 : x; // ok + var r1 = true ? x : 1; // ok } function f6(x: T) { - var r2 = true ? '' : x; // error - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'string' and 'T'. - var r2 = true ? x : ''; // error - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'string'. + var r2 = true ? '' : x; // ok + var r2 = true ? x : ''; // ok } function f7(x: T) { - var r3 = true ? true : x; // error - ~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'boolean' and 'T'. - var r3 = true ? x : true; // error - ~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'boolean'. + var r3 = true ? true : x; // ok + var r3 = true ? x : true; // ok } function f8(x: T) { @@ -191,19 +131,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } function f16(x: T) { - var r13 = true ? E : x; // BUG 831833 - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'typeof E' and 'T'. - var r13 = true ? x : E; // BUG 831833 - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'typeof E'. + var r13 = true ? E : x; // ok + var r13 = true ? x : E; // ok - var r14 = true ? E.A : x; // BUG 831833 - ~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'E' and 'T'. - var r14 = true ? x : E.A; // BUG 831833 - ~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'E'. + var r14 = true ? E.A : x; // ok + var r14 = true ? x : E.A; // ok } function f17(x: T) { @@ -228,11 +160,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. var r18 = true ? x : a; // ok - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'V'. var r18 = true ? a : x; // ok - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'T'. } } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js index bf582fe13e5..bd729f36222 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js @@ -16,8 +16,8 @@ function f2(x: T, y: U, z: V) { var r2 = true ? y : z; // ok - var r2 = true ? z : x; - var r2 = true ? x : z; + var r2a = true ? z : x; + var r2b = true ? x : z; } // Date > U > T @@ -58,18 +58,18 @@ function f4(x: T) { } function f5(x: T) { - var r1 = true ? 1 : x; // error - var r1 = true ? x : 1; // error + var r1 = true ? 1 : x; // ok + var r1 = true ? x : 1; // ok } function f6(x: T) { - var r2 = true ? '' : x; // error - var r2 = true ? x : ''; // error + var r2 = true ? '' : x; // ok + var r2 = true ? x : ''; // ok } function f7(x: T) { - var r3 = true ? true : x; // error - var r3 = true ? x : true; // error + var r3 = true ? true : x; // ok + var r3 = true ? x : true; // ok } function f8(x: T) { @@ -116,11 +116,11 @@ function f15>(x: T) { } function f16(x: T) { - var r13 = true ? E : x; // BUG 831833 - var r13 = true ? x : E; // BUG 831833 + var r13 = true ? E : x; // ok + var r13 = true ? x : E; // ok - var r14 = true ? E.A : x; // BUG 831833 - var r14 = true ? x : E.A; // BUG 831833 + var r14 = true ? E.A : x; // ok + var r14 = true ? x : E.A; // ok } function f17(x: T) { @@ -171,8 +171,8 @@ function f2(x, y, z) { var r2 = true ? z : y; var r2 = true ? y : z; // ok - var r2 = true ? z : x; - var r2 = true ? x : z; + var r2a = true ? z : x; + var r2b = true ? x : z; } // Date > U > T function f3(x, y) { @@ -222,16 +222,16 @@ function f4(x) { var r0b = true ? x : u; // ok } function f5(x) { - var r1 = true ? 1 : x; // error - var r1 = true ? x : 1; // error + var r1 = true ? 1 : x; // ok + var r1 = true ? x : 1; // ok } function f6(x) { - var r2 = true ? '' : x; // error - var r2 = true ? x : ''; // error + var r2 = true ? '' : x; // ok + var r2 = true ? x : ''; // ok } function f7(x) { - var r3 = true ? true : x; // error - var r3 = true ? x : true; // error + var r3 = true ? true : x; // ok + var r3 = true ? x : true; // ok } function f8(x) { var r4 = true ? new Date() : x; // ok @@ -275,10 +275,10 @@ function f15(x) { var r12 = true ? x : c2; // ok } function f16(x) { - var r13 = true ? E : x; // BUG 831833 - var r13 = true ? x : E; // BUG 831833 - var r14 = true ? 0 /* A */ : x; // BUG 831833 - var r14 = true ? x : 0 /* A */; // BUG 831833 + var r13 = true ? E : x; // ok + var r13 = true ? x : E; // ok + var r14 = true ? 0 /* A */ : x; // ok + var r14 = true ? x : 0 /* A */; // ok } function f17(x) { var af; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt index f26389bb2a2..2a5fa5ad362 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt @@ -1,13 +1,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(3,12): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(5,13): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(6,13): error TS2367: No best common type exists between 'U' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(9,14): error TS2367: No best common type exists between 'T' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(10,14): error TS2367: No best common type exists between 'V' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(13,14): error TS2367: No best common type exists between 'V' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(14,14): error TS2367: No best common type exists between 'U' and 'V'. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts (7 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts (1 errors) ==== // checking whether other types are subtypes of type parameters with constraints function f(t: T, u: U, v: V) { @@ -15,25 +9,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. // ok var r = true ? t : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r = true ? u : t; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. - // error + // ok var r2 = true ? t : v; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'V'. var r2 = true ? v : t; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'T'. - // error + // ok var r3 = true ? v : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'U'. var r3 = true ? u : v; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'V'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.js index 229beffd334..790c0fa5b96 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.js @@ -6,11 +6,11 @@ function f(t: T, u: U, v: V) { var r = true ? t : u; var r = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; } @@ -21,10 +21,10 @@ function f(t, u, v) { // ok var r = true ? t : u; var r = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index 082d78d43d5..872cb8ef965 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -1,11 +1,3 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(6,13): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(7,13): error TS2367: No best common type exists between 'U' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(10,14): error TS2367: No best common type exists between 'T' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(11,14): error TS2367: No best common type exists between 'V' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(27,14): error TS2367: No best common type exists between 'Foo' and 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(45,7): error TS2416: Class 'D3' incorrectly extends base class 'B1': Types of property 'foo' are incompatible: Type 'V' is not assignable to type 'Foo': @@ -29,34 +21,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (18 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (10 errors) ==== // checking whether other types are subtypes of type parameters with constraints class Foo { foo: number; } function f(t: T, u: U, v: V) { - // error + // ok var r = true ? t : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r = true ? u : t; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. - // error + // ok var r2 = true ? t : v; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'V'. var r2 = true ? v : t; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'T'. - // error + // ok var r3 = true ? v : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'U'. var r3 = true ? u : v; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'V'. // ok var r4 = true ? t : new Foo(); @@ -66,13 +46,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // BUG, should be error + // ok var r6 = true ? v : new Foo(); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'Foo'. var r6 = true ? new Foo() : v; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'V'. } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js index 96983ecf68f..f1cf61d484f 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js @@ -3,15 +3,15 @@ class Foo { foo: number; } function f(t: T, u: U, v: V) { - // error + // ok var r = true ? t : u; var r = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; @@ -23,7 +23,7 @@ function f(t: T, u: U, v: V) { var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // BUG, should be error + // ok var r6 = true ? v : new Foo(); var r6 = true ? new Foo() : v; @@ -92,13 +92,13 @@ var Foo = (function () { return Foo; })(); function f(t, u, v) { - // error + // ok var r = true ? t : u; var r = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; // ok @@ -107,7 +107,7 @@ function f(t, u, v) { // ok var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // BUG, should be error + // ok var r6 = true ? v : new Foo(); var r6 = true ? new Foo() : v; } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index bf7cbbcae03..f4b1d7ef041 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -1,30 +1,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,12): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,30): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,48): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(6,14): error TS2367: No best common type exists between 'T' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(7,14): error TS2367: No best common type exists between 'U' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(10,14): error TS2367: No best common type exists between 'T' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(11,14): error TS2367: No best common type exists between 'V' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(18,14): error TS2367: No best common type exists between 'T' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(19,14): error TS2367: No best common type exists between 'Foo' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(22,14): error TS2367: No best common type exists between 'U' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(23,14): error TS2367: No best common type exists between 'Foo' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(27,14): error TS2367: No best common type exists between 'Foo' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(31,14): error TS2367: No best common type exists between 'T' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(32,14): error TS2367: No best common type exists between 'Foo' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(35,14): error TS2367: No best common type exists between 'U' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(36,14): error TS2367: No best common type exists between 'Foo' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(39,14): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(40,14): error TS2367: No best common type exists between 'Foo' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(44,15): error TS2367: No best common type exists between 'T' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(45,15): error TS2367: No best common type exists between 'Foo' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(48,15): error TS2367: No best common type exists between 'U' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(49,15): error TS2367: No best common type exists between 'Foo' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(52,15): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(53,15): error TS2367: No best common type exists between 'Foo' and 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -111,7 +87,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(153,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (99 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (75 errors) ==== // checking whether other types are subtypes of type parameters with constraints class Foo { foo: T; } @@ -122,103 +98,55 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. - // error + // ok var r1 = true ? t : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. var r1 = true ? u : t; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'T'. - // error + // ok var r2 = true ? t : v; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'V'. var r2 = true ? v : t; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'T'. - // error + // ok var r3 = true ? v : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'U'. var r3 = true ? u : v; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'V'. - // ok? + // ok var r4 = true ? t : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Foo'. var r4 = true ? new Foo() : t; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'T'. - // ok? + // ok var r5 = true ? u : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'Foo'. var r5 = true ? new Foo() : u; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'U'. - // ok? + // ok var r6 = true ? v : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'Foo'. var r6 = true ? new Foo() : v; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'V'. - // ok? + // ok var r7 = true ? t : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Foo'. var r7 = true ? new Foo() : t; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'T'. - // ok? + // ok var r8 = true ? u : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'Foo'. var r8 = true ? new Foo() : u; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'U'. - // ok? + // ok var r9 = true ? v : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'Foo'. var r9 = true ? new Foo() : v; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'V'. - // ok? + // ok var r10 = true ? t : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Foo'. var r10 = true ? new Foo() : t; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'T'. - // ok? + // ok var r11 = true ? u : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'Foo'. var r11 = true ? new Foo() : u; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'U'. - // ok? + // ok var r12 = true ? v : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'Foo'. var r12 = true ? new Foo() : v; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'V'. } module M1 { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js index e345d746bf7..1caa7d99087 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js @@ -3,53 +3,53 @@ class Foo { foo: T; } function f, U extends Foo, V extends Foo>(t: T, u: U, v: V) { - // error + // ok var r1 = true ? t : u; var r1 = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; - // ok? + // ok var r4 = true ? t : new Foo(); var r4 = true ? new Foo() : t; - // ok? + // ok var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // ok? + // ok var r6 = true ? v : new Foo(); var r6 = true ? new Foo() : v; - // ok? + // ok var r7 = true ? t : new Foo(); var r7 = true ? new Foo() : t; - // ok? + // ok var r8 = true ? u : new Foo(); var r8 = true ? new Foo() : u; - // ok? + // ok var r9 = true ? v : new Foo(); var r9 = true ? new Foo() : v; - // ok? + // ok var r10 = true ? t : new Foo(); var r10 = true ? new Foo() : t; - // ok? + // ok var r11 = true ? u : new Foo(); var r11 = true ? new Foo() : u; - // ok? + // ok var r12 = true ? v : new Foo(); var r12 = true ? new Foo() : v; } @@ -171,40 +171,40 @@ var Foo = (function () { return Foo; })(); function f(t, u, v) { - // error + // ok var r1 = true ? t : u; var r1 = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; - // ok? + // ok var r4 = true ? t : new Foo(); var r4 = true ? new Foo() : t; - // ok? + // ok var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // ok? + // ok var r6 = true ? v : new Foo(); var r6 = true ? new Foo() : v; - // ok? + // ok var r7 = true ? t : new Foo(); var r7 = true ? new Foo() : t; - // ok? + // ok var r8 = true ? u : new Foo(); var r8 = true ? new Foo() : u; - // ok? + // ok var r9 = true ? v : new Foo(); var r9 = true ? new Foo() : v; - // ok? + // ok var r10 = true ? t : new Foo(); var r10 = true ? new Foo() : t; - // ok? + // ok var r11 = true ? u : new Foo(); var r11 = true ? new Foo() : u; - // ok? + // ok var r12 = true ? v : new Foo(); var r12 = true ? new Foo() : v; } diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 5006e00d52b..12344a46f3f 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -368,8 +368,8 @@ var r2a = [r2arg1, r2arg2]; >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : { (x: number): string[]; }[] ->[r2arg2, r2arg1] : { (x: number): string[]; }[] +>r2b : { (x: T): string[]; }[] +>[r2arg2, r2arg1] : { (x: T): string[]; }[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -399,8 +399,8 @@ var r3a = [r3arg1, r3arg2]; >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : { (x: number): void; }[] ->[r3arg2, r3arg1] : { (x: number): void; }[] +>r3b : { (x: T): T; }[] +>[r3arg2, r3arg1] : { (x: T): T; }[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -795,8 +795,8 @@ var r12a = [r12arg1, r12arg2]; >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : { (x: Base[], y: Derived2[]): Derived[]; }[] ->[r12arg2, r12arg1] : { (x: Base[], y: Derived2[]): 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[] diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 8c136113464..be5fb44c9c7 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -340,14 +340,14 @@ module Errors { >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U var r3a = [r3arg2, r3arg]; ->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; }> >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 : {}[] ->[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; }> >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 @@ -535,8 +535,8 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : { (x: { a: T; b: T; }): number; }[] ->[r7arg3, r7arg2] : { (x: { a: T; b: T; }): 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 07b3af3e540..f31a4fa928e 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -318,8 +318,8 @@ var r3a = [r3arg, r3arg2]; >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : { (x: T): void; }[] ->[r3arg2, r3arg] : { (x: T): void; }[] +>r3b : { (x: T): T; }[] +>[r3arg2, r3arg] : { (x: T): T; }[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -442,8 +442,8 @@ var r6a = [r6arg, r6arg2]; >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : { (x: (arg: T) => Derived): T; }[] ->[r6arg2, r6arg] : { (x: (arg: T) => Derived): 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 @@ -491,8 +491,8 @@ var r11a = [r11arg, r11arg2]; >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : { (x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[] ->[r11arg2, r11arg] : { (x: { foo: T; }, y: { foo: T; bar: T; }): 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 @@ -534,8 +534,8 @@ var r15a = [r15arg, r15arg2]; >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : { (x: { a: T; b: T; }): T[]; }[] ->[r15arg2, r15arg] : { (x: { a: T; b: T; }): T[]; }[] +>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[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index fdba6014751..3832697d04c 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -360,8 +360,8 @@ var r2a = [r2arg1, r2arg2]; >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : { new (x: number): string[]; }[] ->[r2arg2, r2arg1] : { new (x: number): string[]; }[] +>r2b : { new (x: T): string[]; }[] +>[r2arg2, r2arg1] : { new (x: T): string[]; }[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -389,8 +389,8 @@ var r3a = [r3arg1, r3arg2]; >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : { new (x: number): void; }[] ->[r3arg2, r3arg1] : { new (x: number): void; }[] +>r3b : { new (x: T): T; }[] +>[r3arg2, r3arg1] : { new (x: T): T; }[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -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 : {}[] ->[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; }> >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 : {}[] ->[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; }> >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 @@ -747,8 +747,8 @@ var r12a = [r12arg1, r12arg2]; >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : { new (x: Base[], y: Derived2[]): Derived[]; }[] ->[r12arg2, r12arg1] : { new (x: Base[], y: Derived2[]): 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[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index cf4db8939fd..ff6b9adef0a 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -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 : {}[] ->[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; }> >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 : {}[] ->[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; }> >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 @@ -497,8 +497,8 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : { new (x: { a: T; b: T; }): number; }[] ->[r7arg3, r7arg2] : { new (x: { a: T; b: T; }): 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 a9116880df3..473bbe9a205 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -307,8 +307,8 @@ var r3a = [r3arg, r3arg2]; >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : { new (x: T): void; }[] ->[r3arg2, r3arg] : { new (x: T): void; }[] +>r3b : { new (x: T): T; }[] +>[r3arg2, r3arg] : { new (x: T): T; }[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -421,8 +421,8 @@ var r6a = [r6arg, r6arg2]; >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : { new (x: new (arg: T) => Derived): T; }[] ->[r6arg2, r6arg] : { new (x: new (arg: T) => Derived): 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 @@ -466,8 +466,8 @@ var r11a = [r11arg, r11arg2]; >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : { new (x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[] ->[r11arg2, r11arg] : { new (x: { foo: T; }, y: { foo: T; bar: T; }): 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 @@ -505,8 +505,8 @@ var r15a = [r15arg, r15arg2]; >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : { new (x: { a: T; b: T; }): T[]; }[] ->[r15arg2, r15arg] : { new (x: { a: T; b: T; }): T[]; }[] +>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[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt index 74d47f12565..ac17303572d 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt @@ -4,10 +4,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Property '1' is optional in type 'S2' but required in type 'T2'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(26,11): error TS2429: Interface 'S3' incorrectly extends interface 'T3': Property ''1'' is optional in type 'S3' but required in type 'T3'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(33,9): error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (4 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (3 errors) ==== // Derived member is optional but base member is not, should be an error interface Base { foo: string; } @@ -49,6 +48,4 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW // object literal case var a: { Foo: Base; } var b: { Foo?: Derived; } - var r = true ? a : b; // error - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'. \ No newline at end of file + var r = true ? a : b; // ok \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.js b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.js index 186f3ba4544..33c4cc927da 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.js @@ -31,11 +31,11 @@ interface S3 extends T3 { // object literal case var a: { Foo: Base; } var b: { Foo?: Derived; } -var r = true ? a : b; // error +var r = true ? a : b; // ok //// [subtypingWithObjectMembersOptionality2.js] // Derived member is optional but base member is not, should be an error // object literal case var a; var b; -var r = true ? a : b; // error +var r = true ? a : b; // ok diff --git a/tests/baselines/reference/targetTypeTest2.types b/tests/baselines/reference/targetTypeTest2.types index 795dd7036f7..f40d68d075a 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"] : any[] +>[1,2,"3"] : Array 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] : any[] +>[stuff1, stuff2, stuff3] : Array >stuff1 : string >stuff2 : number >stuff3 : number diff --git a/tests/baselines/reference/targetTypeTest3.errors.txt b/tests/baselines/reference/targetTypeTest3.errors.txt index e81cba71a47..d9dbec41150 100644 --- a/tests/baselines/reference/targetTypeTest3.errors.txt +++ b/tests/baselines/reference/targetTypeTest3.errors.txt @@ -1,5 +1,6 @@ -tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '{}[]' is not assignable to type 'string[]': - Type '{}' is not assignable to type 'string'. +tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type 'Array' is not assignable to type 'string[]': + Type 'string | number' is not assignable to type 'string': + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/targetTypeTest3.ts (1 errors) ==== @@ -8,8 +9,9 @@ tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '{}[]' is not a var a : string[] = [1,2,"3"]; // should produce an error ~ -!!! error TS2322: Type '{}[]' is not assignable to type 'string[]': -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type 'Array' 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'. function func1(stuff:any[]) { return stuff; } diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.types b/tests/baselines/reference/thisInPropertyBoundDeclarations.types index 1ccebef5eaa..899aa41a684 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); } ] : Function[] +>[ (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 efc2ff24124..7f106daced9 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -219,7 +219,7 @@ throw []; >[] : undefined[] throw ['a', ['b']]; ->['a', ['b']] : {}[] +>['a', ['b']] : Array >['b'] : string[] throw /[a-z]/; diff --git a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt index e1681f5cc29..823bf93e535 100644 --- a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt +++ b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt @@ -1,7 +1,9 @@ -tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'. - Type '{}' is not assignable to type 'number'. -tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'. - Type '{}' is not assignable to type 'number'. +tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type 'Array' 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[]'. + Type 'string | number' is not assignable to type 'number': + Type 'string' is not assignable to type 'number'. ==== tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts (2 errors) ==== @@ -11,12 +13,14 @@ 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 '{}[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type '{}' is not assignable to type 'number'. +!!! error TS2345: Argument of type 'Array' 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 '{}[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type '{}' is not assignable to type 'number'. +!!! error TS2345: Argument of type 'Array' 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/tupleTypes.errors.txt b/tests/baselines/reference/tupleTypes.errors.txt index fcc65ff5c23..8bf6cca4855 100644 --- a/tests/baselines/reference/tupleTypes.errors.txt +++ b/tests/baselines/reference/tupleTypes.errors.txt @@ -1,16 +1,17 @@ tests/cases/compiler/tupleTypes.ts(1,9): error TS1122: A tuple type element list cannot be empty. -tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type '{}[]' is not assignable to type '[number, string]': - Property '0' is missing in type '{}[]'. +tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type 'undefined[]' is not assignable to type '[number, string]': + Property '0' is missing in type 'undefined[]'. tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]': Property '1' is missing in type '[number]'. tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' is not assignable to type '[number, string]': Types of property '0' are incompatible: Type 'string' is not assignable to type 'number'. -tests/cases/compiler/tupleTypes.ts(41,1): error TS2323: Type '{}[]' is not assignable to type '[number, string]'. +tests/cases/compiler/tupleTypes.ts(41,1): error TS2323: Type 'undefined[]' is not assignable to type '[number, string]'. tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]': Types of property 'pop' are incompatible: - Type '() => {}' is not assignable to type '() => number': - Type '{}' is not assignable to type 'number'. + Type '() => string | number' is not assignable to type '() => number': + Type 'string | number' is not assignable to type 'number': + Type 'string' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]': Types of property 'pop' are incompatible: Type '() => {}' is not assignable to type '() => number': @@ -36,13 +37,13 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n var t0: number; var t1 = t[1]; // string var t1: string; - var t2 = t[2]; // {} - var t2: {}; + var t2 = t[2]; // number|string + var t2: number|string; t = []; // Error ~ -!!! error TS2322: Type '{}[]' is not assignable to type '[number, string]': -!!! error TS2322: Property '0' is missing in type '{}[]'. +!!! error TS2322: Type 'undefined[]' is not assignable to type '[number, string]': +!!! error TS2322: Property '0' is missing in type 'undefined[]'. t = [1]; // Error ~ !!! error TS2322: Type '[number]' is not assignable to type '[number, string]': @@ -70,15 +71,15 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n var tt0: number; var tt1 = tt[1]; var tt1: string; - var tt2 = tt[2]; - var tt2: {}; + var tt2 = tt[2]; + var tt2: number | string; tt = tuple2(1, undefined); tt = [1, undefined]; tt = [undefined, undefined]; tt = []; // Error ~~ -!!! error TS2323: Type '{}[]' is not assignable to type '[number, string]'. +!!! error TS2323: Type 'undefined[]' is not assignable to type '[number, string]'. var a: number[]; var a1: [number, string]; @@ -88,8 +89,9 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n ~ !!! error TS2322: Type '[number, string]' is not assignable to type 'number[]': !!! error TS2322: Types of property 'pop' are incompatible: -!!! error TS2322: Type '() => {}' is not assignable to type '() => number': -!!! error TS2322: Type '{}' is not assignable to type 'number'. +!!! error TS2322: Type '() => string | number' is not assignable to type '() => number': +!!! error TS2322: Type 'string | number' is not assignable to type 'number': +!!! error TS2322: Type 'string' is not assignable to type 'number'. a = a2; a = a3; // Error ~ diff --git a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types index 584ae0dcb3c..1cee9140a01 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" }] : 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": string; "type": string; "link": string; "icon": string; } diff --git a/tests/baselines/reference/typeArgInference2.errors.txt b/tests/baselines/reference/typeArgInference2.errors.txt new file mode 100644 index 00000000000..cf188972b7d --- /dev/null +++ b/tests/baselines/reference/typeArgInference2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/typeArgInference2.ts(12,10): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/typeArgInference2.ts (1 errors) ==== + interface Item { + name: string; + } + + declare function foo(x?: T, y?: T): T; + + var z1 = foo(null); // any + var z2 = foo(); // Item + var z3 = foo({ name: null }); // { name: any } + var z4 = foo({ name: "abc" }); // { name: string } + var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } + var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgInference2.js b/tests/baselines/reference/typeArgInference2.js index ef76c9b33e7..193345cdeb3 100644 --- a/tests/baselines/reference/typeArgInference2.js +++ b/tests/baselines/reference/typeArgInference2.js @@ -10,7 +10,7 @@ var z2 = foo(); // Item var z3 = foo({ name: null }); // { name: any } var z4 = foo({ name: "abc" }); // { name: string } var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } -var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item +var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error //// [typeArgInference2.js] var z1 = foo(null); // any @@ -18,4 +18,4 @@ var z2 = foo(); // Item var z3 = foo({ name: null }); // { name: any } var z4 = foo({ name: "abc" }); // { name: string } var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } -var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item +var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error diff --git a/tests/baselines/reference/typeArgInference2.types b/tests/baselines/reference/typeArgInference2.types deleted file mode 100644 index 1b94a0638bd..00000000000 --- a/tests/baselines/reference/typeArgInference2.types +++ /dev/null @@ -1,61 +0,0 @@ -=== tests/cases/compiler/typeArgInference2.ts === -interface Item { ->Item : Item - - name: string; ->name : string -} - -declare function foo(x?: T, y?: T): T; ->foo : (x?: T, y?: T) => T ->T : T ->Item : Item ->x : T ->T : T ->y : T ->T : T ->T : T - -var z1 = foo(null); // any ->z1 : any ->foo(null) : any ->foo : (x?: T, y?: T) => T - -var z2 = foo(); // Item ->z2 : Item ->foo() : Item ->foo : (x?: T, y?: T) => T - -var z3 = foo({ name: null }); // { name: any } ->z3 : { name: any; } ->foo({ name: null }) : { name: any; } ->foo : (x?: T, y?: T) => T ->{ name: null } : { name: null; } ->name : null - -var z4 = foo({ name: "abc" }); // { name: string } ->z4 : { name: string; } ->foo({ name: "abc" }) : { name: string; } ->foo : (x?: T, y?: T) => T ->{ name: "abc" } : { name: string; } ->name : string - -var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } ->z5 : { name: string; a: number; } ->foo({ name: "abc", a: 5 }) : { name: string; a: number; } ->foo : (x?: T, y?: T) => T ->{ name: "abc", a: 5 } : { name: string; a: number; } ->name : string ->a : number - -var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item ->z6 : Item ->foo({ name: "abc", a: 5 }, { name: "def", b: 5 }) : Item ->foo : (x?: T, y?: T) => T ->{ name: "abc", a: 5 } : { name: string; a: number; } ->name : string ->a : number ->{ name: "def", b: 5 } : { name: string; b: number; } ->name : string ->b : number - diff --git a/tests/baselines/reference/typeArgInference2WithError.errors.txt b/tests/baselines/reference/typeArgInference2WithError.errors.txt index 26259abf37b..83fa81b5524 100644 --- a/tests/baselines/reference/typeArgInference2WithError.errors.txt +++ b/tests/baselines/reference/typeArgInference2WithError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeArgInference2WithError.ts(7,14): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Item'. +tests/cases/compiler/typeArgInference2WithError.ts(7,10): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/compiler/typeArgInference2WithError.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/typeArgInference2WithError.ts(7,14): error TS2345: Argument declare function foo(x?: T, y?: T): T; var z7 = foo("abc", 5); // Error - ~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Item'. \ No newline at end of file + ~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt new file mode 100644 index 00000000000..dbff8b83854 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -0,0 +1,109 @@ +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts (2 errors) ==== + // Generic call with no parameters + function noParams() { } + noParams(); + noParams(); + noParams<{}>(); + + // Generic call with parameters but none use type parameter type + function noGenericParams(n: string) { } + noGenericParams(''); + noGenericParams(''); + noGenericParams<{}>(''); + + // Generic call with multiple type parameters and only one used in parameter type annotation + function someGenerics1(n: T, m: number) { } + someGenerics1(3, 4); + someGenerics1(3, 4); + + // Generic call with argument of function type whose parameter is of type parameter type + function someGenerics2a(n: (x: T) => void) { } + someGenerics2a((n: string) => n); + someGenerics2a((n: string) => n); + someGenerics2a((n) => n.substr(0)); + + function someGenerics2b(n: (x: T, y: U) => void) { } + someGenerics2b((n: string, x: number) => n); + someGenerics2b((n: string, t: number) => n); + someGenerics2b((n, t) => n.substr(t * t)); + + // Generic call with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter + function someGenerics3(producer: () => T) { } + someGenerics3(() => ''); + someGenerics3(() => undefined); + someGenerics3(() => 3); + + // 2 parameter generic call with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type + function someGenerics4(n: T, f: (x: U) => void) { } + someGenerics4(4, () => null); + someGenerics4('', () => 3); + someGenerics4(null, null); + + // 2 parameter generic call with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type + function someGenerics5(n: T, f: (x: U) => void) { } + someGenerics5(4, () => null); + someGenerics5('', () => 3); + someGenerics5(null, null); + + // Generic call with multiple arguments of function types that each have parameters of the same generic type + function someGenerics6(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { } + someGenerics6(n => n, n => n, n => n); + someGenerics6(n => n, n => n, n => n); + someGenerics6((n: number) => n, (n: number) => n, (n: number) => n); + + // Generic call with multiple arguments of function types that each have parameters of different generic type + function someGenerics7(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } + someGenerics7(n => n, n => n, n => n); + someGenerics7(n => n, n => n, n => n); + someGenerics7((n: number) => n, (n: string) => n, (n: number) => n); + + // Generic call with argument of generic function type + function someGenerics8(n: T): T { return n; } + var x = someGenerics8(someGenerics7); + x(null, null, null); + + // Generic call with multiple parameters of generic type passed arguments with no best common type + function someGenerics9(a: T, b: T, c: T): T { + return null; + } + var a9a = someGenerics9('', 0, []); + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var a9a: {}; + var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); + var a9b: { a?: number; b?: string; }; + + // Generic call with multiple parameters of generic type passed arguments with multiple best common types + interface A91 { + x: number; + y?: string; + } + interface A92 { + x: number; + z?: Date; + } + var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var a9e: {}; + var a9f = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); + var a9f: A92; + + // Generic call with multiple parameters of generic type passed arguments with a single best common type + var a9d = someGenerics9({ x: 3 }, { x: 6 }, { x: 6 }); + var a9d: { x: number; }; + + // Generic call with multiple parameters of generic type where one argument is of type 'any' + var anyVar: any; + var a = someGenerics9(7, anyVar, 4); + var a: any; + + // Generic call with multiple parameters of generic type where one argument is [] and the other is not 'any' + var arr = someGenerics9([], null, undefined); + var arr: any[]; + + \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.types b/tests/baselines/reference/typeArgumentInference.types deleted file mode 100644 index 40136bd10c3..00000000000 --- a/tests/baselines/reference/typeArgumentInference.types +++ /dev/null @@ -1,468 +0,0 @@ -=== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts === -// Generic call with no parameters -function noParams() { } ->noParams : () => void ->T : T - -noParams(); ->noParams() : void ->noParams : () => void - -noParams(); ->noParams() : void ->noParams : () => void - -noParams<{}>(); ->noParams<{}>() : void ->noParams : () => void - -// Generic call with parameters but none use type parameter type -function noGenericParams(n: string) { } ->noGenericParams : (n: string) => void ->T : T ->n : string - -noGenericParams(''); ->noGenericParams('') : void ->noGenericParams : (n: string) => void - -noGenericParams(''); ->noGenericParams('') : void ->noGenericParams : (n: string) => void - -noGenericParams<{}>(''); ->noGenericParams<{}>('') : void ->noGenericParams : (n: string) => void - -// Generic call with multiple type parameters and only one used in parameter type annotation -function someGenerics1(n: T, m: number) { } ->someGenerics1 : (n: T, m: number) => void ->T : T ->U : U ->n : T ->T : T ->m : number - -someGenerics1(3, 4); ->someGenerics1(3, 4) : void ->someGenerics1 : (n: T, m: number) => void - -someGenerics1(3, 4); ->someGenerics1(3, 4) : void ->someGenerics1 : (n: T, m: number) => void - -// Generic call with argument of function type whose parameter is of type parameter type -function someGenerics2a(n: (x: T) => void) { } ->someGenerics2a : (n: (x: T) => void) => void ->T : T ->n : (x: T) => void ->x : T ->T : T - -someGenerics2a((n: string) => n); ->someGenerics2a((n: string) => n) : void ->someGenerics2a : (n: (x: T) => void) => void ->(n: string) => n : (n: string) => string ->n : string ->n : string - -someGenerics2a((n: string) => n); ->someGenerics2a((n: string) => n) : void ->someGenerics2a : (n: (x: T) => void) => void ->(n: string) => n : (n: string) => string ->n : string ->n : string - -someGenerics2a((n) => n.substr(0)); ->someGenerics2a((n) => n.substr(0)) : void ->someGenerics2a : (n: (x: T) => void) => void ->(n) => n.substr(0) : (n: string) => string ->n : string ->n.substr(0) : string ->n.substr : (from: number, length?: number) => string ->n : string ->substr : (from: number, length?: number) => string - -function someGenerics2b(n: (x: T, y: U) => void) { } ->someGenerics2b : (n: (x: T, y: U) => void) => void ->T : T ->U : U ->n : (x: T, y: U) => void ->x : T ->T : T ->y : U ->U : U - -someGenerics2b((n: string, x: number) => n); ->someGenerics2b((n: string, x: number) => n) : void ->someGenerics2b : (n: (x: T, y: U) => void) => void ->(n: string, x: number) => n : (n: string, x: number) => string ->n : string ->x : number ->n : string - -someGenerics2b((n: string, t: number) => n); ->someGenerics2b((n: string, t: number) => n) : void ->someGenerics2b : (n: (x: T, y: U) => void) => void ->(n: string, t: number) => n : (n: string, t: number) => string ->n : string ->t : number ->n : string - -someGenerics2b((n, t) => n.substr(t * t)); ->someGenerics2b((n, t) => n.substr(t * t)) : void ->someGenerics2b : (n: (x: T, y: U) => void) => void ->(n, t) => n.substr(t * t) : (n: string, t: number) => string ->n : string ->t : number ->n.substr(t * t) : string ->n.substr : (from: number, length?: number) => string ->n : string ->substr : (from: number, length?: number) => string ->t * t : number ->t : number ->t : number - -// Generic call with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter -function someGenerics3(producer: () => T) { } ->someGenerics3 : (producer: () => T) => void ->T : T ->producer : () => T ->T : T - -someGenerics3(() => ''); ->someGenerics3(() => '') : void ->someGenerics3 : (producer: () => T) => void ->() => '' : () => string - -someGenerics3(() => undefined); ->someGenerics3(() => undefined) : void ->someGenerics3 : (producer: () => T) => void ->Date : Date ->() => undefined : () => any ->undefined : undefined - -someGenerics3(() => 3); ->someGenerics3(() => 3) : void ->someGenerics3 : (producer: () => T) => void ->() => 3 : () => number - -// 2 parameter generic call with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type -function someGenerics4(n: T, f: (x: U) => void) { } ->someGenerics4 : (n: T, f: (x: U) => void) => void ->T : T ->U : U ->n : T ->T : T ->f : (x: U) => void ->x : U ->U : U - -someGenerics4(4, () => null); ->someGenerics4(4, () => null) : void ->someGenerics4 : (n: T, f: (x: U) => void) => void ->() => null : () => any - -someGenerics4('', () => 3); ->someGenerics4('', () => 3) : void ->someGenerics4 : (n: T, f: (x: U) => void) => void ->() => 3 : () => number - -someGenerics4(null, null); ->someGenerics4(null, null) : void ->someGenerics4 : (n: T, f: (x: U) => void) => void - -// 2 parameter generic call with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type -function someGenerics5(n: T, f: (x: U) => void) { } ->someGenerics5 : (n: T, f: (x: U) => void) => void ->U : U ->T : T ->n : T ->T : T ->f : (x: U) => void ->x : U ->U : U - -someGenerics5(4, () => null); ->someGenerics5(4, () => null) : void ->someGenerics5 : (n: T, f: (x: U) => void) => void ->() => null : () => any - -someGenerics5('', () => 3); ->someGenerics5('', () => 3) : void ->someGenerics5 : (n: T, f: (x: U) => void) => void ->() => 3 : () => number - -someGenerics5(null, null); ->someGenerics5(null, null) : void ->someGenerics5 : (n: T, f: (x: U) => void) => void - -// Generic call with multiple arguments of function types that each have parameters of the same generic type -function someGenerics6(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { } ->someGenerics6 : (a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void ->A : A ->a : (a: A) => A ->a : A ->A : A ->A : A ->b : (b: A) => A ->b : A ->A : A ->A : A ->c : (c: A) => A ->c : A ->A : A ->A : A - -someGenerics6(n => n, n => n, n => n); ->someGenerics6(n => n, n => n, n => n) : void ->someGenerics6 : (a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void ->n => n : (n: {}) => {} ->n : {} ->n : {} ->n => n : (n: {}) => {} ->n : {} ->n : {} ->n => n : (n: {}) => {} ->n : {} ->n : {} - -someGenerics6(n => n, n => n, n => n); ->someGenerics6(n => n, n => n, n => n) : void ->someGenerics6 : (a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void ->n => n : (n: number) => number ->n : number ->n : number ->n => n : (n: number) => number ->n : number ->n : number ->n => n : (n: number) => number ->n : number ->n : number - -someGenerics6((n: number) => n, (n: number) => n, (n: number) => n); ->someGenerics6((n: number) => n, (n: number) => n, (n: number) => n) : void ->someGenerics6 : (a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void ->(n: number) => n : (n: number) => number ->n : number ->n : number ->(n: number) => n : (n: number) => number ->n : number ->n : number ->(n: number) => n : (n: number) => number ->n : number ->n : number - -// Generic call with multiple arguments of function types that each have parameters of different generic type -function someGenerics7(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } ->someGenerics7 : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->A : A ->B : B ->C : C ->a : (a: A) => A ->a : A ->A : A ->A : A ->b : (b: B) => B ->b : B ->B : B ->B : B ->c : (c: C) => C ->c : C ->C : C ->C : C - -someGenerics7(n => n, n => n, n => n); ->someGenerics7(n => n, n => n, n => n) : void ->someGenerics7 : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->n => n : (n: {}) => {} ->n : {} ->n : {} ->n => n : (n: {}) => {} ->n : {} ->n : {} ->n => n : (n: {}) => {} ->n : {} ->n : {} - -someGenerics7(n => n, n => n, n => n); ->someGenerics7(n => n, n => n, n => n) : void ->someGenerics7 : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->n => n : (n: number) => number ->n : number ->n : number ->n => n : (n: string) => string ->n : string ->n : string ->n => n : (n: number) => number ->n : number ->n : number - -someGenerics7((n: number) => n, (n: string) => n, (n: number) => n); ->someGenerics7((n: number) => n, (n: string) => n, (n: number) => n) : void ->someGenerics7 : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->(n: number) => n : (n: number) => number ->n : number ->n : number ->(n: string) => n : (n: string) => string ->n : string ->n : string ->(n: number) => n : (n: number) => number ->n : number ->n : number - -// Generic call with argument of generic function type -function someGenerics8(n: T): T { return n; } ->someGenerics8 : (n: T) => T ->T : T ->n : T ->T : T ->T : T ->n : T - -var x = someGenerics8(someGenerics7); ->x : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->someGenerics8(someGenerics7) : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->someGenerics8 : (n: T) => T ->someGenerics7 : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void - -x(null, null, null); ->x(null, null, null) : void ->x : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void - -// Generic call with multiple parameters of generic type passed arguments with no best common type -function someGenerics9(a: T, b: T, c: T): T { ->someGenerics9 : (a: T, b: T, c: T) => T ->T : T ->a : T ->T : T ->b : T ->T : T ->c : T ->T : T ->T : T - - return null; -} -var a9a = someGenerics9('', 0, []); ->a9a : {} ->someGenerics9('', 0, []) : {} ->someGenerics9 : (a: T, b: T, c: T) => T ->[] : undefined[] - -var a9a: {}; ->a9a : {} - -var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); ->a9b : { a?: number; b?: string; } ->someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null) : { a?: number; b?: string; } ->someGenerics9 : (a: T, b: T, c: T) => T ->a : number ->b : string ->{ a: 0 } : { a: number; } ->a : number ->{ b: '' } : { b: string; } ->b : string - -var a9b: { a?: number; b?: string; }; ->a9b : { a?: number; b?: string; } ->a : number ->b : string - -// Generic call with multiple parameters of generic type passed arguments with multiple best common types -interface A91 { ->A91 : A91 - - x: number; ->x : number - - y?: string; ->y : string -} -interface A92 { ->A92 : A92 - - x: number; ->x : number - - z?: Date; ->z : Date ->Date : Date -} -var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); ->a9e : {} ->someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }) : {} ->someGenerics9 : (a: T, b: T, c: T) => T ->undefined : undefined ->{ x: 6, z: new Date() } : { x: number; z: Date; } ->x : number ->z : Date ->new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } ->{ x: 6, y: '' } : { x: number; y: string; } ->x : number ->y : string - -var a9e: {}; ->a9e : {} - -var a9f = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); ->a9f : A92 ->someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }) : A92 ->someGenerics9 : (a: T, b: T, c: T) => T ->A92 : A92 ->undefined : undefined ->{ x: 6, z: new Date() } : { x: number; z: Date; } ->x : number ->z : Date ->new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } ->{ x: 6, y: '' } : { x: number; y: string; } ->x : number ->y : string - -var a9f: A92; ->a9f : A92 ->A92 : A92 - -// Generic call with multiple parameters of generic type passed arguments with a single best common type -var a9d = someGenerics9({ x: 3 }, { x: 6 }, { x: 6 }); ->a9d : { x: number; } ->someGenerics9({ x: 3 }, { x: 6 }, { x: 6 }) : { x: number; } ->someGenerics9 : (a: T, b: T, c: T) => T ->{ x: 3 } : { x: number; } ->x : number ->{ x: 6 } : { x: number; } ->x : number ->{ x: 6 } : { x: number; } ->x : number - -var a9d: { x: number; }; ->a9d : { x: number; } ->x : number - -// Generic call with multiple parameters of generic type where one argument is of type 'any' -var anyVar: any; ->anyVar : any - -var a = someGenerics9(7, anyVar, 4); ->a : any ->someGenerics9(7, anyVar, 4) : any ->someGenerics9 : (a: T, b: T, c: T) => T ->anyVar : any - -var a: any; ->a : any - -// Generic call with multiple parameters of generic type where one argument is [] and the other is not 'any' -var arr = someGenerics9([], null, undefined); ->arr : any[] ->someGenerics9([], null, undefined) : any[] ->someGenerics9 : (a: T, b: T, c: T) => T ->[] : any[] ->undefined : undefined - -var arr: any[]; ->arr : any[] - - diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index a9de02d4226..4f11cb6135e 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -3,12 +3,14 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(61,39): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(71,39): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(81,45): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts (8 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts (10 errors) ==== // Generic call with no parameters interface NoParams { new (); @@ -125,6 +127,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct } var someGenerics9: someGenerics9; var a9a = new someGenerics9('', 0, []); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var a9a: {}; var a9b = new someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); var a9b: { a?: number; b?: string; }; @@ -141,6 +145,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct !!! error TS2304: Cannot find name 'Window'. } var a9e = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. ~~~~~~ !!! error TS2304: Cannot find name 'window'. var a9e: {}; diff --git a/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt index e6e59308dd4..08cb5348c27 100644 --- a/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt @@ -1,9 +1,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts(2,29): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts(2,42): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts(7,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'd' must be of type '{}[]', but here has type 'Date[]'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts (3 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts (2 errors) ==== function fn(a: A, b: B, c: C) { ~~~~~~~~~~~ @@ -15,6 +14,4 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiv var d = fn(new Date(), new Date(), new Date()); var d: Date[]; // Should be OK (d should be Date[]) - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'd' must be of type '{}[]', but here has type 'Date[]'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.errors.txt new file mode 100644 index 00000000000..c0ee4329c8d --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts (1 errors) ==== + interface Animal { x } + interface Giraffe extends Animal { y } + interface Elephant extends Animal { z } + function f(x: T, y: T): T { return undefined; } + var g: Giraffe; + var e: Elephant; + f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.types b/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.types deleted file mode 100644 index 35328f72803..00000000000 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.types +++ /dev/null @@ -1,40 +0,0 @@ -=== tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts === -interface Animal { x } ->Animal : Animal ->x : any - -interface Giraffe extends Animal { y } ->Giraffe : Giraffe ->Animal : Animal ->y : any - -interface Elephant extends Animal { z } ->Elephant : Elephant ->Animal : Animal ->z : any - -function f(x: T, y: T): T { return undefined; } ->f : (x: T, y: T) => T ->T : T ->Animal : Animal ->x : T ->T : T ->y : T ->T : T ->T : T ->undefined : undefined - -var g: Giraffe; ->g : Giraffe ->Giraffe : Giraffe - -var e: Elephant; ->e : Elephant ->Elephant : Elephant - -f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal ->f(g, e) : Animal ->f : (x: T, y: T) => T ->g : Giraffe ->e : Elephant - diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 8cf2a2d3503..c0dbf74f66e 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -8,12 +8,14 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(49,15): error TS2344: Type 'string' does not satisfy the constraint 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(55,41): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(66,31): error TS2345: Argument of type '(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,11): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts (13 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts (15 errors) ==== // Generic call with no parameters function noParams() { } noParams(); @@ -107,6 +109,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst return null; } var a9a = someGenerics9('', 0, []); + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var a9a: {}; var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); var a9b: { a?: number; b?: string; }; @@ -123,6 +127,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst !!! error TS2304: Cannot find name 'Window'. } var a9e = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. ~~~~~~ !!! error TS2304: Cannot find name 'window'. var a9e: {}; diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt new file mode 100644 index 00000000000..5f9f980e735 --- /dev/null +++ b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/typeInferenceConflictingCandidates.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/typeInferenceConflictingCandidates.ts (1 errors) ==== + declare function g(a: T, b: T, c: (t: T) => T): T; + + g("", 3, a => a); + ~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.types b/tests/baselines/reference/typeInferenceConflictingCandidates.types deleted file mode 100644 index 7a77daf4092..00000000000 --- a/tests/baselines/reference/typeInferenceConflictingCandidates.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/typeInferenceConflictingCandidates.ts === -declare function g(a: T, b: T, c: (t: T) => T): T; ->g : (a: T, b: T, c: (t: T) => T) => T ->T : T ->a : T ->T : T ->b : T ->T : T ->c : (t: T) => T ->t : T ->T : T ->T : T ->T : T - -g("", 3, a => a); ->g("", 3, a => a) : {} ->g : (a: T, b: T, c: (t: T) => T) => T ->a => a : (a: {}) => {} ->a : {} ->a : {} - diff --git a/tests/baselines/reference/typeParameterAsElementType.types b/tests/baselines/reference/typeParameterAsElementType.types index 0dbbbf5ac7a..828c7034a58 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 : {}[] ->[t, ""] : {}[] +>arr : Array +>[t, ""] : Array >t : T } diff --git a/tests/baselines/reference/undefinedInferentialTyping.types b/tests/baselines/reference/undefinedInferentialTyping.types index b5741e4d40f..61737ac6b6c 100644 --- a/tests/baselines/reference/undefinedInferentialTyping.types +++ b/tests/baselines/reference/undefinedInferentialTyping.types @@ -15,5 +15,5 @@ var a = f([], 3); // should be number >a : number >f([], 3) : number >f : (arr: T[], elemnt: T) => T ->[] : number[] +>[] : undefined[] diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 115bc09195d..5337a4971d1 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -104,7 +104,7 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []); >a : number[] >concat : { (...items: U[]): number[]; (...items: number[]): number[]; } >b : number[] ->[] : number[] +>[] : undefined[] var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >even : number @@ -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'] : {}[] +>[true, 1, null, 'yes'] : Array >_.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] : {}[] +>[null, 0, 'yes', false] : Array _.contains([1, 2, 3], 3); >_.contains([1, 2, 3], 3) : boolean @@ -200,7 +200,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); >_.invoke : { (list: any[], methodName: string, ...args: any[]): any[]; (list: Dictionary, methodName: string, ...args: any[]): any[]; } >_ : Underscore.Static >invoke : { (list: any[], methodName: string, ...args: any[]): any[]; (list: Dictionary, methodName: string, ...args: any[]): any[]; } ->[[5, 1, 7], [3, 2, 1]] : any[] +>[[5, 1, 7], [3, 2, 1]] : number[][] >[5, 1, 7] : number[] >[3, 2, 1] : number[] @@ -309,7 +309,7 @@ _.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd'); >[1, 2, 3, 4, 5] : number[] >(num) => num % 2 == 0 ? 'even' : 'odd' : (num: number) => string >num : number ->num % 2 == 0 ? 'even' : 'odd' : any +>num % 2 == 0 ? 'even' : 'odd' : string >num % 2 == 0 : boolean >num % 2 : number >num : number @@ -364,25 +364,25 @@ _.rest([5, 4, 3, 2, 1]); >[5, 4, 3, 2, 1] : number[] _.compact([0, 1, false, 2, '', 3]); ->_.compact([0, 1, false, 2, '', 3]) : {}[] +>_.compact([0, 1, false, 2, '', 3]) : Array >_.compact : (list: T[]) => T[] >_ : Underscore.Static >compact : (list: T[]) => T[] ->[0, 1, false, 2, '', 3] : {}[] +>[0, 1, false, 2, '', 3] : Array _.flatten([1, 2, 3, 4]); >_.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] : any[] +>[1, 2, 3, 4] : number[] _.flatten([1, [2]]); >_.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]] : any[] +>[1, [2]] : Array >[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]]]] : any[] +>[1, [2], [3, [[4]]]] : Array> >[2] : number[] ->[3, [[4]]] : {}[] +>[3, [[4]]] : Array >[[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]]]] : any[] +>[1, [2], [3, [[4]]]] : Array> >[2] : number[] ->[3, [[4]]] : {}[] +>[3, [[4]]] : Array >[[4]] : number[][] >[4] : number[] @@ -463,17 +463,17 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); >_ : Underscore.Static >object : { (list: any[][]): any; (keys: string[], values: any[]): any; } >['moe', 'larry', 'curly'] : string[] ->[30, 40, 50] : any[] +>[30, 40, 50] : number[] _.object([['moe', 30], ['larry', 40], ['curly', 50]]); >_.object([['moe', 30], ['larry', 40], ['curly', 50]]) : any >_.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]] : any[][] ->['moe', 30] : any[] ->['larry', 40] : any[] ->['curly', 50] : any[] +>[['moe', 30], ['larry', 40], ['curly', 50]] : Array[] +>['moe', 30] : Array +>['larry', 40] : Array +>['curly', 50] : Array _.indexOf([1, 2, 3], 2); >_.indexOf([1, 2, 3], 2) : number diff --git a/tests/baselines/reference/validMultipleVariableDeclarations.types b/tests/baselines/reference/validMultipleVariableDeclarations.types index 89d3702a702..4bbd46bab2b 100644 --- a/tests/baselines/reference/validMultipleVariableDeclarations.types +++ b/tests/baselines/reference/validMultipleVariableDeclarations.types @@ -117,11 +117,11 @@ var a = ['a', 'b'] var a = []; >a : string[] >[] : string[] ->[] : string[] +>[] : undefined[] var a: string[] = []; >a : string[] ->[] : string[] +>[] : undefined[] var a = new Array(); >a : string[] diff --git a/tests/cases/compiler/arrayBestCommonTypes.ts b/tests/cases/compiler/arrayBestCommonTypes.ts index ee09c4d07f6..c7466b5181e 100644 --- a/tests/cases/compiler/arrayBestCommonTypes.ts +++ b/tests/cases/compiler/arrayBestCommonTypes.ts @@ -1,52 +1,106 @@ -interface iface { } -class base implements iface { } -class base2 implements iface { } -class derived extends base { } +module EmptyTypes { + interface iface { } + class base implements iface { } + class base2 implements iface { } + class derived extends base { } -class f { - public voidIfAny(x: boolean, y?: boolean): number; - public voidIfAny(x: string, y?: boolean): number; - public voidIfAny(x: number, y?: boolean): number; - public voidIfAny(x: any, y =false): any { return null; } - - public x() { - (this.voidIfAny([4, 2][0])); - (this.voidIfAny([4, 2, undefined][0])); - (this.voidIfAny([undefined, 2, 4][0])); - (this.voidIfAny([null, 2, 4][0])); - (this.voidIfAny([2, 4, null][0])); - (this.voidIfAny([undefined, 4, null][0])); + class f { + public voidIfAny(x: boolean, y?: boolean): number; + public voidIfAny(x: string, y?: boolean): number; + public voidIfAny(x: number, y?: boolean): number; + public voidIfAny(x: any, y = false): any { return null; } - (this.voidIfAny(['', "q"][0])); - (this.voidIfAny(['', "q", undefined][0])); - (this.voidIfAny([undefined, "q", ''][0])); - (this.voidIfAny([null, "q", ''][0])); - (this.voidIfAny(["q", '', null][0])); - (this.voidIfAny([undefined, '', null][0])); + public x() { + (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); - (this.voidIfAny([[3,4],[null]][0][0])); - - - var t1: { x: number; y: base; }[] = [ { x: 7, y: new derived() }, { x: 5, y: new base() } ]; - var t2: { x: boolean; y: base; }[] = [ { x: true, y: new derived() }, { x: false, y: new base() } ]; - var t3: { x: string; y: base; }[] = [ { x: undefined, y: new base() }, { x: '', y: new derived() } ]; + (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny([undefined, '', null][0])); - var anyObj: any = null; - // Order matters here so test all the variants - var a1 = [ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ]; - var a2 = [ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ]; - var a3 = [ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ]; - - var ifaceObj: iface = null; - var baseObj = new base(); - var base2Obj = new base2(); + (this.voidIfAny([[3, 4], [null]][0][0])); - var b1 = [ baseObj, base2Obj, ifaceObj ]; - var b2 = [ base2Obj, baseObj, ifaceObj ]; - var b3 = [ baseObj, ifaceObj, base2Obj ]; - var b4 = [ ifaceObj, baseObj, base2Obj ]; + + var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; + var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }]; + var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + + var anyObj: any = null; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + + var ifaceObj: iface = null; + var baseObj = new base(); + var base2Obj = new base2(); + + var b1 = [baseObj, base2Obj, ifaceObj]; + var b2 = [base2Obj, baseObj, ifaceObj]; + var b3 = [baseObj, ifaceObj, base2Obj]; + var b4 = [ifaceObj, baseObj, base2Obj]; + } } } +module NonEmptyTypes { + interface iface { x: string; } + class base implements iface { x: string; y: string; } + class base2 implements iface { x: string; z: string; } + class derived extends base { a: string; } + + + class f { + public voidIfAny(x: boolean, y?: boolean): number; + public voidIfAny(x: string, y?: boolean): number; + public voidIfAny(x: number, y?: boolean): number; + public voidIfAny(x: any, y = false): any { return null; } + + public x() { + (this.voidIfAny([4, 2][0])); + (this.voidIfAny([4, 2, undefined][0])); + (this.voidIfAny([undefined, 2, 4][0])); + (this.voidIfAny([null, 2, 4][0])); + (this.voidIfAny([2, 4, null][0])); + (this.voidIfAny([undefined, 4, null][0])); + + (this.voidIfAny(['', "q"][0])); + (this.voidIfAny(['', "q", undefined][0])); + (this.voidIfAny([undefined, "q", ''][0])); + (this.voidIfAny([null, "q", ''][0])); + (this.voidIfAny(["q", '', null][0])); + (this.voidIfAny([undefined, '', null][0])); + + (this.voidIfAny([[3, 4], [null]][0][0])); + + + var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; + var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }]; + var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + + var anyObj: any = null; + // Order matters here so test all the variants + var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; + var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; + var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + + var ifaceObj: iface = null; + var baseObj = new base(); + var base2Obj = new base2(); + + var b1 = [baseObj, base2Obj, ifaceObj]; + var b2 = [base2Obj, baseObj, ifaceObj]; + var b3 = [baseObj, ifaceObj, base2Obj]; + var b4 = [ifaceObj, baseObj, base2Obj]; + } + } +} diff --git a/tests/cases/compiler/arrayLiteralContextualType.ts b/tests/cases/compiler/arrayLiteralContextualType.ts index 1518d2e4ac0..be05929e8e7 100644 --- a/tests/cases/compiler/arrayLiteralContextualType.ts +++ b/tests/cases/compiler/arrayLiteralContextualType.ts @@ -25,5 +25,5 @@ bar([ ]); // Legal because of the contextual type IAnimal provided by the parameter var arr = [new Giraffe(), new Elephant()]; -foo(arr); // Error because of no contextual type -bar(arr); // Error because of no contextual type \ No newline at end of file +foo(arr); // ok because arr is Array not {}[] +bar(arr); // ok because arr is Array not {}[] \ No newline at end of file diff --git a/tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts b/tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts index bd1f22f44dc..1ea001057a9 100644 --- a/tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts +++ b/tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts @@ -1,3 +1,3 @@ var f10: (x: T, b: () => (a: T) => void, y: T) => T; -f10('', () => a => a.foo, ''); // a is string, fixed by first parameter -var r9 = f10('', () => (a => a.foo), 1); // now a should be any \ No newline at end of file +f10('', () => a => a.foo, ''); // a is string +var r9 = f10('', () => (a => a.foo), 1); // error \ No newline at end of file diff --git a/tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts b/tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts index b9fecdc6ffc..254197bf309 100644 --- a/tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts +++ b/tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts @@ -1,18 +1,14 @@ - var obj1: {}; - obj1.length; - - var obj2: Object; - obj2.length; - - function concat(x: T, y: T): T { return null; } +var result = concat(1, ""); // error +var elementCount = result.length; -var result = concat(1, ""); +function concat2(x: T, y: U) { return null; } +var result2 = concat2(1, ""); // result2 will be number|string +var elementCount2 = result.length; -var elementCount = result.length; // would like to get an error by now diff --git a/tests/cases/compiler/nonContextuallyTypedLogicalOr.ts b/tests/cases/compiler/nonContextuallyTypedLogicalOr.ts index f77ad5105ab..cadd60ea398 100644 --- a/tests/cases/compiler/nonContextuallyTypedLogicalOr.ts +++ b/tests/cases/compiler/nonContextuallyTypedLogicalOr.ts @@ -11,6 +11,4 @@ interface Ellement { var c: Contextual; var e: Ellement; -// This should error. Even though we are contextually typing e with Contextual, the RHS still -// needs to be a supertype of the LHS to win as the best common type. (c || e).dummy; \ No newline at end of file diff --git a/tests/cases/compiler/promisePermutations.ts b/tests/cases/compiler/promisePermutations.ts index c5091aaa630..0ce62be8181 100644 --- a/tests/cases/compiler/promisePermutations.ts +++ b/tests/cases/compiler/promisePermutations.ts @@ -11,7 +11,7 @@ interface IPromise { then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -71,7 +71,7 @@ var s3: Promise; var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); var s3c = s3.then(testFunction3P, testFunction3, testFunction3); -var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); +var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -82,7 +82,7 @@ var s4: Promise; var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error -var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); +var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -134,7 +134,7 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); @@ -149,15 +149,15 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; -var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok +var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok -var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok -var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok +var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error +var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/cases/compiler/promisePermutations2.ts b/tests/cases/compiler/promisePermutations2.ts index 66f9806de00..05a60860929 100644 --- a/tests/cases/compiler/promisePermutations2.ts +++ b/tests/cases/compiler/promisePermutations2.ts @@ -10,7 +10,7 @@ interface IPromise { then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -81,7 +81,7 @@ var s4: Promise; var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error -var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); +var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -125,7 +125,7 @@ var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok -var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok +var r9d = r9.then(testFunction, sIPromise, nIPromise); // error var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -133,14 +133,14 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok -var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok +var r10d = r10.then(testFunction, sIPromise, nIPromise); // error var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -148,11 +148,11 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; -var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok +var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok diff --git a/tests/cases/compiler/promisePermutations3.ts b/tests/cases/compiler/promisePermutations3.ts index 78d6b17c9ec..3aab00b0ed0 100644 --- a/tests/cases/compiler/promisePermutations3.ts +++ b/tests/cases/compiler/promisePermutations3.ts @@ -10,7 +10,7 @@ interface Promise { interface IPromise { then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + done? (success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; } declare function testFunction(): IPromise; @@ -81,7 +81,7 @@ var s4: Promise; var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error -var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); +var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4); var r5: IPromise; var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error @@ -125,7 +125,7 @@ var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok -var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok +var r9d = r9.then(testFunction, sIPromise, nIPromise); // error var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error @@ -133,14 +133,14 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error var s9d = s9.then(sPromise, sPromise, sPromise); // ok var s9e = s9.then(nPromise, nPromise, nPromise); // ok -var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok +var s9f = s9.then(testFunction, sIPromise, nIPromise); // error var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok -var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok +var r10d = r10.then(testFunction, sIPromise, nIPromise); // error var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -148,15 +148,15 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok var s10d = s10.then(sPromise, sPromise, sPromise); // ok var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok -var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok +var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok -var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok -var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok +var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error +var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/cases/compiler/tupleTypes.ts b/tests/cases/compiler/tupleTypes.ts index 3b22c284cb1..80181f8b332 100644 --- a/tests/cases/compiler/tupleTypes.ts +++ b/tests/cases/compiler/tupleTypes.ts @@ -8,8 +8,8 @@ var t0 = t[0]; // number var t0: number; var t1 = t[1]; // string var t1: string; -var t2 = t[2]; // {} -var t2: {}; +var t2 = t[2]; // number|string +var t2: number|string; t = []; // Error t = [1]; // Error @@ -32,8 +32,8 @@ var tt0 = tt[0]; var tt0: number; var tt1 = tt[1]; var tt1: string; -var tt2 = tt[2]; -var tt2: {}; +var tt2 = tt[2]; +var tt2: number | string; tt = tuple2(1, undefined); tt = [1, undefined]; diff --git a/tests/cases/compiler/typeArgInference2.ts b/tests/cases/compiler/typeArgInference2.ts index 523d1eab506..5bf8599996e 100644 --- a/tests/cases/compiler/typeArgInference2.ts +++ b/tests/cases/compiler/typeArgInference2.ts @@ -1,12 +1,12 @@ -interface Item { - name: string; -} - -declare function foo(x?: T, y?: T): T; - -var z1 = foo(null); // any -var z2 = foo(); // Item -var z3 = foo({ name: null }); // { name: any } -var z4 = foo({ name: "abc" }); // { name: string } -var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } -var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item \ No newline at end of file +interface Item { + name: string; +} + +declare function foo(x?: T, y?: T): T; + +var z1 = foo(null); // any +var z2 = foo(); // Item +var z3 = foo({ name: null }); // { name: any } +var z4 = foo({ name: "abc" }); // { name: string } +var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } +var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error \ No newline at end of file diff --git a/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts index b4b85573755..41c5a0b8100 100644 --- a/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts +++ b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts @@ -1,28 +1,21 @@ // Empty array literal with no contextual type has type Undefined[] var arr1= [[], [1], ['']]; -var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK var arr2 = [[null], [1], ['']]; -var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK // Array literal with elements of only EveryType E has type E[] var stringArrArr = [[''], [""]]; -var stringArrArr: string[][]; var stringArr = ['', ""]; -var stringArr: string[]; var numberArr = [0, 0.0, 0x00, 1e1]; -var numberArr: number[]; var boolArr = [false, true, false, true]; -var boolArr: boolean[]; class C { private p; } var classArr = [new C(), new C()]; -var classArr: C[]; // Should be OK var classTypeArray = [C, C, C]; var classTypeArray: Array; // Should OK, not be a parse error @@ -30,7 +23,6 @@ var classTypeArray: Array; // Should OK, not be a parse error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; -var context2: Array<{}>; // Should be OK // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] class Base { private p; } diff --git a/tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts b/tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts index 34ef4b3ca8c..feaa3c5a280 100644 --- a/tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts +++ b/tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts @@ -1,21 +1,20 @@ -//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type -class X { propertyX: any; propertyX1: number; propertyX2: string }; -class A extends X { propertyA: number }; -class B extends X { propertyB: string }; - -var x: X; -var a: A; -var b: B; - -//Expect to have compiler errors -//Be not contextually typed -true ? a : b; -var result1 = true ? a : b; - -//Be contextually typed and and bct is not identical -var result2: A = true ? a : b; -var result3: B = true ? a : b; - -var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2; -var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2; +//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type +class X { propertyX: any; propertyX1: number; propertyX2: string }; +class A extends X { propertyA: number }; +class B extends X { propertyB: string }; + +var x: X; +var a: A; +var b: B; + +// No errors anymore, uses union types +true ? a : b; +var result1 = true ? a : b; + +//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target +var result2: A = true ? a : b; +var result3: B = true ? a : b; + +var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2; +var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2; var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2; \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts index 68ac4cff026..9edf4f5f417 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts @@ -15,8 +15,8 @@ function f2(x: T, y: U, z: V) { var r2 = true ? y : z; // ok - var r2 = true ? z : x; - var r2 = true ? x : z; + var r2a = true ? z : x; + var r2b = true ? x : z; } // Date > U > T @@ -57,18 +57,18 @@ function f4(x: T) { } function f5(x: T) { - var r1 = true ? 1 : x; // error - var r1 = true ? x : 1; // error + var r1 = true ? 1 : x; // ok + var r1 = true ? x : 1; // ok } function f6(x: T) { - var r2 = true ? '' : x; // error - var r2 = true ? x : ''; // error + var r2 = true ? '' : x; // ok + var r2 = true ? x : ''; // ok } function f7(x: T) { - var r3 = true ? true : x; // error - var r3 = true ? x : true; // error + var r3 = true ? true : x; // ok + var r3 = true ? x : true; // ok } function f8(x: T) { @@ -115,11 +115,11 @@ function f15>(x: T) { } function f16(x: T) { - var r13 = true ? E : x; // BUG 831833 - var r13 = true ? x : E; // BUG 831833 + var r13 = true ? E : x; // ok + var r13 = true ? x : E; // ok - var r14 = true ? E.A : x; // BUG 831833 - var r14 = true ? x : E.A; // BUG 831833 + var r14 = true ? E.A : x; // ok + var r14 = true ? x : E.A; // ok } function f17(x: T) { diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts index 10021cdcc06..96218dce43e 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts @@ -5,11 +5,11 @@ function f(t: T, u: U, v: V) { var r = true ? t : u; var r = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts index a4e691edbb4..0dc53908ea3 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts @@ -2,15 +2,15 @@ class Foo { foo: number; } function f(t: T, u: U, v: V) { - // error + // ok var r = true ? t : u; var r = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; @@ -22,7 +22,7 @@ function f(t: T, u: U, v: V) { var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // BUG, should be error + // ok var r6 = true ? v : new Foo(); var r6 = true ? new Foo() : v; diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts index dc3f2917ec1..f63b63432e5 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts @@ -2,53 +2,53 @@ class Foo { foo: T; } function f, U extends Foo, V extends Foo>(t: T, u: U, v: V) { - // error + // ok var r1 = true ? t : u; var r1 = true ? u : t; - // error + // ok var r2 = true ? t : v; var r2 = true ? v : t; - // error + // ok var r3 = true ? v : u; var r3 = true ? u : v; - // ok? + // ok var r4 = true ? t : new Foo(); var r4 = true ? new Foo() : t; - // ok? + // ok var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; - // ok? + // ok var r6 = true ? v : new Foo(); var r6 = true ? new Foo() : v; - // ok? + // ok var r7 = true ? t : new Foo(); var r7 = true ? new Foo() : t; - // ok? + // ok var r8 = true ? u : new Foo(); var r8 = true ? new Foo() : u; - // ok? + // ok var r9 = true ? v : new Foo(); var r9 = true ? new Foo() : v; - // ok? + // ok var r10 = true ? t : new Foo(); var r10 = true ? new Foo() : t; - // ok? + // ok var r11 = true ? u : new Foo(); var r11 = true ? new Foo() : u; - // ok? + // ok var r12 = true ? v : new Foo(); var r12 = true ? new Foo() : v; } diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts index 601d85704eb..ac8f5642f70 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts @@ -30,4 +30,4 @@ interface S3 extends T3 { // object literal case var a: { Foo: Base; } var b: { Foo?: Derived; } -var r = true ? a : b; // error \ No newline at end of file +var r = true ? a : b; // ok \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts index 3f2e17c6b05..97359cde959 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts @@ -23,14 +23,14 @@ function foo3(x: T, cb: (a: T) => U, y: U) { var r7 = foo3(1, (a: Z) => '', ''); // string -var r8 = foo3(1, function (a) { return '' }, 1); // {} +var r8 = foo3(1, function (a) { return '' }, 1); // error var r9 = foo3(1, (a) => '', ''); // string function other(t: T, u: U) { - var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made + var r10 = foo2(1, (x: T) => ''); // error var r10 = foo2(1, (x) => ''); // string - var r11 = foo3(1, (x: T) => '', ''); // string - var r11b = foo3(1, (x: T) => '', 1); // {} - var r12 = foo3(1, function (a) { return '' }, 1); // {} + var r11 = foo3(1, (x: T) => '', ''); // error + var r11b = foo3(1, (x: T) => '', 1); // error + var r12 = foo3(1, function (a) { return '' }, 1); // error } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts index f313d638bfb..0d02afe9c88 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts @@ -26,7 +26,7 @@ function foo2(x: T, cb: new(a: T) => U) { return new cb(x); } -var r4 = foo2(1, i2); // string, instantiated generic +var r4 = foo2(1, i2); // error var r4b = foo2(1, a); // any var r5 = foo2(1, i); // any var r6 = foo2('', i2); // string @@ -37,5 +37,5 @@ function foo3(x: T, cb: new(a: T) => U, y: U) { var r7 = foo3(null, i, ''); // any var r7b = foo3(null, a, ''); // any -var r8 = foo3(1, i2, 1); // {} +var r8 = foo3(1, i2, 1); // error var r9 = foo3('', i2, ''); // string \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts index 54a7cf7ebc6..c37b2e31333 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts @@ -1,36 +1,73 @@ // 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; +module onlyT { + function foo(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); + + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); // T => T + // BUG 835518 + var r9 = r7(new Date()); // should be ok + var r10 = r7(1); // error + } + + function foo2(a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + function other3(x: T) { + var r7 = foo2((a: T) => a, (b: T) => b); // error + var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date + } + + enum E { A } + enum F { A } + + function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { + var r: (x: T) => T; + return r; + } + + var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error } -var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); +module TU { + function foo(a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } -function other2(x: T) { - var r7 = foo((a: T) => a, (b: T) => b); // T => T - // BUG 835518 - var r9 = r7(new Date()); // should be ok - var r10 = r7(1); // error -} + var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => ''); -function foo2(a: (x: T) => T, b: (x: T) => T) { - var r: (x: T) => T; - return r; -} + function other2(x: T) { + var r7 = foo((a: T) => a, (b: T) => b); + var r9 = r7(new Date()); + var r10 = r7(1); + } -function other3(x: T) { - var r7 = foo2((a: T) => a, (b: T) => b); // error - var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date -} + function foo2(a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } -enum E { A } -enum F { A } + function other3(x: T) { + var r7 = foo2((a: T) => a, (b: T) => b); + var r7b = foo2((a) => a, (b) => b); + } -function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { - var r: (x: T) => T; - return r; -} + enum E { A } + enum F { A } -var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error \ No newline at end of file + function foo3(x: T, a: (x: T) => T, b: (x: U) => U) { + var r: (x: T) => T; + return r; + } + + var r7 = foo3(E.A, (x) => E.A, (x) => F.A); +} \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts index 65f22a3fd3f..82b917efa3e 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts @@ -29,5 +29,5 @@ var r9 = foo2(null, (x) => '', (x) => ''); // any => any var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object var x: (a: string) => boolean; -var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {} -var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {} \ No newline at end of file +var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error +var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts index 1e5976b33e5..75b0462b689 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts @@ -2,7 +2,7 @@ function foo(x: { bar: T; baz: T }) { return x; } -var r = foo({ bar: 1, baz: '' }); // T = {} +var r = foo({ bar: 1, baz: '' }); // error var r2 = foo({ bar: 1, baz: 1 }); // T = number var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo var r4 = foo({ bar: 1, baz: '' }); // T = Object \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts index 8bb5d234bb5..527286e6ee2 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts @@ -33,7 +33,7 @@ module GenericParameter { return cb; } - var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string + var r8 = foo6(a); // error var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string function foo7(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) { diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts index a3b02eaf4e4..f429cd5169d 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts @@ -54,11 +54,11 @@ module WithCandidates { var c3: C3; function other(t: T, u: U) { - var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made + var r10 = c.foo2(1, (x: T) => ''); // error var r10 = c.foo2(1, (x) => ''); // string - var r11 = c3.foo3(1, (x: T) => '', ''); // string - var r11b = c3.foo3(1, (x: T) => '', 1); // {} - var r12 = c3.foo3(1, function (a) { return '' }, 1); // {} + var r11 = c3.foo3(1, (x: T) => '', ''); // error + var r11b = c3.foo3(1, (x: T) => '', 1); // error + var r12 = c3.foo3(1, function (a) { return '' }, 1); // error } } \ No newline at end of file diff --git a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts index 1632fff5df8..917ed526d69 100644 --- a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts +++ b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts @@ -28,10 +28,19 @@ goTo.marker('2'); verify.quickInfoIs('(var) c1: {\n name: string;\n age: number;\n}[]'); goTo.marker('3'); -verify.quickInfoIs('(var) c2: {}[]'); +verify.quickInfoIs('(var) c2: Array<{\n\ + name: string;\n\ + age: number;\n\ + address: string;\n\ +} | {\n\ + name: string;\n\ + age: number;\n\ + dob: Date;\n\ +}>'); goTo.marker('4'); verify.quickInfoIs('(var) c2a: {\n name: string;\n age: number;\n}[]'); goTo.marker('5'); -verify.quickInfoIs('(var) c3: I[]'); \ No newline at end of file +verify.quickInfoIs('(var) c3: I[]'); + diff --git a/tests/cases/fourslash/commentsExternalModules.ts b/tests/cases/fourslash/commentsExternalModules.ts index 0eed08ca01e..c0e27149202 100644 --- a/tests/cases/fourslash/commentsExternalModules.ts +++ b/tests/cases/fourslash/commentsExternalModules.ts @@ -69,10 +69,10 @@ verify.memberListContains("i", "(var) m1.m2.i: m1.m2.c", "i"); goTo.file("commentsExternalModules_file1.ts"); goTo.marker('9'); -verify.quickInfoIs('(alias) extMod', "This is on import declaration"); +verify.quickInfoIs('import extMod = require("commentsExternalModules_file0")', "This is on import declaration"); goTo.marker('10'); -verify.completionListContains("extMod", "(alias) extMod", "This is on import declaration"); +verify.completionListContains("extMod", 'import extMod = require("commentsExternalModules_file0")', "This is on import declaration"); goTo.marker('11'); verify.memberListContains("m1", "module extMod.m1"); diff --git a/tests/cases/fourslash/commentsImportDeclaration.ts b/tests/cases/fourslash/commentsImportDeclaration.ts index 192cb2763ca..f115f3607b7 100644 --- a/tests/cases/fourslash/commentsImportDeclaration.ts +++ b/tests/cases/fourslash/commentsImportDeclaration.ts @@ -28,7 +28,7 @@ goTo.marker('2'); verify.quickInfoIs("module m1", "ModuleComment"); goTo.marker('3'); -verify.quickInfoIs("(alias) extMod", "Import declaration"); +verify.quickInfoIs('import extMod = require("commentsImportDeclaration_file0")', "Import declaration"); goTo.marker('6'); verify.memberListContains("m1", "module extMod.m1"); diff --git a/tests/cases/fourslash/completionEntryForUnionProperty.ts b/tests/cases/fourslash/completionEntryForUnionProperty.ts new file mode 100644 index 00000000000..bc0f9405a1b --- /dev/null +++ b/tests/cases/fourslash/completionEntryForUnionProperty.ts @@ -0,0 +1,20 @@ +/// + +////interface One { +//// commonProperty: number; +//// commonFunction(): number; +////} +//// +////interface Two { +//// commonProperty: string +//// commonFunction(): number; +////} +//// +////var x : One | Two; +//// +////x./**/ + +goTo.marker(); +verify.memberListContains("commonProperty", "(property) commonProperty: string | number"); +verify.memberListContains("commonFunction", "(method) commonFunction(): number"); +verify.memberListCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionEntryForUnionProperty2.ts b/tests/cases/fourslash/completionEntryForUnionProperty2.ts new file mode 100644 index 00000000000..b32e6d05345 --- /dev/null +++ b/tests/cases/fourslash/completionEntryForUnionProperty2.ts @@ -0,0 +1,19 @@ +/// + +////interface One { +//// commonProperty: number; +//// commonFunction(): number; +////} +//// +////interface Two { +//// commonProperty: string +//// commonFunction(): number; +////} +//// +////var x : One | Two; +//// +////x.commonProperty./**/ + +goTo.marker(); +verify.memberListContains("toString", "(method) toString(): string"); +verify.memberListCount(1); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListOnAliases.ts b/tests/cases/fourslash/completionListOnAliases.ts index 68c25d3608e..3d9026c3036 100644 --- a/tests/cases/fourslash/completionListOnAliases.ts +++ b/tests/cases/fourslash/completionListOnAliases.ts @@ -9,7 +9,7 @@ ////} goTo.marker("1"); -verify.memberListContains("x", "(alias) x", undefined); +verify.memberListContains("x", "import x = M", undefined); goTo.marker("2"); verify.memberListContains("value"); diff --git a/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts b/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts index 9e59d21c53b..128f801300b 100644 --- a/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts +++ b/tests/cases/fourslash/contextualTypingOfArrayLiterals1.ts @@ -43,7 +43,7 @@ goTo.marker('4'); verify.quickInfoIs('(var) r4: C'); goTo.marker('5'); -verify.quickInfoIs('(var) x5: {\n name: string;\n age: number;\n}[]'); +verify.quickInfoIs('(var) x5: C[]'); goTo.marker('6'); -verify.quickInfoIs('(var) r5: {\n name: string;\n age: number;\n}'); \ No newline at end of file +verify.quickInfoIs('(var) r5: C'); \ No newline at end of file diff --git a/tests/cases/fourslash/exportEqualTypes.ts b/tests/cases/fourslash/exportEqualTypes.ts index 47a266f7f39..8cfe931d87b 100644 --- a/tests/cases/fourslash/exportEqualTypes.ts +++ b/tests/cases/fourslash/exportEqualTypes.ts @@ -15,7 +15,7 @@ ////var /*3*/r2 = t./*4*/foo; // t should have 'foo' in dropdown list and be of type 'string' goTo.marker('1'); -verify.quickInfoIs('(alias) test'); +verify.quickInfoIs("import test = require('exportEqualTypes_file0')"); goTo.marker('2'); verify.quickInfoIs('(var) r1: Date'); goTo.marker('3'); diff --git a/tests/cases/fourslash/externalModuleWithExportAssignment.ts b/tests/cases/fourslash/externalModuleWithExportAssignment.ts index 952640f2c6c..1de1e55579b 100644 --- a/tests/cases/fourslash/externalModuleWithExportAssignment.ts +++ b/tests/cases/fourslash/externalModuleWithExportAssignment.ts @@ -30,7 +30,7 @@ goTo.file("externalModuleWithExportAssignment_file1.ts"); goTo.marker('1'); -verify.quickInfoIs("(alias) a1"); +verify.quickInfoIs('import a1 = require("externalModuleWithExportAssignment_file0")'); goTo.marker('2'); verify.quickInfoIs("(var) a: {\n (): a1.connectExport;\n test1: a1.connectModule;\n test2(): a1.connectModule;\n}", undefined); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 7be7dd63c92..d184be57712 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -80,6 +80,10 @@ module FourSlashInterface { return FourSlash.currentTestState.getMarkers(); } + public marker(name?: string): Marker { + return FourSlash.currentTestState.getMarkerByName(name); + } + public ranges(): Range[] { return FourSlash.currentTestState.getRanges(); } @@ -401,11 +405,17 @@ module FourSlashInterface { FourSlash.currentTestState.verifyCompletionEntryDetails(entryName, text, documentation, kind); } + /** + * This method *requires* a contiguous, complete, and ordered stream of classifications for a file. + */ public syntacticClassificationsAre(...classifications: { classificationType: string; text: string }[]) { FourSlash.currentTestState.verifySyntacticClassifications(classifications); } - public semanticClassificationsAre(...classifications: { classificationType: string; text: string }[]) { + /** + * This method *requires* an ordered stream of classifications for a file, and spans are highly recommended. + */ + public semanticClassificationsAre(...classifications: { classificationType: string; text: string; textSpan?: TextSpan }[]) { FourSlash.currentTestState.verifySemanticClassifications(classifications); } @@ -563,61 +573,69 @@ module FourSlashInterface { } } - export class classification { - public static comment(text: string): { classificationType: string; text: string } { - return { classificationType: "comment", text: text }; + export module classification { + export function comment(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("comment", text, position); } - public static identifier(text: string): { classificationType: string; text: string } { - return { classificationType: "identifier", text: text }; + export function identifier(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("identifier", text, position); } - public static keyword(text: string): { classificationType: string; text: string } { - return { classificationType: "keyword", text: text }; + export function keyword(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("keyword", text, position); } - public static numericLiteral(text: string): { classificationType: string; text: string } { - return { classificationType: "numericLiteral", text: text }; + export function numericLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("numericLiteral", text, position); } - public static operator(text: string): { classificationType: string; text: string } { - return { classificationType: "operator", text: text }; + export function operator(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("operator", text, position); } - public static stringLiteral(text: string): { classificationType: string; text: string } { - return { classificationType: "stringLiteral", text: text }; + export function stringLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("stringLiteral", text, position); } - public static whiteSpace(text: string): { classificationType: string; text: string } { - return { classificationType: "whiteSpace", text: text }; + export function whiteSpace(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("whiteSpace", text, position); } - public static text(text: string): { classificationType: string; text: string } { - return { classificationType: "text", text: text }; + export function text(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("text", text, position); } - public static punctuation(text: string): { classificationType: string; text: string } { - return { classificationType: "punctuation", text: text }; + export function punctuation(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("punctuation", text, position); } - public static className(text: string): { classificationType: string; text: string } { - return { classificationType: "className", text: text }; + export function className(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("className", text, position); } - public static enumName(text: string): { classificationType: string; text: string } { - return { classificationType: "enumName", text: text }; + export function enumName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("enumName", text, position); } - public static interfaceName(text: string): { classificationType: string; text: string } { - return { classificationType: "interfaceName", text: text }; + export function interfaceName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("interfaceName", text, position); } - public static moduleName(text: string): { classificationType: string; text: string } { - return { classificationType: "moduleName", text: text }; + export function moduleName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("moduleName", text, position); } - public static typeParameterName(text: string): { classificationType: string; text: string } { - return { classificationType: "typeParameterName", text: text }; + export function typeParameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("typeParameterName", text, position); + } + + function getClassification(type: string, text: string, position?: number) { + return { + classificationType: type, + text: text, + textSpan: position === undefined ? undefined : { start: position, end: position + text.length } + }; } } } @@ -635,6 +653,7 @@ module fs { function verifyOperationIsCancelled(f) { FourSlash.verifyOperationIsCancelled(f); } + var test = new FourSlashInterface.test_(); var goTo = new FourSlashInterface.goTo(); var verify = new FourSlashInterface.verify(); diff --git a/tests/cases/fourslash/genericTypeArgumentInference1.ts b/tests/cases/fourslash/genericTypeArgumentInference1.ts index 96d603b939c..eadec7ad0ce 100644 --- a/tests/cases/fourslash/genericTypeArgumentInference1.ts +++ b/tests/cases/fourslash/genericTypeArgumentInference1.ts @@ -18,9 +18,9 @@ ////var /*4*/r4 = _./*41*/all([true], _.identity); goTo.marker('1'); -verify.quickInfoIs('(var) r: {}'); +verify.quickInfoIs('(var) r: string | number | boolean'); goTo.marker('11'); -verify.quickInfoIs('(method) Underscore.Static.all<{}>(list: {}[], iterator?: Underscore.Iterator<{}, boolean>, context?: any): {}'); +verify.quickInfoIs('(method) Underscore.Static.all(list: Array, iterator?: Underscore.Iterator, context?: any): string | number | boolean'); goTo.marker('2'); verify.quickInfoIs('(var) r2: boolean'); @@ -37,4 +37,4 @@ verify.quickInfoIs('(var) r4: any'); goTo.marker('41'); verify.quickInfoIs('(method) Underscore.Static.all(list: any[], iterator?: Underscore.Iterator, context?: any): any'); -verify.numberOfErrorsInCurrentFile(0); +verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash/genericTypeArgumentInference2.ts b/tests/cases/fourslash/genericTypeArgumentInference2.ts index 0ae5114b133..a660675c51e 100644 --- a/tests/cases/fourslash/genericTypeArgumentInference2.ts +++ b/tests/cases/fourslash/genericTypeArgumentInference2.ts @@ -18,9 +18,9 @@ ////var /*4*/r4 = _./*41*/all([true], _.identity); goTo.marker('1'); -verify.quickInfoIs('(var) r: {}'); +verify.quickInfoIs('(var) r: string | number | boolean'); goTo.marker('11'); -verify.quickInfoIs('(method) Underscore.Static.all<{}>(list: {}[], iterator?: Underscore.Iterator<{}, boolean>, context?: any): {}'); +verify.quickInfoIs('(method) Underscore.Static.all(list: Array, iterator?: Underscore.Iterator, context?: any): string | number | boolean'); goTo.marker('2'); verify.quickInfoIs('(var) r2: boolean'); diff --git a/tests/cases/fourslash/goToDefinitionUnionTypeProperty.ts b/tests/cases/fourslash/goToDefinitionUnionTypeProperty.ts new file mode 100644 index 00000000000..74b5e2aad8a --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionUnionTypeProperty.ts @@ -0,0 +1,24 @@ +/// + +////interface One { +//// /*propertyDefinition1*/commonProperty: number; +//// commonFunction(): number; +////} +//// +////interface Two { +//// /*propertyDefinition2*/commonProperty: string +//// commonFunction(): number; +////} +//// +////var x : One | Two; +//// +////x./*propertyReference*/commonProperty; +////x./*3*/commonFunction; + +goTo.marker("propertyReference"); +goTo.definition(0); +verify.caretAtMarker("propertyDefinition1"); + +goTo.marker("propertyReference"); +goTo.definition(1); +verify.caretAtMarker("propertyDefinition2"); diff --git a/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts b/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts new file mode 100644 index 00000000000..6536bb76e7d --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts @@ -0,0 +1,25 @@ +/// +////interface HasAOrB { +//// /*propertyDefinition1*/a: string; +//// b: string; +////} +//// +////interface One { +//// common: { /*propertyDefinition2*/a : number; }; +////} +//// +////interface Two { +//// common: HasAOrB; +////} +//// +////var x : One | Two; +//// +////x.common./*propertyReference*/a; + +goTo.marker("propertyReference"); +goTo.definition(0); +verify.caretAtMarker("propertyDefinition1"); + +goTo.marker("propertyReference"); +goTo.definition(1); +verify.caretAtMarker("propertyDefinition2"); diff --git a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts index be5376d5de5..3198b6e9243 100644 --- a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts +++ b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts @@ -19,7 +19,7 @@ edit.insert(''); goTo.marker('1'); -verify.quickInfoIs('(alias) Foo'); +verify.quickInfoIs("import Foo = require('mergedDeclarationsWithExportAssignment1_file0')"); goTo.marker('2'); verify.completionListContains('Foo'); diff --git a/tests/cases/fourslash/quickInfoOnArgumentsInsideFunction.ts b/tests/cases/fourslash/quickInfoOnArgumentsInsideFunction.ts new file mode 100644 index 00000000000..6f08b15da7b --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnArgumentsInsideFunction.ts @@ -0,0 +1,8 @@ +/// + +////function foo(x: string) { +//// return /*1*/arguments; +////} + +goTo.marker('1'); +verify.quickInfoIs('(local var) arguments: IArguments'); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoOnInternalAliases.ts b/tests/cases/fourslash/quickInfoOnInternalAliases.ts new file mode 100644 index 00000000000..b1c562df494 --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnInternalAliases.ts @@ -0,0 +1,59 @@ +/// + +/////** Module comment*/ +////export module m1 { +//// /** m2 comments*/ +//// export module m2 { +//// /** class comment;*/ +//// export class /*1*/c { +//// }; +//// } +//// export function foo() { +//// } +////} +/////**This is on import declaration*/ +////import /*2*/internalAlias = m1.m2./*3*/c; +////var /*4*/newVar = new /*5*/internalAlias(); +////var /*6*/anotherAliasVar = /*7*/internalAlias; +////import /*8*/internalFoo = m1./*9*/foo; +////var /*10*/callVar = /*11*/internalFoo(); +////var /*12*/anotherAliasFoo = /*13*/internalFoo; + +goTo.marker('1'); +verify.quickInfoIs("class m1.m2.c", "class comment;"); + +goTo.marker('2'); +verify.quickInfoIs('import internalAlias = m1.m2.c', "This is on import declaration"); + +goTo.marker('3'); +verify.quickInfoIs("class m1.m2.c", "class comment;"); + +goTo.marker('4'); +verify.quickInfoIs("(var) newVar: internalAlias", ""); + +goTo.marker('5'); +verify.quickInfoIs("(alias) new internalAlias(): internalAlias\nimport internalAlias = m1.m2.c", ""); + +goTo.marker('6'); +verify.quickInfoIs("(var) anotherAliasVar: typeof internalAlias", ""); + +goTo.marker('7'); +verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration"); + +goTo.marker('8'); +verify.quickInfoIs('import internalFoo = m1.foo', ""); + +goTo.marker('9'); +verify.quickInfoIs("(function) m1.foo(): void", ""); + +goTo.marker('10'); +verify.quickInfoIs("(var) callVar: void", ""); + +goTo.marker('11'); +verify.quickInfoIs("(alias) internalFoo(): void\nimport internalFoo = m1.foo", ""); + +goTo.marker('12'); +verify.quickInfoIs("(var) anotherAliasFoo: () => void", ""); + +goTo.marker('13'); +verify.quickInfoIs("import internalFoo = m1.foo", ""); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoOnUndefined.ts b/tests/cases/fourslash/quickInfoOnUndefined.ts index 252da49d4fe..1bb516d2c18 100644 --- a/tests/cases/fourslash/quickInfoOnUndefined.ts +++ b/tests/cases/fourslash/quickInfoOnUndefined.ts @@ -3,6 +3,13 @@ ////function foo(a: string) { ////} ////foo(/*1*/undefined); +////var x = { +//// undefined: 10 +////}; +////x./*2*/undefined = 30; goTo.marker('1'); -verify.quickInfoIs('(var) undefined'); \ No newline at end of file +verify.quickInfoIs('(var) undefined'); + +goTo.marker('2'); +verify.quickInfoIs('(property) undefined: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoForUnionProperty.ts b/tests/cases/fourslash/quickinfoForUnionProperty.ts new file mode 100644 index 00000000000..b5c7dc0a01c --- /dev/null +++ b/tests/cases/fourslash/quickinfoForUnionProperty.ts @@ -0,0 +1,27 @@ +/// + +////interface One { +//// commonProperty: number; +//// commonFunction(): number; +////} +//// +////interface Two { +//// commonProperty: string +//// commonFunction(): number; +////} +//// +////var /*1*/x : One | Two; +//// +////x./*2*/commonProperty; +////x./*3*/commonFunction; + + +goTo.marker("1"); +verify.quickInfoIs('(var) x: One | Two'); + + +goTo.marker("2"); +verify.quickInfoIs('(property) commonProperty: string | number'); + +goTo.marker("3"); +verify.quickInfoIs('(method) commonFunction(): number'); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts index f21f6cc3936..15dd5720019 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts @@ -1,5 +1,5 @@ -/// - +/// + ////interface IFoo { /*1*/xy: number; } //// ////// Assignment @@ -23,10 +23,10 @@ ////var w: IFoo = { /*4*/xy: undefined }; //// ////// Untped -- should not be included -////var u = { xy: 0 }; - - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(9); -}); +////var u = { xy: 0 }; + + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(9); +}); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts new file mode 100644 index 00000000000..f9c479de769 --- /dev/null +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts @@ -0,0 +1,40 @@ +/// + +////interface A { +//// a: number; +//// common: string; +////} +//// +////interface B { +//// b: number; +//// common: number; +////} +//// +////// Assignment +////var v1: A | B = { a: 0, /*1*/common: "" }; +////var v2: A | B = { b: 0, /*2*/common: 3 }; +//// +////// Function call +////function consumer(f: A | B) { } +////consumer({ a: 0, b: 0, /*3*/common: 1 }); +//// +////// Type cast +////var c = { /*4*/common: 0, b: 0 }; +//// +////// Array literal +////var ar: Array = [{ a: 0, /*5*/common: "" }, { b: 0, /*6*/common: 0 }]; +//// +////// Nested object literal +////var ob: { aorb: A|B } = { aorb: { b: 0, /*7*/common: 0 } }; +//// +////// Widened type +////var w: A|B = { a:0, /*8*/common: undefined }; +//// +////// Untped -- should not be included +////var u1 = { a: 0, b: 0, common: "" }; +////var u2 = { b: 0, common: 0 }; + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(10); // 8 contextually typed common, and 2 in definition (A.common, B.common) +}); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts new file mode 100644 index 00000000000..bbcc482a6e7 --- /dev/null +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts @@ -0,0 +1,40 @@ +/// + +////interface A { +//// a: number; +//// common: string; +////} +//// +////interface B { +//// /*1*/b: number; +//// common: number; +////} +//// +////// Assignment +////var v1: A | B = { a: 0, common: "" }; +////var v2: A | B = { /*2*/b: 0, common: 3 }; +//// +////// Function call +////function consumer(f: A | B) { } +////consumer({ a: 0, /*3*/b: 0, common: 1 }); +//// +////// Type cast +////var c = { common: 0, /*4*/b: 0 }; +//// +////// Array literal +////var ar: Array = [{ a: 0, common: "" }, { /*5*/b: 0, common: 0 }]; +//// +////// Nested object literal +////var ob: { aorb: A|B } = { aorb: { /*6*/b: 0, common: 0 } }; +//// +////// Widened type +////var w: A|B = { /*7*/b:undefined, common: undefined }; +//// +////// Untped -- should not be included +////var u1 = { a: 0, b: 0, common: "" }; +////var u2 = { b: 0, common: 0 }; + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(7); +}); diff --git a/tests/cases/fourslash/referencesForUnionProperties.ts b/tests/cases/fourslash/referencesForUnionProperties.ts new file mode 100644 index 00000000000..f4ef85e8e4e --- /dev/null +++ b/tests/cases/fourslash/referencesForUnionProperties.ts @@ -0,0 +1,35 @@ +/// + +////interface One { +//// common: { /*1*/a: number; }; +////} +//// +////interface Base { +//// /*2*/a: string; +//// b: string; +////} +//// +////interface HasAOrB extends Base { +//// /*3*/a: string; +//// b: string; +////} +//// +////interface Two { +//// common: HasAOrB; +////} +//// +////var x : One | Two; +//// +////x.common./*4*/a; + +goTo.marker("1"); +verify.referencesCountIs(2); // One.common.a, x.common.a + +goTo.marker("2"); +verify.referencesCountIs(3); // Base.a, HasAOrB.a, x.common.a + +goTo.marker("3"); +verify.referencesCountIs(3); // Base.a, HasAOrB.a, x.common.a + +goTo.marker("4"); +verify.referencesCountIs(4); // One.common.a, Base.a, HasAOrB.a, x.common.a \ No newline at end of file diff --git a/tests/cases/fourslash/selfReferencedExternalModule.ts b/tests/cases/fourslash/selfReferencedExternalModule.ts index ec312ccb1e5..f5e955839c7 100644 --- a/tests/cases/fourslash/selfReferencedExternalModule.ts +++ b/tests/cases/fourslash/selfReferencedExternalModule.ts @@ -5,5 +5,5 @@ ////A./**/I goTo.marker(); -verify.completionListContains("A", "(alias) A"); +verify.completionListContains("A", "import A = require('app')"); verify.completionListContains("I", "(var) I: number"); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassification1.ts b/tests/cases/fourslash/semanticClassification1.ts index ad9e88ea842..4eb7f2a32ed 100644 --- a/tests/cases/fourslash/semanticClassification1.ts +++ b/tests/cases/fourslash/semanticClassification1.ts @@ -1,11 +1,15 @@ /// -//// module M { -//// export interface I { +//// module /*0*/M { +//// export interface /*1*/I { //// } //// } -//// interface X extends M.I { } +//// interface /*2*/X extends /*3*/M./*4*/I { } var c = classification; verify.semanticClassificationsAre( - c.moduleName("M"), c.interfaceName("I"), c.interfaceName("X"), c.moduleName("M"), c.interfaceName("I")); + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.interfaceName("X", test.marker("2").position), + c.moduleName("M", test.marker("3").position), + c.interfaceName("I", test.marker("4").position)); diff --git a/tests/cases/fourslash/semanticClassification2.ts b/tests/cases/fourslash/semanticClassification2.ts index 810636dba3e..f7f6340e5bd 100644 --- a/tests/cases/fourslash/semanticClassification2.ts +++ b/tests/cases/fourslash/semanticClassification2.ts @@ -1,6 +1,6 @@ /// -//// interface Thing { +//// interface /*0*/Thing { //// toExponential(): number; //// } //// @@ -8,4 +8,4 @@ //// Thing.toExponential(); var c = classification; -verify.semanticClassificationsAre(c.interfaceName("Thing")); \ No newline at end of file +verify.semanticClassificationsAre(c.interfaceName("Thing", test.marker("0").position)); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassification3.ts b/tests/cases/fourslash/semanticClassification3.ts deleted file mode 100644 index c1d8da243e7..00000000000 --- a/tests/cases/fourslash/semanticClassification3.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -////declare module M { -//// interface I { -//// -//// } -////} -//// -////var M = { I: 10 }; - -var c = classification; -verify.semanticClassificationsAre(c.moduleName("M"), c.interfaceName("I"), c.moduleName("M")); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts new file mode 100644 index 00000000000..2b8b6824558 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts @@ -0,0 +1,24 @@ +/// + +////module /*0*/M { +//// export interface /*1*/I { +//// } +//// var x = 10; +////} +//// +////var /*2*/M = { +//// foo: 10, +//// bar: 20 +////} +//// +////var v: /*3*/M./*4*/I; +//// +////var x = /*5*/M; + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.moduleName("M", test.marker("3").position), + c.interfaceName("I", test.marker("4").position), + c.moduleName("M", test.marker("5").position)); diff --git a/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts new file mode 100644 index 00000000000..5d2ed9844cc --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts @@ -0,0 +1,28 @@ +/// + +////module /*0*/M { +//// export interface /*1*/I { +//// } +////} +//// +////module /*2*/M { +//// var x = 10; +////} +//// +////var /*3*/M = { +//// foo: 10, +//// bar: 20 +////} +//// +////var v: /*4*/M./*5*/I; +//// +////var x = /*6*/M; + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.moduleName("M", test.marker("2").position), + c.moduleName("M", test.marker("4").position), + c.interfaceName("I", test.marker("5").position), + c.moduleName("M", test.marker("6").position)); diff --git a/tests/cases/fourslash/semanticClassificationModules.ts b/tests/cases/fourslash/semanticClassificationModules.ts new file mode 100644 index 00000000000..86c2819983a --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationModules.ts @@ -0,0 +1,19 @@ +/// + +////module /*0*/M { +//// export var v; +//// export interface /*1*/I { +//// } +////} +//// +////var x: /*2*/M./*3*/I = /*4*/M.v; +////var y = /*5*/M; + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.moduleName("M", test.marker("2").position), + c.interfaceName("I", test.marker("3").position), + c.moduleName("M", test.marker("4").position), + c.moduleName("M", test.marker("5").position)); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts new file mode 100644 index 00000000000..e7486c2c0cb --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts @@ -0,0 +1,14 @@ +/// + +////declare module /*0*/M { +//// interface /*1*/I { +//// +//// } +////} +//// +////var M = { I: 10 }; + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position)); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts new file mode 100644 index 00000000000..f90efd7518d --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts @@ -0,0 +1,22 @@ +/// + +////module /*0*/M { +//// export interface /*1*/I { +//// } +////} +//// +////var /*2*/M = { +//// foo: 10, +//// bar: 20 +////} +//// +////var v: /*3*/M./*4*/I; +//// +////var x = /*5*/M; + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.moduleName("M", test.marker("3").position), + c.interfaceName("I", test.marker("4").position)); diff --git a/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts b/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts new file mode 100644 index 00000000000..40a7f409685 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts @@ -0,0 +1,24 @@ +////module /*0*/M { +//// export interface /*1*/I { +//// } +////} +//// +////interface /*2*/I { +////} +////class /*3*/C { +////} +//// +////var M: /*4*/M./*5*/I | /*6*/I | /*7*/C; +////var I: typeof M | typeof /*8*/C; + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.interfaceName("I", test.marker("2").position), + c.className("C", test.marker("3").position), + c.moduleName("M", test.marker("4").position), + c.interfaceName("I", test.marker("5").position), + c.interfaceName("I", test.marker("6").position), + c.className("C", test.marker("7").position), + c.className("C", test.marker("8").position)); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassifications1.ts b/tests/cases/fourslash/syntacticClassifications1.ts index e70a4b672ff..88f655683a3 100644 --- a/tests/cases/fourslash/syntacticClassifications1.ts +++ b/tests/cases/fourslash/syntacticClassifications1.ts @@ -18,7 +18,6 @@ //// } //// } -debugger; var c = classification; verify.syntacticClassificationsAre( c.comment("// comment"),