mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 02:35:48 -05:00
File diff suppressed because it is too large
Load Diff
@@ -82,7 +82,7 @@ module ts {
|
||||
return array1.concat(array2);
|
||||
}
|
||||
|
||||
export function uniqueElements<T>(array: T[]): T[] {
|
||||
export function deduplicate<T>(array: T[]): T[] {
|
||||
if (array) {
|
||||
var result: T[] = [];
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
|
||||
@@ -181,8 +181,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." },
|
||||
|
||||
@@ -716,14 +716,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
|
||||
|
||||
@@ -225,6 +225,8 @@ module ts {
|
||||
return child((<ArrayTypeNode>node).elementType);
|
||||
case SyntaxKind.TupleType:
|
||||
return children((<TupleTypeNode>node).elementTypes);
|
||||
case SyntaxKind.UnionType:
|
||||
return children((<UnionTypeNode>node).types);
|
||||
case SyntaxKind.ArrayLiteral:
|
||||
return children((<ArrayLiteral>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 = <ArrayTypeNode>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 = <NodeArray<TypeNode>>[type];
|
||||
types.pos = type.pos;
|
||||
while (parseOptional(SyntaxKind.BarToken)) {
|
||||
types.push(parseNonUnionType());
|
||||
}
|
||||
types.end = getNodeEnd();
|
||||
var node = <UnionTypeNode>createNode(SyntaxKind.UnionType, type.pos);
|
||||
node.types = types;
|
||||
type = finishNode(node);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function parseTypeAnnotation(): TypeNode {
|
||||
return parseOptional(SyntaxKind.ColonToken) ? parseType() : undefined;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
@@ -337,6 +338,10 @@ module ts {
|
||||
elementTypes: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface UnionTypeNode extends TypeNode {
|
||||
types: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface StringLiteralTypeNode extends TypeNode {
|
||||
text: string;
|
||||
}
|
||||
@@ -648,7 +653,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;
|
||||
@@ -757,19 +762,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)
|
||||
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)
|
||||
Undefined = 0x10000000, // Symbol for the undefined
|
||||
|
||||
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,
|
||||
@@ -827,6 +835,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 { }
|
||||
@@ -849,14 +858,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<boolean>; // Cache of assignment checks
|
||||
}
|
||||
|
||||
export enum TypeFlags {
|
||||
@@ -874,13 +884,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
|
||||
@@ -938,6 +949,10 @@ module ts {
|
||||
baseArrayType: TypeReference; // Array<T> 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
|
||||
@@ -970,6 +985,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
|
||||
}
|
||||
@@ -984,9 +1000,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 {
|
||||
|
||||
@@ -2259,6 +2259,10 @@ 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, typeChecker),
|
||||
@@ -2613,7 +2617,7 @@ module ts {
|
||||
// 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,
|
||||
@@ -2658,7 +2662,7 @@ module ts {
|
||||
|
||||
// TODO(drosen): use contextual SemanticMeaning.
|
||||
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker): string {
|
||||
var flags = typeInfoResolver.getRootSymbol(symbol).getFlags();
|
||||
var flags = typeInfoResolver.getRootSymbols(symbol)[0].getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
|
||||
if (flags & SymbolFlags.Enum) return ScriptElementKind.enumElement;
|
||||
@@ -2740,15 +2744,13 @@ 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 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
|
||||
@@ -2858,14 +2860,13 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo) {
|
||||
displayParts.push(keywordPart(SyntaxKind.ClassKeyword));
|
||||
displayParts.push(spacePart());
|
||||
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());
|
||||
@@ -2884,7 +2885,7 @@ module ts {
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.TypeParameter) {
|
||||
if ((symbolFlags & SymbolFlags.TypeParameter) && (semanticMeaning & SemanticMeaning.Type)) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
displayParts.push(textPart("type parameter"));
|
||||
@@ -3050,7 +3051,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:
|
||||
@@ -3085,7 +3085,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,
|
||||
@@ -3117,7 +3117,7 @@ module ts {
|
||||
result.push(getDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3181,7 +3181,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;
|
||||
}
|
||||
|
||||
@@ -3714,18 +3714,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);
|
||||
@@ -3747,15 +3749,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;
|
||||
@@ -3782,22 +3784,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(<SourceFile>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(<SourceFile>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;
|
||||
@@ -3933,14 +3937,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));
|
||||
}
|
||||
});
|
||||
@@ -4102,24 +4099,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;
|
||||
}
|
||||
@@ -4155,11 +4155,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;
|
||||
}
|
||||
|
||||
@@ -4167,29 +4163,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 = (<Identifier>node).text;
|
||||
if (contextualType) {
|
||||
return typeInfoResolver.getPropertyOfType(contextualType, (<Identifier>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((<UnionType>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;
|
||||
@@ -4691,7 +4719,6 @@ module ts {
|
||||
function classifySymbol(symbol: Symbol, meaningAtPosition: SemanticMeaning) {
|
||||
var flags = symbol.getFlags();
|
||||
|
||||
// TODO(drosen): use meaningAtPosition.
|
||||
if (flags & SymbolFlags.Class) {
|
||||
return ClassificationTypeNames.className;
|
||||
}
|
||||
@@ -4709,8 +4736,6 @@ module ts {
|
||||
else if (flags & SymbolFlags.Module) {
|
||||
return ClassificationTypeNames.moduleName;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function processNode(node: Node) {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
<number>(this.voidIfAny([4, 2][0]));
|
||||
<number>(this.voidIfAny([4, 2, undefined][0]));
|
||||
<number>(this.voidIfAny([undefined, 2, 4][0]));
|
||||
<number>(this.voidIfAny([null, 2, 4][0]));
|
||||
<number>(this.voidIfAny([2, 4, null][0]));
|
||||
<number>(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; }
|
||||
|
||||
<number>(this.voidIfAny(['', "q"][0]));
|
||||
<number>(this.voidIfAny(['', "q", undefined][0]));
|
||||
<number>(this.voidIfAny([undefined, "q", ''][0]));
|
||||
<number>(this.voidIfAny([null, "q", ''][0]));
|
||||
<number>(this.voidIfAny(["q", '', null][0]));
|
||||
<number>(this.voidIfAny([undefined, '', null][0]));
|
||||
public x() {
|
||||
<number>(this.voidIfAny([4, 2][0]));
|
||||
<number>(this.voidIfAny([4, 2, undefined][0]));
|
||||
<number>(this.voidIfAny([undefined, 2, 4][0]));
|
||||
<number>(this.voidIfAny([null, 2, 4][0]));
|
||||
<number>(this.voidIfAny([2, 4, null][0]));
|
||||
<number>(this.voidIfAny([undefined, 4, null][0]));
|
||||
|
||||
<number>(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() } ];
|
||||
<number>(this.voidIfAny(['', "q"][0]));
|
||||
<number>(this.voidIfAny(['', "q", undefined][0]));
|
||||
<number>(this.voidIfAny([undefined, "q", ''][0]));
|
||||
<number>(this.voidIfAny([null, "q", ''][0]));
|
||||
<number>(this.voidIfAny(["q", '', null][0]));
|
||||
<number>(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();
|
||||
<number>(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() {
|
||||
<number>(this.voidIfAny([4, 2][0]));
|
||||
<number>(this.voidIfAny([4, 2, undefined][0]));
|
||||
<number>(this.voidIfAny([undefined, 2, 4][0]));
|
||||
<number>(this.voidIfAny([null, 2, 4][0]));
|
||||
<number>(this.voidIfAny([2, 4, null][0]));
|
||||
<number>(this.voidIfAny([undefined, 4, null][0]));
|
||||
|
||||
<number>(this.voidIfAny(['', "q"][0]));
|
||||
<number>(this.voidIfAny(['', "q", undefined][0]));
|
||||
<number>(this.voidIfAny([undefined, "q", ''][0]));
|
||||
<number>(this.voidIfAny([null, "q", ''][0]));
|
||||
<number>(this.voidIfAny(["q", '', null][0]));
|
||||
<number>(this.voidIfAny([undefined, '', null][0]));
|
||||
|
||||
<number>(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 = {}));
|
||||
|
||||
@@ -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
|
||||
|
||||
<number>(this.voidIfAny([4, 2][0]));
|
||||
<number>(this.voidIfAny([4, 2][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([4, 2, undefined][0]));
|
||||
<number>(this.voidIfAny([4, 2, undefined][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([undefined, 2, 4][0]));
|
||||
<number>(this.voidIfAny([undefined, 2, 4][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([null, 2, 4][0]));
|
||||
<number>(this.voidIfAny([null, 2, 4][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([2, 4, null][0]));
|
||||
<number>(this.voidIfAny([2, 4, null][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([undefined, 4, null][0]));
|
||||
<number>(this.voidIfAny([undefined, 4, null][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny(['', "q"][0]));
|
||||
<number>(this.voidIfAny(['', "q"][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny(['', "q", undefined][0]));
|
||||
<number>(this.voidIfAny(['', "q", undefined][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([undefined, "q", ''][0]));
|
||||
<number>(this.voidIfAny([undefined, "q", ''][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([null, "q", ''][0]));
|
||||
<number>(this.voidIfAny([null, "q", ''][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny(["q", '', null][0]));
|
||||
<number>(this.voidIfAny(["q", '', null][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([undefined, '', null][0]));
|
||||
<number>(this.voidIfAny([undefined, '', null][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(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]) : number
|
||||
<number>(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]) : 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
|
||||
|
||||
<number>(this.voidIfAny([4, 2][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([4, 2, undefined][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([undefined, 2, 4][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([null, 2, 4][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([2, 4, null][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([undefined, 4, null][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny(['', "q"][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny(['', "q", undefined][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([undefined, "q", ''][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(this.voidIfAny([null, "q", ''][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny(["q", '', null][0]));
|
||||
><number>(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[]
|
||||
|
||||
<number>(this.voidIfAny([undefined, '', null][0]));
|
||||
><number>(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
|
||||
|
||||
<number>(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]) : 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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[]
|
||||
|
||||
@@ -25,7 +25,7 @@ var y = new Array<number>();
|
||||
|
||||
var x2: number[] = [];
|
||||
>x2 : number[]
|
||||
>[] : number[]
|
||||
>[] : undefined[]
|
||||
|
||||
var x2: number[] = new Array(1);
|
||||
>x2 : number[]
|
||||
|
||||
@@ -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; }'.
|
||||
@@ -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<Giraffe|Elephant> not {}[]
|
||||
bar(arr); // ok because arr is Array<Giraffe|Elephant> 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<Giraffe|Elephant> not {}[]
|
||||
bar(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
|
||||
|
||||
86
tests/baselines/reference/arrayLiteralContextualType.types
Normal file
86
tests/baselines/reference/arrayLiteralContextualType.types
Normal file
@@ -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<Giraffe | Elephant>
|
||||
|
||||
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<Giraffe | Elephant>
|
||||
|
||||
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<Giraffe | Elephant>
|
||||
>[new Giraffe(), new Elephant()] : Array<Giraffe | Elephant>
|
||||
>new Giraffe() : Giraffe
|
||||
>Giraffe : typeof Giraffe
|
||||
>new Elephant() : Elephant
|
||||
>Elephant : typeof Elephant
|
||||
|
||||
foo(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
|
||||
>foo(arr) : void
|
||||
>foo : (animals: IAnimal[]) => void
|
||||
>arr : Array<Giraffe | Elephant>
|
||||
|
||||
bar(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
|
||||
>bar(arr) : void
|
||||
>bar : (animals: { [x: number]: IAnimal; }) => void
|
||||
>arr : Array<Giraffe | Elephant>
|
||||
|
||||
@@ -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[]
|
||||
|
||||
|
||||
@@ -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<ActionA | ActionB>
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
@@ -78,7 +78,7 @@ var z1: { id: number }[] =
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : { 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<ActionA | ActionB>
|
||||
|
||||
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
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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<typeof C>; // Should OK, not be a parse error
|
||||
@@ -31,7 +24,6 @@ var classTypeArray: Array<typeof C>; // 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() {
|
||||
|
||||
@@ -2,25 +2,19 @@
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : {}[]
|
||||
>[[], [1], ['']] : {}[]
|
||||
>arr1 : Array<string[] | number[]>
|
||||
>[[], [1], ['']] : Array<string[] | number[]>
|
||||
>[] : 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<string[] | number[]>
|
||||
>[[null], [1], ['']] : Array<string[] | number[]>
|
||||
>[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<Derived1 | Derived2>
|
||||
>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
|
||||
|
||||
@@ -61,8 +61,8 @@ var xs = [list, myList]; // {}[]
|
||||
>myList : MyList<number>
|
||||
|
||||
var ys = [list, list2]; // {}[]
|
||||
>ys : {}[]
|
||||
>[list, list2] : {}[]
|
||||
>ys : Array<List<number> | List<string>>
|
||||
>[list, list2] : Array<List<number> | List<string>>
|
||||
>list : List<number>
|
||||
>list2 : List<string>
|
||||
|
||||
|
||||
@@ -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 '[{}]':
|
||||
|
||||
@@ -6,6 +6,6 @@ function method() {
|
||||
>dictionary : { [x: string]: string; }
|
||||
><{ [index: string]: string; }>{} : { [x: string]: string; }
|
||||
>index : string
|
||||
>{} : { [x: string]: string; }
|
||||
>{} : { [x: string]: undefined; }
|
||||
}
|
||||
|
||||
|
||||
@@ -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, U>(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
|
||||
}
|
||||
|
||||
@@ -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, U>(t: T, u: U) {
|
||||
return true ? t : u;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2367: No best common type exists between 'T' and 'U'.
|
||||
}
|
||||
|
||||
function foo2<T extends U, U>(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 extends U, U extends V, V>(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'.
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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'.
|
||||
@@ -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'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'boolean':
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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'.
|
||||
!!! 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'.
|
||||
@@ -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; };
|
||||
|
||||
@@ -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; }
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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'.
|
||||
|
||||
@@ -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<number | { id: number; }>' is not assignable to type '{ id: number; }[]':
|
||||
Type 'number | { id: number; }' is not assignable to type '{ id: number; }':
|
||||
Type 'number' is not assignable to type '{ id: number; }':
|
||||
Property 'id' is missing in type 'Number'.
|
||||
|
||||
|
||||
==== 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 '{}'.
|
||||
!!! error TS2322: Type 'Array<number | { id: number; }>' is not assignable to type '{ id: number; }[]':
|
||||
!!! error TS2322: Type 'number | { id: number; }' is not assignable to type '{ id: number; }':
|
||||
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }':
|
||||
!!! error TS2322: Property 'id' is missing in type 'Number'.
|
||||
@@ -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<string | number>' is not assignable to parameter of type 'number[]'.
|
||||
Type 'string | number' is not assignable to type 'number':
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/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'.
|
||||
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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; }'.
|
||||
!!! 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; }'.
|
||||
@@ -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<number | Date>' 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<number | Date>' 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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'.
|
||||
|
||||
@@ -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: <T>(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
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
@@ -1,9 +1,9 @@
|
||||
//// [contextualTypingWithFixedTypeParameters1.ts]
|
||||
var f10: <T>(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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -131,11 +131,11 @@ module templa.dom.mvc.composite {
|
||||
>super : typeof AbstractElementController
|
||||
|
||||
this._controllers = [];
|
||||
>this._controllers = [] : templa.mvc.IController<templa.mvc.IModel>[]
|
||||
>this._controllers = [] : undefined[]
|
||||
>this._controllers : templa.mvc.IController<templa.mvc.IModel>[]
|
||||
>this : AbstractCompositeElementController<ModelType>
|
||||
>_controllers : templa.mvc.IController<templa.mvc.IModel>[]
|
||||
>[] : templa.mvc.IController<templa.mvc.IModel>[]
|
||||
>[] : undefined[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ var ANY1;
|
||||
|
||||
var ANY2: any[] = ["", ""];
|
||||
>ANY2 : any[]
|
||||
>["", ""] : any[]
|
||||
>["", ""] : string[]
|
||||
|
||||
var obj = {x:1,y:null};
|
||||
>obj : { x: number; y: any; }
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,7): error TS2304: Cannot find name 'A'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts (3 errors) ====
|
||||
// -- operator on enum type
|
||||
|
||||
enum ENUM1 { A, B, "" };
|
||||
|
||||
// expression
|
||||
var ResultIsNumber1 = --ENUM1["A"];
|
||||
var ResultIsNumber2 = ENUM1.A--;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
|
||||
// miss assignment operator
|
||||
--ENUM1["A"];
|
||||
|
||||
ENUM1[A]--;
|
||||
~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,7): error TS2304: Cannot find name 'A'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts (3 errors) ====
|
||||
// -- operator on enum type
|
||||
|
||||
enum ENUM1 { A, B, "" };
|
||||
|
||||
// expression
|
||||
var ResultIsNumber1 = --ENUM1["A"];
|
||||
var ResultIsNumber2 = ENUM1.A--;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
|
||||
// miss assignment operator
|
||||
--ENUM1["A"];
|
||||
|
||||
ENUM1[A]--;
|
||||
~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
@@ -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<T>(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<T, U>(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 '{}'.
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
//// [defaultBestCommonTypesHaveDecls.ts]
|
||||
|
||||
var obj1: {};
|
||||
|
||||
obj1.length;
|
||||
|
||||
|
||||
|
||||
var obj2: Object;
|
||||
|
||||
obj2.length;
|
||||
|
||||
|
||||
|
||||
function concat<T>(x: T, y: T): T { return null; }
|
||||
var result = concat(1, ""); // error
|
||||
var elementCount = result.length;
|
||||
|
||||
var result = concat(1, "");
|
||||
function concat2<T, U>(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;
|
||||
|
||||
@@ -49,7 +49,7 @@ b = d2;
|
||||
var r: Base[] = [d1, d2];
|
||||
>r : Base[]
|
||||
>Base : Base
|
||||
>[d1, d2] : Base[]
|
||||
>[d1, d2] : Array<Derived | Derived2>
|
||||
>d1 : Derived
|
||||
>d2 : Derived2
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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<E3 | E4 | E7 | E8>
|
||||
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : Array<E3 | E4 | E7 | E8>
|
||||
|
||||
E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z
|
||||
>E8.B : E8
|
||||
@@ -183,8 +183,8 @@ var doNotPropagate = [
|
||||
];
|
||||
// Enum computed members are not propagated
|
||||
var doPropagate = [
|
||||
>doPropagate : {}[]
|
||||
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : {}[]
|
||||
>doPropagate : Array<E5 | E6 | E9>
|
||||
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : Array<E5 | E6 | E9>
|
||||
|
||||
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
|
||||
>E9.A : E9
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(2,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(3,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(4,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(5,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(6,5): error TS1151: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumIdentifierLiterals.ts (5 errors) ====
|
||||
enum Nums {
|
||||
1.0,
|
||||
~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
11e-1,
|
||||
~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
0.12e1,
|
||||
~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
"13e-1",
|
||||
~~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
0xF00D
|
||||
~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(2,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(3,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(4,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(5,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(6,5): error TS1151: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumIdentifierLiterals.ts (5 errors) ====
|
||||
enum Nums {
|
||||
1.0,
|
||||
~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
11e-1,
|
||||
~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
0.12e1,
|
||||
~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
"13e-1",
|
||||
~~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
0xF00D
|
||||
~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
//// [enumIdentifierLiterals.ts]
|
||||
//// [enumIdentifierLiterals.ts]
|
||||
enum Nums {
|
||||
1.0,
|
||||
11e-1,
|
||||
0.12e1,
|
||||
"13e-1",
|
||||
0xF00D
|
||||
}
|
||||
|
||||
//// [enumIdentifierLiterals.js]
|
||||
var Nums;
|
||||
(function (Nums) {
|
||||
Nums[Nums["1"] = 0] = "1";
|
||||
Nums[Nums["1.1"] = 1] = "1.1";
|
||||
Nums[Nums["1.2"] = 2] = "1.2";
|
||||
Nums[Nums["13e-1"] = 3] = "13e-1";
|
||||
Nums[Nums["61453"] = 4] = "61453";
|
||||
})(Nums || (Nums = {}));
|
||||
}
|
||||
|
||||
//// [enumIdentifierLiterals.js]
|
||||
var Nums;
|
||||
(function (Nums) {
|
||||
Nums[Nums["1"] = 0] = "1";
|
||||
Nums[Nums["1.1"] = 1] = "1.1";
|
||||
Nums[Nums["1.2"] = 2] = "1.2";
|
||||
Nums[Nums["13e-1"] = 3] = "13e-1";
|
||||
Nums[Nums["61453"] = 4] = "61453";
|
||||
})(Nums || (Nums = {}));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<T>(item1: T, item2: T) { }
|
||||
bar(1, ""); // Should be ok
|
||||
~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
@@ -1,13 +0,0 @@
|
||||
=== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts ===
|
||||
function bar<T>(item1: T, item2: T) { }
|
||||
>bar : <T>(item1: T, item2: T) => void
|
||||
>T : T
|
||||
>item1 : T
|
||||
>T : T
|
||||
>item2 : T
|
||||
>T : T
|
||||
|
||||
bar(1, ""); // Should be ok
|
||||
>bar(1, "") : void
|
||||
>bar : <T>(item1: T, item2: T) => void
|
||||
|
||||
@@ -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<C | D<string>>'.
|
||||
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<string>[]', but here has type 'D<number>[]'.
|
||||
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<string>()];;){}
|
||||
~~~
|
||||
!!! 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<C | D<string>>'.
|
||||
|
||||
for(var arr2 = [new D<string>()];;){}
|
||||
for( var arr2 = new Array<D<number>>();;){}
|
||||
|
||||
@@ -109,11 +109,11 @@ for (var a = ['a', 'b']; ;) { }
|
||||
for (var a = <string[]>[]; ;) { }
|
||||
>a : string[]
|
||||
><string[]>[] : string[]
|
||||
>[] : string[]
|
||||
>[] : undefined[]
|
||||
|
||||
for (var a: string[] = []; ;) { }
|
||||
>a : string[]
|
||||
>[] : string[]
|
||||
>[] : undefined[]
|
||||
|
||||
for (var a = new Array<string>(); ;) { }
|
||||
>a : string[]
|
||||
|
||||
@@ -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[]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,7 +49,7 @@ _.all([true, 1, null, 'yes'], _.identity);
|
||||
>_.all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => boolean
|
||||
>_ : Underscore.Static
|
||||
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => boolean
|
||||
>[true, 1, null, 'yes'] : {}[]
|
||||
>[true, 1, null, 'yes'] : Array<string | number | boolean>
|
||||
>_.identity : <T>(value: T) => T
|
||||
>_ : Underscore.Static
|
||||
>identity : <T>(value: T) => T
|
||||
|
||||
@@ -16,6 +16,6 @@ function map<U>() {
|
||||
var ys: U[] = [];
|
||||
>ys : U[]
|
||||
>U : U
|
||||
>[] : U[]
|
||||
>[] : undefined[]
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ class BaseCollection2<TItem extends CollectionItem2> {
|
||||
|
||||
constructor() {
|
||||
this._itemsByKey = {};
|
||||
>this._itemsByKey = {} : { [x: string]: TItem; }
|
||||
>this._itemsByKey = {} : { [x: string]: undefined; }
|
||||
>this._itemsByKey : { [x: string]: TItem; }
|
||||
>this : BaseCollection2<TItem>
|
||||
>_itemsByKey : { [x: string]: TItem; }
|
||||
>{} : { [x: string]: TItem; }
|
||||
>{} : { [x: string]: undefined; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,36 +25,36 @@ var ra = foo<any[]>([1, 2]); // any[]
|
||||
>ra : any[]
|
||||
>foo<any[]>([1, 2]) : any[]
|
||||
>foo : <T>(t: T) => T
|
||||
>[1, 2] : any[]
|
||||
>[1, 2] : number[]
|
||||
|
||||
var r2 = foo([]); // any[]
|
||||
>r2 : any[]
|
||||
>foo([]) : any[]
|
||||
>foo : <T>(t: T) => T
|
||||
>[] : any[]
|
||||
>[] : undefined[]
|
||||
|
||||
var r3 = foo<number[]>([]); // number[]
|
||||
>r3 : number[]
|
||||
>foo<number[]>([]) : number[]
|
||||
>foo : <T>(t: T) => T
|
||||
>[] : number[]
|
||||
>[] : undefined[]
|
||||
|
||||
var r4 = foo([1, '']); // {}[]
|
||||
>r4 : {}[]
|
||||
>foo([1, '']) : {}[]
|
||||
>r4 : Array<string | number>
|
||||
>foo([1, '']) : Array<string | number>
|
||||
>foo : <T>(t: T) => T
|
||||
>[1, ''] : {}[]
|
||||
>[1, ''] : Array<string | number>
|
||||
|
||||
var r5 = foo<any[]>([1, '']); // any[]
|
||||
>r5 : any[]
|
||||
>foo<any[]>([1, '']) : any[]
|
||||
>foo : <T>(t: T) => T
|
||||
>[1, ''] : any[]
|
||||
>[1, ''] : Array<string | number>
|
||||
|
||||
var r6 = foo<Object[]>([1, '']); // Object[]
|
||||
>r6 : Object[]
|
||||
>foo<Object[]>([1, '']) : Object[]
|
||||
>foo : <T>(t: T) => T
|
||||
>Object : Object
|
||||
>[1, ''] : Object[]
|
||||
>[1, ''] : Array<string | number>
|
||||
|
||||
|
||||
@@ -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<T>(x: (a: T) => T) {
|
||||
return x(null);
|
||||
}
|
||||
|
||||
var r = foo(<U>(x: U) => ''); // {}
|
||||
var r2 = foo<string>(<U>(x: U) => ''); // string
|
||||
var r3 = foo(x => ''); // {}
|
||||
|
||||
function foo2<T, U>(x: T, cb: (a: T) => U) {
|
||||
return cb(x);
|
||||
}
|
||||
|
||||
var r4 = foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
|
||||
var r5 = foo2(1, (a) => ''); // string
|
||||
var r6 = foo2<string, number>('', <Z>(a: Z) => 1);
|
||||
|
||||
function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
|
||||
return cb(x);
|
||||
}
|
||||
|
||||
var r7 = foo3(1, <Z>(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<number, string>(1, (a) => '', ''); // string
|
||||
|
||||
function other<T, U>(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'.
|
||||
}
|
||||
@@ -24,16 +24,16 @@ function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
|
||||
|
||||
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
|
||||
|
||||
var r8 = foo3(1, function (a) { return '' }, 1); // {}
|
||||
var r8 = foo3(1, function (a) { return '' }, 1); // error
|
||||
var r9 = foo3<number, string>(1, (a) => '', ''); // string
|
||||
|
||||
function other<T, U>(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
|
||||
}
|
||||
|
||||
@@ -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<T>(x: (a: T) => T) {
|
||||
>foo : <T>(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(<U>(x: U) => ''); // {}
|
||||
>r : {}
|
||||
>foo(<U>(x: U) => '') : {}
|
||||
>foo : <T>(x: (a: T) => T) => T
|
||||
><U>(x: U) => '' : <U>(x: U) => string
|
||||
>U : U
|
||||
>x : U
|
||||
>U : U
|
||||
|
||||
var r2 = foo<string>(<U>(x: U) => ''); // string
|
||||
>r2 : string
|
||||
>foo<string>(<U>(x: U) => '') : string
|
||||
>foo : <T>(x: (a: T) => T) => T
|
||||
><U>(x: U) => '' : <U>(x: U) => string
|
||||
>U : U
|
||||
>x : U
|
||||
>U : U
|
||||
|
||||
var r3 = foo(x => ''); // {}
|
||||
>r3 : {}
|
||||
>foo(x => '') : {}
|
||||
>foo : <T>(x: (a: T) => T) => T
|
||||
>x => '' : (x: {}) => string
|
||||
>x : {}
|
||||
|
||||
function foo2<T, U>(x: T, cb: (a: T) => U) {
|
||||
>foo2 : <T, U>(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 <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
|
||||
>r4 : string
|
||||
>foo2(1, function <Z>(a: Z) { return '' }) : string
|
||||
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>function <Z>(a: Z) { return '' } : <Z>(a: Z) => string
|
||||
>Z : Z
|
||||
>a : Z
|
||||
>Z : Z
|
||||
|
||||
var r5 = foo2(1, (a) => ''); // string
|
||||
>r5 : string
|
||||
>foo2(1, (a) => '') : string
|
||||
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>(a) => '' : (a: number) => string
|
||||
>a : number
|
||||
|
||||
var r6 = foo2<string, number>('', <Z>(a: Z) => 1);
|
||||
>r6 : number
|
||||
>foo2<string, number>('', <Z>(a: Z) => 1) : number
|
||||
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
><Z>(a: Z) => 1 : <Z>(a: Z) => number
|
||||
>Z : Z
|
||||
>a : Z
|
||||
>Z : Z
|
||||
|
||||
function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
|
||||
>foo3 : <T, U>(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, <Z>(a: Z) => '', ''); // string
|
||||
>r7 : string
|
||||
>foo3(1, <Z>(a: Z) => '', '') : string
|
||||
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
><Z>(a: Z) => '' : <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 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>function (a) { return '' } : (a: number) => string
|
||||
>a : number
|
||||
|
||||
var r9 = foo3<number, string>(1, (a) => '', ''); // string
|
||||
>r9 : string
|
||||
>foo3<number, string>(1, (a) => '', '') : string
|
||||
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>(a) => '' : (a: number) => string
|
||||
>a : number
|
||||
|
||||
function other<T, U>(t: T, u: U) {
|
||||
>other : <T, U>(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 : <T, U>(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 : <T, U>(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 : <T, U>(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 : <T, U>(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 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>function (a) { return '' } : (a: number) => string
|
||||
>a : number
|
||||
}
|
||||
@@ -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<T>(x: new(a: T) => T) {
|
||||
return new x(null);
|
||||
}
|
||||
|
||||
interface I {
|
||||
new <T>(x: T): T;
|
||||
}
|
||||
interface I2<T> {
|
||||
new (x: T): T;
|
||||
}
|
||||
var i: I;
|
||||
var i2: I2<string>;
|
||||
var a: {
|
||||
new <T>(x: T): T;
|
||||
}
|
||||
|
||||
var r = foo(i); // any
|
||||
var r2 = foo<string>(i); // string
|
||||
var r3 = foo(i2); // string
|
||||
var r3b = foo(a); // any
|
||||
|
||||
function foo2<T, U>(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<string, string>('', i2); // string
|
||||
|
||||
function foo3<T, U>(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<string, string>('', i2, ''); // string
|
||||
@@ -27,7 +27,7 @@ function foo2<T, U>(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<string, string>('', i2); // string
|
||||
@@ -38,7 +38,7 @@ function foo3<T, U>(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<string, string>('', 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
|
||||
|
||||
@@ -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<T>(x: new(a: T) => T) {
|
||||
>foo : <T>(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 <T>(x: T): T;
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
}
|
||||
interface I2<T> {
|
||||
>I2 : I2<T>
|
||||
>T : T
|
||||
|
||||
new (x: T): T;
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
}
|
||||
var i: I;
|
||||
>i : I
|
||||
>I : I
|
||||
|
||||
var i2: I2<string>;
|
||||
>i2 : I2<string>
|
||||
>I2 : I2<T>
|
||||
|
||||
var a: {
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
new <T>(x: T): T;
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
}
|
||||
|
||||
var r = foo(i); // any
|
||||
>r : any
|
||||
>foo(i) : any
|
||||
>foo : <T>(x: new (a: T) => T) => T
|
||||
>i : I
|
||||
|
||||
var r2 = foo<string>(i); // string
|
||||
>r2 : string
|
||||
>foo<string>(i) : string
|
||||
>foo : <T>(x: new (a: T) => T) => T
|
||||
>i : I
|
||||
|
||||
var r3 = foo(i2); // string
|
||||
>r3 : string
|
||||
>foo(i2) : string
|
||||
>foo : <T>(x: new (a: T) => T) => T
|
||||
>i2 : I2<string>
|
||||
|
||||
var r3b = foo(a); // any
|
||||
>r3b : any
|
||||
>foo(a) : any
|
||||
>foo : <T>(x: new (a: T) => T) => T
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
function foo2<T, U>(x: T, cb: new(a: T) => U) {
|
||||
>foo2 : <T, U>(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 : <T, U>(x: T, cb: new (a: T) => U) => U
|
||||
>i2 : I2<string>
|
||||
|
||||
var r4b = foo2(1, a); // any
|
||||
>r4b : any
|
||||
>foo2(1, a) : any
|
||||
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
var r5 = foo2(1, i); // any
|
||||
>r5 : any
|
||||
>foo2(1, i) : any
|
||||
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
|
||||
>i : I
|
||||
|
||||
var r6 = foo2<string, string>('', i2); // string
|
||||
>r6 : string
|
||||
>foo2<string, string>('', i2) : string
|
||||
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
|
||||
>i2 : I2<string>
|
||||
|
||||
function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
|
||||
>foo3 : <T, U>(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 : <T, U>(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 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
var r8 = foo3(1, i2, 1); // {}
|
||||
>r8 : {}
|
||||
>foo3(1, i2, 1) : {}
|
||||
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
|
||||
>i2 : I2<string>
|
||||
|
||||
var r9 = foo3<string, string>('', i2, ''); // string
|
||||
>r9 : string
|
||||
>foo3<string, string>('', i2, '') : string
|
||||
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
|
||||
>i2 : I2<string>
|
||||
|
||||
@@ -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<T>(a: (x: T) => T, b: (x: T) => T) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
module onlyT {
|
||||
function foo<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 r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
function other2<T extends Date>(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<T extends Date>(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<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
|
||||
function other3<T extends RegExp>(x: T) {
|
||||
var r7 = foo2((a: T) => a, (b: T) => b); // error
|
||||
~~~~~~~~~~~
|
||||
function other3<T extends RegExp>(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<T>(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<T, U>(a: (x: T) => T, b: (x: U) => U) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
|
||||
function foo3<T>(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'.
|
||||
function other2<T extends Date>(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<T extends Date, U extends Date>(a: (x: T) => T, b: (x: U) => U) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
|
||||
function other3<T extends RegExp>(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<T>(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);
|
||||
}
|
||||
@@ -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<T>(a: (x: T) => T, b: (x: T) => T) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
module onlyT {
|
||||
function foo<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) => '');
|
||||
|
||||
function other2<T extends Date>(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<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
|
||||
function other3<T extends RegExp>(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<T>(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<T, U>(a: (x: T) => T, b: (x: U) => U) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
|
||||
function other2<T extends Date>(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<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
function other2<T extends Date>(x: T) {
|
||||
var r7 = foo((a: T) => a, (b: T) => b);
|
||||
var r9 = r7(new Date());
|
||||
var r10 = r7(1);
|
||||
}
|
||||
|
||||
function other3<T extends RegExp>(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<T extends Date, U extends Date>(a: (x: T) => T, b: (x: U) => U) {
|
||||
var r: (x: T) => T;
|
||||
return r;
|
||||
}
|
||||
|
||||
enum E { A }
|
||||
enum F { A }
|
||||
function other3<T extends RegExp>(x: T) {
|
||||
var r7 = foo2((a: T) => a, (b: T) => b);
|
||||
var r7b = foo2((a) => a, (b) => b);
|
||||
}
|
||||
|
||||
function foo3<T>(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<T>(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 = {}));
|
||||
|
||||
@@ -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<T>(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<T, U>(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.
|
||||
@@ -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
|
||||
|
||||
@@ -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<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
|
||||
>foo : <T>(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 : <T>(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 : <T>(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 : <T>(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 : <T>(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 : <T>(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 : <T>(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 : <T>(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<T, U>(x: T, a: (x: T) => U, b: (x: T) => U) {
|
||||
>foo2 : <T, U>(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 : <T, U>(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 : <T, U>(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 : <T, U>(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 : <T, U>(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 : <T, U>(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
|
||||
|
||||
@@ -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<T>(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<Object>({ bar: 1, baz: '' }); // T = Object
|
||||
@@ -3,7 +3,7 @@ function foo<T>(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<Object>({ bar: 1, baz: '' }); // T = Object
|
||||
@@ -12,7 +12,7 @@ var r4 = foo<Object>({ 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
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts ===
|
||||
function foo<T>(x: { bar: T; baz: T }) {
|
||||
>foo : <T>(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 : <T>(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 : <T>(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: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
|
||||
>foo({ bar: foo, baz: foo }) : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
|
||||
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
|
||||
>{ bar: foo, baz: foo } : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
|
||||
>bar : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
|
||||
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
|
||||
>baz : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
|
||||
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
|
||||
|
||||
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
|
||||
>r4 : { bar: Object; baz: Object; }
|
||||
>foo<Object>({ bar: 1, baz: '' }) : { bar: Object; baz: Object; }
|
||||
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
|
||||
>Object : Object
|
||||
>{ bar: 1, baz: '' } : { bar: number; baz: string; }
|
||||
>bar : number
|
||||
>baz : string
|
||||
|
||||
@@ -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<T>(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<number>({ x: 3, y: "" }, 4);
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -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<T> {
|
||||
x: T;
|
||||
}
|
||||
|
||||
function foo<T>(t: X<T>, t2: X<T>) {
|
||||
var x: T;
|
||||
return x;
|
||||
}
|
||||
|
||||
var c1 = new X<C>();
|
||||
var d1 = new X<D>();
|
||||
var r = foo(c1, d1); // error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
var r2 = foo(c1, c1); // ok
|
||||
@@ -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<T> {
|
||||
>X : X<T>
|
||||
>T : T
|
||||
|
||||
x: T;
|
||||
>x : T
|
||||
>T : T
|
||||
}
|
||||
|
||||
function foo<T>(t: X<T>, t2: X<T>) {
|
||||
>foo : <T>(t: X<T>, t2: X<T>) => T
|
||||
>T : T
|
||||
>t : X<T>
|
||||
>X : X<T>
|
||||
>T : T
|
||||
>t2 : X<T>
|
||||
>X : X<T>
|
||||
>T : T
|
||||
|
||||
var x: T;
|
||||
>x : T
|
||||
>T : T
|
||||
|
||||
return x;
|
||||
>x : T
|
||||
}
|
||||
|
||||
var c1 = new X<C>();
|
||||
>c1 : X<C>
|
||||
>new X<C>() : X<C>
|
||||
>X : typeof X
|
||||
>C : C
|
||||
|
||||
var d1 = new X<D>();
|
||||
>d1 : X<D>
|
||||
>new X<D>() : X<D>
|
||||
>X : typeof X
|
||||
>D : D
|
||||
|
||||
var r = foo(c1, d1); // error
|
||||
>r : {}
|
||||
>foo(c1, d1) : {}
|
||||
>foo : <T>(t: X<T>, t2: X<T>) => T
|
||||
>c1 : X<C>
|
||||
>d1 : X<D>
|
||||
|
||||
var r2 = foo(c1, c1); // ok
|
||||
>r2 : C
|
||||
>foo(c1, c1) : C
|
||||
>foo : <T>(t: X<T>, t2: X<T>) => T
|
||||
>c1 : X<C>
|
||||
>c1 : X<C>
|
||||
|
||||
@@ -22,7 +22,7 @@ class Derived2 extends Base {
|
||||
|
||||
// returns {}[]
|
||||
function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
|
||||
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
|
||||
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
|
||||
>T : T
|
||||
>Base : Base
|
||||
>U : U
|
||||
@@ -34,7 +34,7 @@ function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
|
||||
>U : U
|
||||
|
||||
return [a.x, a.y];
|
||||
>[a.x, a.y] : {}[]
|
||||
>[a.x, a.y] : Array<T | U>
|
||||
>a.x : T
|
||||
>a : { x: T; y: U; }
|
||||
>x : T
|
||||
@@ -44,9 +44,9 @@ function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
|
||||
}
|
||||
|
||||
var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
|
||||
>r : {}[]
|
||||
>f({ x: new Derived(), y: new Derived2() }) : {}[]
|
||||
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
|
||||
>r : Array<Derived | Derived2>
|
||||
>f({ x: new Derived(), y: new Derived2() }) : Array<Derived | Derived2>
|
||||
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
|
||||
>{ 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 : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
|
||||
>r2 : Base[]
|
||||
>f({ x: new Base(), y: new Derived2() }) : Array<Base | Derived2>
|
||||
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
|
||||
>{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; }
|
||||
>x : Base
|
||||
>new Base() : Base
|
||||
|
||||
@@ -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<T extends Base, U extends { x: T; y: T }>(a: U) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -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 <T>(x: T): T };
|
||||
var r2 = foo4(b);
|
||||
}
|
||||
|
||||
module GenericParameter {
|
||||
function foo5<T>(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<T>(x: T): string; new<T>(x: number): T; }
|
||||
var r7 = foo5(b); // new any => string; new(x:number) => any
|
||||
|
||||
function foo6<T>(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<T>(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 <T>(x: T): string; <T>(x: number): T; }
|
||||
var c2: { new <T>(x: T): string; new<T>(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
|
||||
}
|
||||
@@ -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<T>(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;
|
||||
|
||||
@@ -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 <T>(x: T): T };
|
||||
>b : new <T>(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 <T>(x: T) => T
|
||||
}
|
||||
|
||||
module GenericParameter {
|
||||
>GenericParameter : typeof GenericParameter
|
||||
|
||||
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
|
||||
>foo5 : <T>(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 : <T>(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<T>(x: T): string; new<T>(x: number): T; }
|
||||
>b : { new <T>(x: T): string; new <T>(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 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
|
||||
>b : { new <T>(x: T): string; new <T>(x: number): T; }
|
||||
|
||||
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
|
||||
>foo6 : <T>(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 : <T>(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 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>b : { new <T>(x: T): string; new <T>(x: number): T; }
|
||||
|
||||
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
|
||||
>foo7 : <T>(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 : <T>(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 <T>(x: T): string; new <T>(x: number): T; }
|
||||
|
||||
var c: { new <T>(x: T): string; <T>(x: number): T; }
|
||||
>c : { <T>(x: number): T; new <T>(x: T): string; }
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : number
|
||||
>T : T
|
||||
|
||||
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
|
||||
>c2 : { new <T>(x: T): string; new <T>(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 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>c : { <T>(x: number): T; new <T>(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 : <T>(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 <T>(x: T): string; new <T>(x: number): T; }
|
||||
}
|
||||
@@ -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<T, U> {
|
||||
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"];
|
||||
|
||||
@@ -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<T> {
|
||||
foo<T>(x: (a: T) => T) {
|
||||
return x(null);
|
||||
}
|
||||
}
|
||||
|
||||
var c = new C<number>();
|
||||
var r = c.foo(<U>(x: U) => ''); // {}
|
||||
var r2 = c.foo<string>(<U>(x: U) => ''); // string
|
||||
var r3 = c.foo(x => ''); // {}
|
||||
|
||||
class C2<T> {
|
||||
foo(x: (a: T) => T) {
|
||||
return x(null);
|
||||
}
|
||||
}
|
||||
|
||||
var c2 = new C2<number>();
|
||||
var ra = c2.foo(<U>(x: U) => 1); // number
|
||||
var r3a = c2.foo(x => 1); // number
|
||||
}
|
||||
|
||||
module WithCandidates {
|
||||
class C<T> {
|
||||
foo2<T, U>(x: T, cb: (a: T) => U) {
|
||||
return cb(x);
|
||||
}
|
||||
}
|
||||
|
||||
var c: C<number>;
|
||||
var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
|
||||
var r5 = c.foo2(1, (a) => ''); // string
|
||||
var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
|
||||
|
||||
class C2<T, U> {
|
||||
foo3(x: T, cb: (a: T) => U, y: U) {
|
||||
return cb(x);
|
||||
}
|
||||
}
|
||||
|
||||
var c2: C2<number, string>;
|
||||
var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
|
||||
var r8 = c2.foo3(1, function (a) { return '' }, ''); // string
|
||||
|
||||
class C3<T, U> {
|
||||
foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
|
||||
return cb(x);
|
||||
}
|
||||
}
|
||||
var c3: C3<number, string>;
|
||||
|
||||
function other<T, U>(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'.
|
||||
}
|
||||
}
|
||||
@@ -55,12 +55,12 @@ module WithCandidates {
|
||||
var c3: C3<number, string>;
|
||||
|
||||
function other<T, U>(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 = {}));
|
||||
|
||||
@@ -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<T> {
|
||||
>C : C<T>
|
||||
>T : T
|
||||
|
||||
foo<T>(x: (a: T) => T) {
|
||||
>foo : <T>(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<number>();
|
||||
>c : C<number>
|
||||
>new C<number>() : C<number>
|
||||
>C : typeof C
|
||||
|
||||
var r = c.foo(<U>(x: U) => ''); // {}
|
||||
>r : {}
|
||||
>c.foo(<U>(x: U) => '') : {}
|
||||
>c.foo : <T>(x: (a: T) => T) => T
|
||||
>c : C<number>
|
||||
>foo : <T>(x: (a: T) => T) => T
|
||||
><U>(x: U) => '' : <U>(x: U) => string
|
||||
>U : U
|
||||
>x : U
|
||||
>U : U
|
||||
|
||||
var r2 = c.foo<string>(<U>(x: U) => ''); // string
|
||||
>r2 : string
|
||||
>c.foo<string>(<U>(x: U) => '') : string
|
||||
>c.foo : <T>(x: (a: T) => T) => T
|
||||
>c : C<number>
|
||||
>foo : <T>(x: (a: T) => T) => T
|
||||
><U>(x: U) => '' : <U>(x: U) => string
|
||||
>U : U
|
||||
>x : U
|
||||
>U : U
|
||||
|
||||
var r3 = c.foo(x => ''); // {}
|
||||
>r3 : {}
|
||||
>c.foo(x => '') : {}
|
||||
>c.foo : <T>(x: (a: T) => T) => T
|
||||
>c : C<number>
|
||||
>foo : <T>(x: (a: T) => T) => T
|
||||
>x => '' : (x: {}) => string
|
||||
>x : {}
|
||||
|
||||
class C2<T> {
|
||||
>C2 : C2<T>
|
||||
>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<number>();
|
||||
>c2 : C2<number>
|
||||
>new C2<number>() : C2<number>
|
||||
>C2 : typeof C2
|
||||
|
||||
var ra = c2.foo(<U>(x: U) => 1); // number
|
||||
>ra : number
|
||||
>c2.foo(<U>(x: U) => 1) : number
|
||||
>c2.foo : (x: (a: number) => number) => number
|
||||
>c2 : C2<number>
|
||||
>foo : (x: (a: number) => number) => number
|
||||
><U>(x: U) => 1 : <U>(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<number>
|
||||
>foo : (x: (a: number) => number) => number
|
||||
>x => 1 : (x: number) => number
|
||||
>x : number
|
||||
}
|
||||
|
||||
module WithCandidates {
|
||||
>WithCandidates : typeof WithCandidates
|
||||
|
||||
class C<T> {
|
||||
>C : C<T>
|
||||
>T : T
|
||||
|
||||
foo2<T, U>(x: T, cb: (a: T) => U) {
|
||||
>foo2 : <T, U>(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<number>;
|
||||
>c : C<number>
|
||||
>C : C<T>
|
||||
|
||||
var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
|
||||
>r4 : string
|
||||
>c.foo2(1, function <Z>(a: Z) { return '' }) : string
|
||||
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>c : C<number>
|
||||
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>function <Z>(a: Z) { return '' } : <Z>(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 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>c : C<number>
|
||||
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>(a) => '' : (a: number) => string
|
||||
>a : number
|
||||
|
||||
var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
|
||||
>r6 : number
|
||||
>c.foo2<string, number>('', <Z>(a: Z) => 1) : number
|
||||
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>c : C<number>
|
||||
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
><Z>(a: Z) => 1 : <Z>(a: Z) => number
|
||||
>Z : Z
|
||||
>a : Z
|
||||
>Z : Z
|
||||
|
||||
class C2<T, U> {
|
||||
>C2 : C2<T, U>
|
||||
>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<number, string>;
|
||||
>c2 : C2<number, string>
|
||||
>C2 : C2<T, U>
|
||||
|
||||
var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
|
||||
>r7 : string
|
||||
>c2.foo3(1, <Z>(a: Z) => '', '') : string
|
||||
>c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string
|
||||
>c2 : C2<number, string>
|
||||
>foo3 : (x: number, cb: (a: number) => string, y: string) => string
|
||||
><Z>(a: Z) => '' : <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<number, string>
|
||||
>foo3 : (x: number, cb: (a: number) => string, y: string) => string
|
||||
>function (a) { return '' } : (a: number) => string
|
||||
>a : number
|
||||
|
||||
class C3<T, U> {
|
||||
>C3 : C3<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
|
||||
>foo3 : <T, U>(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<number, string>;
|
||||
>c3 : C3<number, string>
|
||||
>C3 : C3<T, U>
|
||||
|
||||
function other<T, U>(t: T, u: U) {
|
||||
>other : <T, U>(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 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>c : C<number>
|
||||
>foo2 : <T, U>(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 : <T, U>(x: T, cb: (a: T) => U) => U
|
||||
>c : C<number>
|
||||
>foo2 : <T, U>(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 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>c3 : C3<number, string>
|
||||
>foo3 : <T, U>(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 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>c3 : C3<number, string>
|
||||
>foo3 : <T, U>(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 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>c3 : C3<number, string>
|
||||
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
|
||||
>function (a) { return '' } : (a: number) => string
|
||||
>a : number
|
||||
}
|
||||
}
|
||||
@@ -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<T>(...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<any>(1, "");
|
||||
var a1Gc = makeArrayG<Object>(1, "");
|
||||
var a1Gd = makeArrayG<number>(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<any>(1, "");
|
||||
var a2Gc = makeArrayG<any[]>(1, ""); // error
|
||||
~
|
||||
|
||||
@@ -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 : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
|
||||
>_ : Underscore.Static
|
||||
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
|
||||
>[true, 1, null, 'yes'] : {}[]
|
||||
>[true, 1, null, 'yes'] : Array<string | number | boolean>
|
||||
>_.identity : <T>(value: T) => T
|
||||
>_ : Underscore.Static
|
||||
>identity : <T>(value: T) => T
|
||||
@@ -69,7 +69,7 @@ var r3 = _.all([], _.identity);
|
||||
>_.all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
|
||||
>_ : Underscore.Static
|
||||
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
|
||||
>[] : any[]
|
||||
>[] : undefined[]
|
||||
>_.identity : <T>(value: T) => T
|
||||
>_ : Underscore.Static
|
||||
>identity : <T>(value: T) => T
|
||||
|
||||
@@ -8,7 +8,7 @@ class LazyArray<T> {
|
||||
><{ [objectId: string]: T; }>{} : { [x: string]: T; }
|
||||
>objectId : string
|
||||
>T : T
|
||||
>{} : { [x: string]: T; }
|
||||
>{} : { [x: string]: undefined; }
|
||||
|
||||
array() {
|
||||
>array : () => { [x: string]: T; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/genericsManyTypeParameters.ts ===
|
||||
function Foo<
|
||||
>Foo : <a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, a69, a91, a210, a310, a410, a510, a610, a111, a211, a311, a411, a511, a611, a112, a212, a312, a412, a512, a612, a113, a213, a313, a413, a513, a613, a114, a214, a314, a414, a514, a614, a115, a215, a315, a415, a515, a615, a116, a216, a316, a416, a516, a616, a117, a217, a317, a417, a517, a617, a118, a218, a318, a418, a518, a618>(x1: a1, y1: a21, z1: a31, 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 : <a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, a69, a91, a210, a310, a410, a510, a610, a111, a211, a311, a411, a511, a611, a112, a212, a312, a412, a512, a612, a113, a213, a313, a413, a513, a613, a114, a214, a314, a414, a514, a614, a115, a215, a315, a415, a515, a615, a116, a216, a316, a416, a516, a616, a117, a217, a317, a417, a517, a617, a118, a218, a318, a418, a518, a618>(x1: a1, y1: a21, z1: a31, 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 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618>
|
||||
|
||||
a1, a21, a31, a41, a51, a61,
|
||||
>a1 : a1
|
||||
@@ -402,7 +402,7 @@ function Foo<
|
||||
)
|
||||
{
|
||||
return [x1 , y1 , z1 , a1 , b1 , c1,
|
||||
>[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : {}[]
|
||||
>[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<a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618>
|
||||
>x1 : a1
|
||||
>y1 : a21
|
||||
>z1 : a31
|
||||
|
||||
@@ -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<string | number>' is not assignable to parameter of type 'string[]'.
|
||||
Type 'string | number' is not assignable to type 'string':
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== 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<string | number>' is not assignable to parameter of type 'string[]'.
|
||||
!!! error TS2345: Type 'string | number' is not assignable to type 'string':
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'string'.
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user