diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 913d7f3b2a91a..cb43388b2dd00 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -94,8 +94,6 @@ namespace ts { const globalThisSymbol = createSymbol(SymbolFlags.Module, "globalThis" as __String, CheckFlags.Readonly); globalThisSymbol.exports = globals; - globalThisSymbol.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; - (globalThisSymbol.valueDeclaration as Identifier).escapedText = "globalThis" as __String; globals.set(globalThisSymbol.escapedName, globalThisSymbol); const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); @@ -500,6 +498,7 @@ namespace ts { * This is only used if there is no exact match. */ let patternAmbientModules: PatternAmbientModule[]; + let patternAmbientModuleAugmentations: Map | undefined; let globalObjectType: ObjectType; let globalFunctionType: ObjectType; @@ -890,7 +889,7 @@ namespace ts { * Note: if target is transient, then it is mutable, and mergeSymbol with both mutate and return it. * If target is not transient, mergeSymbol will produce a transient clone, mutate that and return it. */ - function mergeSymbol(target: Symbol, source: Symbol): Symbol { + function mergeSymbol(target: Symbol, source: Symbol, unidirectional = false): Symbol { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & SymbolFlags.Assignment) { Debug.assert(source !== target); @@ -917,16 +916,24 @@ namespace ts { addRange(target.declarations, source.declarations); if (source.members) { if (!target.members) target.members = createSymbolTable(); - mergeSymbolTable(target.members, source.members); + mergeSymbolTable(target.members, source.members, unidirectional); } if (source.exports) { if (!target.exports) target.exports = createSymbolTable(); - mergeSymbolTable(target.exports, source.exports); + mergeSymbolTable(target.exports, source.exports, unidirectional + ); + } + if (!unidirectional) { + recordMergedSymbol(target, source); } - recordMergedSymbol(target, source); } else if (target.flags & SymbolFlags.NamespaceModule) { - error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + // Do not report an error when merging `var globalThis` with the built-in `globalThis`, + // as we will already report a "Declaration name conflicts..." error, and this error + // won't make much sense. + if (target !== globalThisSymbol) { + error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } } else { // error const isEitherEnum = !!(target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum); @@ -990,10 +997,10 @@ namespace ts { return combined; } - function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { + function mergeSymbolTable(target: SymbolTable, source: SymbolTable, unidirectional = false) { source.forEach((sourceSymbol, id) => { const targetSymbol = target.get(id); - target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol); }); } @@ -1023,7 +1030,22 @@ namespace ts { // obtain item referenced by 'export=' mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & SymbolFlags.Namespace) { - mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); + // If we’re merging an augmentation to a pattern ambient module, we want to + // perform the merge unidirectionally from the augmentation ('a.foo') to + // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you + // all the exports both from the pattern and from the augmentation, but + // 'getMergedSymbol()' on *.foo only gives you exports from *.foo. + if (some(patternAmbientModules, module => mainModule === module.symbol)) { + const merged = mergeSymbol(moduleAugmentation.symbol, mainModule, /*unidirectional*/ true); + if (!patternAmbientModuleAugmentations) { + patternAmbientModuleAugmentations = createMap(); + } + // moduleName will be a StringLiteral since this is not `declare global`. + patternAmbientModuleAugmentations.set((moduleName as StringLiteral).text, merged); + } + else { + mergeSymbol(mainModule, moduleAugmentation.symbol); + } } else { // moduleName will be a StringLiteral since this is not `declare global`. @@ -2452,6 +2474,14 @@ namespace ts { if (patternAmbientModules) { const pattern = findBestPatternMatch(patternAmbientModules, _ => _.pattern, moduleReference); if (pattern) { + // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // module augmentation by the specific name requested ('a.foo'), we store the merged symbol + // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports + // from a.foo. + const augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference); + if (augmentation) { + return getMergedSymbol(augmentation); + } return getMergedSymbol(pattern.symbol); } } @@ -8562,7 +8592,7 @@ namespace ts { function getSignatureInstantiation(signature: Signature, typeArguments: Type[] | undefined, isJavascript: boolean, inferredTypeParameters?: ReadonlyArray): Signature { const instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); if (inferredTypeParameters) { - const returnSignature = getSingleCallSignature(getReturnTypeOfSignature(instantiatedSignature)); + const returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature)); if (returnSignature) { const newReturnSignature = cloneSignature(returnSignature); newReturnSignature.typeParameters = inferredTypeParameters; @@ -8638,7 +8668,8 @@ namespace ts { // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - const isConstructor = signature.declaration!.kind === SyntaxKind.Constructor || signature.declaration!.kind === SyntaxKind.ConstructSignature; // TODO: GH#18217 + const kind = signature.declaration ? signature.declaration.kind : SyntaxKind.Unknown; + const isConstructor = kind === SyntaxKind.Constructor || kind === SyntaxKind.ConstructSignature || kind === SyntaxKind.ConstructorType; const type = createObjectType(ObjectFlags.Anonymous); type.members = emptySymbols; type.properties = emptyArray; @@ -10080,7 +10111,7 @@ namespace ts { error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); return indexInfo.type; } - if (indexInfo.isReadonly && (accessFlags & AccessFlags.Writing || accessExpression && (isAssignmentTarget(accessExpression) || isDeleteTarget(accessExpression)))) { + if (indexInfo.isReadonly && accessExpression && (isAssignmentTarget(accessExpression) || isDeleteTarget(accessExpression))) { if (accessExpression) { error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return indexInfo.type; @@ -10114,7 +10145,13 @@ namespace ts { } } else { - error(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + const suggestion = getSuggestionForNonexistentIndexSignature(objectType, accessExpression); + if (suggestion !== undefined) { + error(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion); + } + else { + error(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } } @@ -10383,11 +10420,11 @@ namespace ts { // We attempt to resolve the conditional type only when the check and extends types are non-generic if (!checkTypeInstantiable && !maybeTypeOfKind(inferredExtendsType, TypeFlags.Instantiable | TypeFlags.GenericMappedType)) { if (inferredExtendsType.flags & TypeFlags.AnyOrUnknown) { - return trueType; + return combinedMapper ? instantiateType(root.trueType, combinedMapper) : trueType; } // Return union of trueType and falseType for 'any' since it matches anything if (checkType.flags & TypeFlags.Any) { - return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), falseType]); + return getUnionType([combinedMapper ? instantiateType(root.trueType, combinedMapper) : trueType, falseType]); } // Return falseType for a definitely false extends check. We check an instantiations of the two // types with type parameters mapped to the wildcard type, the most permissive instantiations @@ -10402,7 +10439,7 @@ namespace ts { // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. if (isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { - return instantiateType(root.trueType, combinedMapper || mapper); + return combinedMapper ? instantiateType(root.trueType, combinedMapper) : trueType; } } // Return a deferred type for a check that is neither definitely true nor definitely false @@ -12319,6 +12356,15 @@ namespace ts { function reportRelationError(message: DiagnosticMessage | undefined, source: Type, target: Type) { const [sourceType, targetType] = getTypeNamesForErrorDisplay(source, target); + if (target.flags & TypeFlags.TypeParameter && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { + reportError( + Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, + sourceType, + targetType, + typeToString(target.immediateBaseConstraint), + ); + } + if (!message) { if (relation === comparableRelation) { message = Diagnostics.Type_0_is_not_comparable_to_type_1; @@ -12482,7 +12528,7 @@ namespace ts { if (result && isPerformingExcessPropertyChecks) { // Validate against excess props using the original `source` const discriminantType = target.flags & TypeFlags.Union ? findMatchingDiscriminantType(source, target as UnionType) : undefined; - if (!propertiesRelatedTo(source, discriminantType || target, reportErrors)) { + if (!propertiesRelatedTo(source, discriminantType || target, reportErrors, /*excludedProperties*/ undefined)) { return Ternary.False; } } @@ -12492,7 +12538,7 @@ namespace ts { result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target as IntersectionType, reportErrors); if (result && isPerformingExcessPropertyChecks) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { return Ternary.False; } } @@ -13170,7 +13216,7 @@ namespace ts { if (source.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Object) { // Report structural errors only if we haven't reported any errors yet const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors); + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined); if (result) { result &= signaturesRelatedTo(source, target, SignatureKind.Call, reportStructuralErrors); if (result) { @@ -13190,6 +13236,19 @@ namespace ts { return result; } } + // If S is an object type and T is a discriminated union, S may be related to T if + // there exists a constituent of T for every combination of the discriminants of S + // with respect to T. We do not report errors here, as we will use the existing + // error result from checking each constituent of the union. + if (source.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Union) { + const objectOnlyTarget = extractTypesOfKind(target, TypeFlags.Object); + if (objectOnlyTarget.flags & TypeFlags.Union) { + const result = typeRelatedToDiscriminatedType(source, objectOnlyTarget as UnionType); + if (result) { + return result; + } + } + } } return Ternary.False; @@ -13253,9 +13312,185 @@ namespace ts { return Ternary.False; } - function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { + function typeRelatedToDiscriminatedType(source: Type, target: UnionType) { + // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. + // a. If the number of combinations is above a set limit, the comparison is too complex. + // 2. Filter 'target' to the subset of types whose discriminants exist in the matrix. + // a. If 'target' does not satisfy all discriminants in the matrix, 'source' is not related. + // 3. For each type in the filtered 'target', determine if all non-discriminant properties of + // 'target' are related to a property in 'source'. + // + // NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts + // for examples. + + const sourceProperties = getPropertiesOfObjectType(source); + const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (!sourcePropertiesFiltered) return Ternary.False; + + // Though we could compute the number of combinations as we generate + // the matrix, this would incur additional memory overhead due to + // array allocations. To reduce this overhead, we first compute + // the number of combinations to ensure we will not surpass our + // fixed limit before incurring the cost of any allocations: + let numCombinations = 1; + for (const sourceProperty of sourcePropertiesFiltered) { + numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + if (numCombinations > 25) { + // We've reached the complexity limit. + return Ternary.False; + } + } + + // Compute the set of types for each discriminant property. + const sourceDiscriminantTypes: Type[][] = new Array(sourcePropertiesFiltered.length); + const excludedProperties = createUnderscoreEscapedMap(); + for (let i = 0; i < sourcePropertiesFiltered.length; i++) { + const sourceProperty = sourcePropertiesFiltered[i]; + const sourcePropertyType = getTypeOfSymbol(sourceProperty); + sourceDiscriminantTypes[i] = sourcePropertyType.flags & TypeFlags.Union + ? (sourcePropertyType as UnionType).types + : [sourcePropertyType]; + excludedProperties.set(sourceProperty.escapedName, true); + } + + // Match each combination of the cartesian product of discriminant properties to one or more + // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. + const discriminantCombinations = cartesianProduct(sourceDiscriminantTypes); + const matchingTypes: Type[] = []; + for (const combination of discriminantCombinations) { + let hasMatch = false; + outer: for (const type of target.types) { + for (let i = 0; i < sourcePropertiesFiltered.length; i++) { + const sourceProperty = sourcePropertiesFiltered[i]; + const targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); + if (!targetProperty) continue outer; + if (sourceProperty === targetProperty) continue; + // We compare the source property to the target in the context of a single discriminant type. + const related = propertyRelatedTo(source, target, sourceProperty, targetProperty, _ => combination[i], /*reportErrors*/ false); + // If the target property could not be found, or if the properties were not related, + // then this constituent is not a match. + if (!related) { + continue outer; + } + } + pushIfUnique(matchingTypes, type, equateValues); + hasMatch = true; + } + if (!hasMatch) { + // We failed to match any type for this combination. + return Ternary.False; + } + } + + // Compare the remaining non-discriminant properties of each match. + let result = Ternary.True; + for (const type of matchingTypes) { + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + if (result) { + result &= signaturesRelatedTo(source, type, SignatureKind.Call, /*reportStructuralErrors*/ false); + if (result) { + result &= signaturesRelatedTo(source, type, SignatureKind.Construct, /*reportStructuralErrors*/ false); + if (result) { + result &= indexTypesRelatedTo(source, type, IndexKind.String, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false); + if (result) { + result &= indexTypesRelatedTo(source, type, IndexKind.Number, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false); + } + } + } + } + if (!result) { + return result; + } + } + return result; + } + + function excludeProperties(properties: Symbol[], excludedProperties: UnderscoreEscapedMap | undefined) { + if (!excludedProperties || properties.length === 0) return properties; + let result: Symbol[] | undefined; + for (let i = 0; i < properties.length; i++) { + if (!excludedProperties.has(properties[i].escapedName)) { + if (result) { + result.push(properties[i]); + } + } + else if (!result) { + result = properties.slice(0, i); + } + } + return result || properties; + } + + function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean): Ternary { + const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); + const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); + if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { + const hasDifferingDeclarations = sourceProp.valueDeclaration !== targetProp.valueDeclaration; + if (getCheckFlags(sourceProp) & CheckFlags.ContainsPrivate && hasDifferingDeclarations) { + if (reportErrors) { + reportError(Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return Ternary.False; + } + if (hasDifferingDeclarations) { + if (reportErrors) { + if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) { + reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); + } + else { + reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), + typeToString(sourcePropFlags & ModifierFlags.Private ? source : target), + typeToString(sourcePropFlags & ModifierFlags.Private ? target : source)); + } + } + return Ternary.False; + } + } + else if (targetPropFlags & ModifierFlags.Protected) { + if (!isValidOverrideOf(sourceProp, targetProp)) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), + typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); + } + return Ternary.False; + } + } + else if (sourcePropFlags & ModifierFlags.Protected) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, + symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return Ternary.False; + } + // If the target comes from a partial union prop, allow `undefined` in the target type + const related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(getCheckFlags(targetProp) & CheckFlags.Partial)), reportErrors); + if (!related) { + if (reportErrors) { + reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + } + return Ternary.False; + } + // When checking for comparability, be more lenient with optional properties. + if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) { + // TypeScript 1.0 spec (April 2014): 3.8.3 + // S is a subtype of a type T, and T is a supertype of S if ... + // S' and T are object types and, for each member M in T.. + // M is a property and S' contains a property N where + // if M is a required property, N is also a required property + // (M - property in T) + // (N - property in S) + if (reportErrors) { + reportError(Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, + symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return Ternary.False; + } + return related; + } + + function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean, excludedProperties: UnderscoreEscapedMap | undefined): Ternary { if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); + return propertiesIdenticalTo(source, target, excludedProperties); } const requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); const unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false); @@ -13285,7 +13520,7 @@ namespace ts { return Ternary.False; } if (isObjectLiteralType(target)) { - for (const sourceProp of getPropertiesOfType(source)) { + for (const sourceProp of excludeProperties(getPropertiesOfType(source), excludedProperties)) { if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { const sourceType = getTypeOfSymbol(sourceProp); if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { @@ -13328,89 +13563,30 @@ namespace ts { // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members const properties = target.flags & TypeFlags.Union ? getPossiblePropertiesOfUnionType(target as UnionType) : getPropertiesOfType(target); - for (const targetProp of properties) { + for (const targetProp of excludeProperties(properties, excludedProperties)) { if (!(targetProp.flags & SymbolFlags.Prototype)) { const sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { continue; } - const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); - const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { - const hasDifferingDeclarations = sourceProp.valueDeclaration !== targetProp.valueDeclaration; - if (getCheckFlags(sourceProp) & CheckFlags.ContainsPrivate && hasDifferingDeclarations) { - if (reportErrors) { - reportError(Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); - } - return Ternary.False; - } - if (hasDifferingDeclarations) { - if (reportErrors) { - if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) { - reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), - typeToString(sourcePropFlags & ModifierFlags.Private ? source : target), - typeToString(sourcePropFlags & ModifierFlags.Private ? target : source)); - } - } - return Ternary.False; - } - } - else if (targetPropFlags & ModifierFlags.Protected) { - if (!isValidOverrideOf(sourceProp, targetProp)) { - if (reportErrors) { - reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), - typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); - } - return Ternary.False; - } - } - else if (sourcePropFlags & ModifierFlags.Protected) { - if (reportErrors) { - reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, - symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return Ternary.False; - } - // If the target comes from a partial union prop, allow `undefined` in the target type - const related = isRelatedTo(getTypeOfSymbol(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(getCheckFlags(targetProp) & CheckFlags.Partial)), reportErrors); + const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { - if (reportErrors) { - reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } return Ternary.False; } result &= related; - // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) { - // TypeScript 1.0 spec (April 2014): 3.8.3 - // S is a subtype of a type T, and T is a supertype of S if ... - // S' and T are object types and, for each member M in T.. - // M is a property and S' contains a property N where - // if M is a required property, N is also a required property - // (M - property in T) - // (N - property in S) - if (reportErrors) { - reportError(Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, - symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return Ternary.False; - } } } } return result; } - function propertiesIdenticalTo(source: Type, target: Type): Ternary { + function propertiesIdenticalTo(source: Type, target: Type, excludedProperties: UnderscoreEscapedMap | undefined): Ternary { if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) { return Ternary.False; } - const sourceProperties = getPropertiesOfObjectType(source); - const targetProperties = getPropertiesOfObjectType(target); + const sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); + const targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { return Ternary.False; } @@ -15949,6 +16125,10 @@ namespace ts { return f(type) ? type : neverType; } + function countTypes(type: Type) { + return type.flags & TypeFlags.Union ? (type as UnionType).types.length : 1; + } + // Apply a mapping function to a type and return the resulting type. If the source type // is a union type, the mapping function is applied to each constituent type and a union // of the resulting types is returned. @@ -18433,7 +18613,7 @@ namespace ts { case SyntaxKind.ParenthesizedExpression: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : undefined; - return tag ? getTypeFromTypeNode(tag.typeExpression!.type) : getContextualType(parent, contextFlags); + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } case SyntaxKind.JsxExpression: return getContextualTypeForJsxExpression(parent); @@ -20049,6 +20229,35 @@ namespace ts { return suggestion && symbolName(suggestion); } + function getSuggestionForNonexistentIndexSignature(objectType: Type, expr: ElementAccessExpression): string | undefined { + // check if object type has setter or getter + const hasProp = (name: "set" | "get", argCount = 1) => { + const prop = getPropertyOfObjectType(objectType, <__String>name); + if (prop) { + const s = getSingleCallSignature(getTypeOfSymbol(prop)); + if (s && getMinArgumentCount(s) === argCount && typeToString(getTypeAtPosition(s, 0)) === "string") { + return true; + } + } + return false; + }; + + const suggestedMethod = isAssignmentTarget(expr) ? "set" : "get"; + if (!hasProp(suggestedMethod)) { + return undefined; + } + + let suggestion = tryGetPropertyAccessOrIdentifierToString(expr); + if (suggestion === undefined) { + suggestion = suggestedMethod; + } + else { + suggestion += "." + suggestedMethod; + } + + return suggestion; + } + /** * Given a name and a list of symbols whose names are *not* equal to the name, return a spelling suggestion if there is one that is close enough. * Names less than length 3 only check for case-insensitive equality, not levenshtein distance. @@ -20449,11 +20658,24 @@ namespace ts { // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type: Type): Signature | undefined { + return getSingleSignature(type, SignatureKind.Call, /*allowMembers*/ false); + } + + function getSingleCallOrConstructSignature(type: Type): Signature | undefined { + return getSingleSignature(type, SignatureKind.Call, /*allowMembers*/ false) || + getSingleSignature(type, SignatureKind.Construct, /*allowMembers*/ false); + } + + function getSingleSignature(type: Type, kind: SignatureKind, allowMembers: boolean): Signature | undefined { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { - return resolved.callSignatures[0]; + if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (kind === SignatureKind.Call && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + return resolved.callSignatures[0]; + } + if (kind === SignatureKind.Construct && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + return resolved.constructSignatures[0]; + } } } return undefined; @@ -23795,16 +24017,18 @@ namespace ts { function instantiateTypeWithSingleGenericCallSignature(node: Expression | MethodDeclaration | QualifiedName, type: Type, checkMode?: CheckMode) { if (checkMode && checkMode & (CheckMode.Inferential | CheckMode.SkipGenericFunctions)) { - const signature = getSingleCallSignature(type); + const callSignature = getSingleSignature(type, SignatureKind.Call, /*allowMembers*/ true); + const constructSignature = getSingleSignature(type, SignatureKind.Construct, /*allowMembers*/ true); + const signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - if (checkMode & CheckMode.SkipGenericFunctions) { - skippedGenericFunction(node, checkMode); - return anyFunctionType; - } const contextualType = getApparentTypeOfContextualType(node); - if (contextualType) { - const contextualSignature = getSingleCallSignature(getNonNullableType(contextualType)); + if (contextualType && !isMixinConstructorType(contextualType)) { + const contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? SignatureKind.Call : SignatureKind.Construct, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { + if (checkMode & CheckMode.SkipGenericFunctions) { + skippedGenericFunction(node, checkMode); + return anyFunctionType; + } const context = getInferenceContext(node)!; // We have an expression that is an argument of a generic function for which we are performing // type argument inference. The expression is of a function type with a single generic call @@ -23812,7 +24036,8 @@ namespace ts { // if the outer function returns a function type with a single non-generic call signature and // if some of the outer function type parameters have no inferences so far. If so, we can // potentially add inferred type parameters to the outer function return type. - const returnSignature = context.signature && getSingleCallSignature(getReturnTypeOfSignature(context.signature)); + const returnType = context.signature && getReturnTypeOfSignature(context.signature); + const returnSignature = returnType && getSingleCallOrConstructSignature(returnType); if (returnSignature && !returnSignature.typeParameters && !every(context.inferences, hasInferenceCandidates)) { // Instantiate the signature with its own type parameters as type arguments, possibly // renaming the type parameters to ensure they have unique names. @@ -24006,7 +24231,7 @@ namespace ts { function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type { const tag = isInJSFile(node) ? getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression!.type, node.expression, checkMode); + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -26462,14 +26687,28 @@ namespace ts { } // For a binding pattern, validate the initializer and exit if (isBindingPattern(node.name)) { - // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== SyntaxKind.ForInStatement) { - const initializerType = checkExpressionCached(node.initializer); - if (strictNullChecks && node.name.elements.length === 0) { - checkNonNullNonVoidType(initializerType, node); + const needCheckInitializer = node.initializer && node.parent.parent.kind !== SyntaxKind.ForInStatement; + const needCheckWidenedType = node.name.elements.length === 0; + if (needCheckInitializer || needCheckWidenedType) { + // Don't validate for-in initializer as it is already an error + const widenedType = getWidenedTypeForVariableLikeDeclaration(node); + if (needCheckInitializer) { + const initializerType = checkExpressionCached(node.initializer!); + if (strictNullChecks && needCheckWidenedType) { + checkNonNullNonVoidType(initializerType, node); + } + else { + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); + } } - else { - checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); + // check the binding pattern with empty elements + if (needCheckWidenedType) { + if (isArrayBindingPattern(node.name)) { + checkIteratedTypeOrElementType(widenedType, node, /* allowStringInput */ false, /* allowAsyncIterables */ false); + } + else if (strictNullChecks) { + checkNonNullNonVoidType(widenedType, node); + } } } return; @@ -30442,6 +30681,14 @@ namespace ts { continue; } if (!isExternalOrCommonJsModule(file)) { + // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. + // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. + const fileGlobalThisSymbol = file.locals!.get("globalThis" as __String); + if (fileGlobalThisSymbol) { + for (const declaration of fileGlobalThisSymbol.declarations) { + diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); + } + } mergeSymbolTable(globals, file.locals!); } if (file.jsGlobalAugmentations) { @@ -30487,6 +30734,7 @@ namespace ts { getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments" as __String, /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; + getSymbolLinks(globalThisSymbol).type = createObjectType(ObjectFlags.Anonymous, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array" as __String, /*arity*/ 1, /*reportErrors*/ true); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 527217e860e6f..104f3576e3a6d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -45,6 +45,7 @@ namespace ts { ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], ["es2019.array", "lib.es2019.array.d.ts"], + ["es2019.object", "lib.es2019.object.d.ts"], ["es2019.string", "lib.es2019.string.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["es2020.string", "lib.es2020.string.d.ts"], @@ -218,6 +219,7 @@ namespace ts { }), affectsSourceFile: true, affectsModuleResolution: true, + affectsEmit: true, paramType: Diagnostics.VERSION, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, @@ -1345,7 +1347,12 @@ namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined { + export function getParsedCommandLineOfConfigFile( + configFileName: string, + optionsToExtend: CompilerOptions, + host: ParseConfigFileHost, + extendedConfigCache?: Map + ): ParsedCommandLine | undefined { let configFileText: string | undefined; try { configFileText = host.readFile(configFileName); @@ -1366,7 +1373,16 @@ namespace ts { result.path = toPath(configFileName, cwd, createGetCanonicalFileName(host.useCaseSensitiveFileNames)); result.resolvedPath = result.path; result.originalFileName = result.fileName; - return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd)); + return parseJsonSourceFileConfigFileContent( + result, + host, + getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), + optionsToExtend, + getNormalizedAbsolutePath(configFileName, cwd), + /*resolutionStack*/ undefined, + /*extraFileExtension*/ undefined, + extendedConfigCache + ); } /** @@ -1980,8 +1996,8 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { - return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions); + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, /*@internal*/ extendedConfigCache?: Map): ParsedCommandLine { + return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); } /*@internal*/ @@ -2020,11 +2036,12 @@ namespace ts { configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: ReadonlyArray = [], + extendedConfigCache?: Map ): ParsedCommandLine { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; - const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors); + const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache); const { raw } = parsedConfig; const options = extend(existingOptions, parsedConfig.options || {}); options.configFilePath = configFileName && normalizeSlashes(configFileName); @@ -2172,7 +2189,7 @@ namespace ts { return existingErrors !== configParseDiagnostics.length; } - interface ParsedTsconfig { + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -2191,13 +2208,14 @@ namespace ts { * It does *not* resolve the included files. */ function parseConfig( - json: any, - sourceFile: TsConfigSourceFile | undefined, - host: ParseConfigHost, - basePath: string, - configFileName: string | undefined, - resolutionStack: string[], - errors: Push, + json: any, + sourceFile: TsConfigSourceFile | undefined, + host: ParseConfigHost, + basePath: string, + configFileName: string | undefined, + resolutionStack: string[], + errors: Push, + extendedConfigCache?: Map ): ParsedTsconfig { basePath = normalizeSlashes(basePath); const resolvedPath = getNormalizedAbsolutePath(configFileName || "", basePath); @@ -2214,7 +2232,7 @@ namespace ts { if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors); + const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { const baseRaw = extendedConfig.raw; const raw = ownConfig.raw; @@ -2358,6 +2376,11 @@ namespace ts { return undefined; } + export interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } + function getExtendedConfig( sourceFile: TsConfigSourceFile | undefined, extendedConfigPath: string, @@ -2365,40 +2388,53 @@ namespace ts { basePath: string, resolutionStack: string[], errors: Push, + extendedConfigCache?: Map ): ParsedTsconfig | undefined { - const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path)); + const path = host.useCaseSensitiveFileNames ? extendedConfigPath : toLowerCase(extendedConfigPath); + let value: ExtendedConfigCacheEntry | undefined; + let extendedResult: TsConfigSourceFile; + let extendedConfig: ParsedTsconfig | undefined; + if (extendedConfigCache && (value = extendedConfigCache.get(path))) { + ({ extendedResult, extendedConfig } = value); + } + else { + extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path)); + if (!extendedResult.parseDiagnostics.length) { + const extendedDirname = getDirectoryPath(extendedConfigPath); + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, + getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); + + if (isSuccessfulParsedTsconfig(extendedConfig)) { + // Update the paths to reflect base path + const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity); + const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); + const mapPropertiesInRawIfNotUndefined = (propertyName: string) => { + if (raw[propertyName]) { + raw[propertyName] = map(raw[propertyName], updatePath); + } + }; + + const { raw } = extendedConfig; + mapPropertiesInRawIfNotUndefined("include"); + mapPropertiesInRawIfNotUndefined("exclude"); + mapPropertiesInRawIfNotUndefined("files"); + } + } + if (extendedConfigCache) { + extendedConfigCache.set(path, { extendedResult, extendedConfig }); + } + } if (sourceFile) { sourceFile.extendedSourceFiles = [extendedResult.fileName]; + if (extendedResult.extendedSourceFiles) { + sourceFile.extendedSourceFiles.push(...extendedResult.extendedSourceFiles); + } } if (extendedResult.parseDiagnostics.length) { errors.push(...extendedResult.parseDiagnostics); return undefined; } - - const extendedDirname = getDirectoryPath(extendedConfigPath); - const extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, - getBaseFileName(extendedConfigPath), resolutionStack, errors); - if (sourceFile && extendedResult.extendedSourceFiles) { - sourceFile.extendedSourceFiles!.push(...extendedResult.extendedSourceFiles); - } - - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity); - const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); - const mapPropertiesInRawIfNotUndefined = (propertyName: string) => { - if (raw[propertyName]) { - raw[propertyName] = map(raw[propertyName], updatePath); - } - }; - - const { raw } = extendedConfig; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } - - return extendedConfig; + return extendedConfig!; } function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Push): boolean { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b3839842d3e60..8d2f01f3de27a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2284,4 +2284,29 @@ namespace ts { } return result; } + + export function cartesianProduct(arrays: readonly T[][]) { + const result: T[][] = []; + cartesianProductWorker(arrays, result, /*outer*/ undefined, 0); + return result; + } + + function cartesianProductWorker(arrays: readonly (readonly T[])[], result: (readonly T[])[], outer: readonly T[] | undefined, index: number) { + for (const element of arrays[index]) { + let inner: T[]; + if (outer) { + inner = outer.slice(); + inner.push(element); + } + else { + inner = [element]; + } + if (index === arrays.length - 1) { + result.push(inner); + } + else { + cartesianProductWorker(arrays, result, inner, index + 1); + } + } + } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 45ec2a9ad427a..75a21022adbe9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3096,6 +3096,10 @@ "category": "Error", "code": 5074 }, + "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'.": { + "category": "Error", + "code": 5075 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", @@ -4272,7 +4276,10 @@ "category": "Error", "code": 7051 }, - + "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?": { + "category": "Error", + "code": 7052 + }, "You cannot rename this element.": { "category": "Error", "code": 8000 diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3742f2d5fdf11..f562a6b5d12be 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2189,7 +2189,7 @@ namespace ts { } /* @internal */ - export function createJSDocTypeTag(typeExpression?: JSDocTypeExpression, comment?: string): JSDocTypeTag { + export function createJSDocTypeTag(typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag { const tag = createJSDocTag(SyntaxKind.JSDocTypeTag, "type"); tag.typeExpression = typeExpression; tag.comment = comment; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 481a601118edb..a86dba52c87af 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6855,7 +6855,7 @@ namespace ts { } function parseReturnTag(start: number, tagName: Identifier): JSDocReturnTag { - if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) { + if (some(tags, isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText); } @@ -6866,7 +6866,7 @@ namespace ts { } function parseTypeTag(start: number, tagName: Identifier): JSDocTypeTag { - if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) { + if (some(tags, isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText); } @@ -7782,24 +7782,9 @@ namespace ts { /*@internal*/ export function processCommentPragmas(context: PragmaContext, sourceText: string): void { - const triviaScanner = createScanner(context.languageVersion, /*skipTrivia*/ false, LanguageVariant.Standard, sourceText); const pragmas: PragmaPseudoMapEntry[] = []; - // Keep scanning all the leading trivia in the file until we get to something that - // isn't trivia. Any single line comment will be analyzed to see if it is a - // reference comment. - while (true) { - const kind = triviaScanner.scan(); - if (!isTrivia(kind)) { - break; - } - - const range = { - kind: triviaScanner.getToken(), - pos: triviaScanner.getTokenPos(), - end: triviaScanner.getTextPos(), - }; - + for (const range of getLeadingCommentRanges(sourceText, 0) || emptyArray) { const comment = sourceText.substring(range.pos, range.end); extractPragmas(pragmas, range, comment); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 358cabcecb1c5..7e01e56f0693d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2678,18 +2678,32 @@ namespace ts { return fromCache || undefined; } - // An absolute path pointing to the containing directory of the config file - const basePath = getNormalizedAbsolutePath(getDirectoryPath(refPath), host.getCurrentDirectory()); - const sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile | undefined; - addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); - if (sourceFile === undefined) { - projectReferenceRedirects.set(sourceFilePath, false); - return undefined; + let commandLine: ParsedCommandLine | undefined; + let sourceFile: JsonSourceFile | undefined; + if (host.getParsedCommandLine) { + commandLine = host.getParsedCommandLine(refPath); + if (!commandLine) { + addFileToFilesByName(/*sourceFile*/ undefined, sourceFilePath, /*redirectedPath*/ undefined); + projectReferenceRedirects.set(sourceFilePath, false); + return undefined; + } + sourceFile = Debug.assertDefined(commandLine.options.configFile); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); + } + else { + // An absolute path pointing to the containing directory of the config file + const basePath = getNormalizedAbsolutePath(getDirectoryPath(refPath), host.getCurrentDirectory()); + sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile | undefined; + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); + if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); + return undefined; + } + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; + commandLine = parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); } - sourceFile.path = sourceFilePath; - sourceFile.resolvedPath = sourceFilePath; - sourceFile.originalFileName = refPath; - const commandLine = parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); const resolvedRef: ResolvedProjectReference = { commandLine, sourceFile }; projectReferenceRedirects.set(sourceFilePath, resolvedRef); if (commandLine.projectReferences) { diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 6eb5cc3e8f2ea..a5eae8922da30 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -399,6 +399,7 @@ namespace ts { let projectCompilerOptions = baseCompilerOptions; const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions); setGetSourceFileAsHashVersioned(compilerHost, host); + compilerHost.getParsedCommandLine = parseConfigFile; compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); @@ -415,6 +416,7 @@ namespace ts { } | undefined; const buildInfoChecked = createFileMap(toPath); + const extendedConfigCache = createMap(); // Watch state const builderPrograms = createFileMap(toPath); @@ -491,7 +493,7 @@ namespace ts { let diagnostic: Diagnostic | undefined; parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = d => diagnostic = d; - const parsed = getParsedCommandLineOfConfigFile(configFilePath, baseCompilerOptions, parseConfigFileHost); + const parsed = getParsedCommandLineOfConfigFile(configFilePath, baseCompilerOptions, parseConfigFileHost, extendedConfigCache); parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = noop; configFileCache.setValue(configFilePath, parsed || diagnostic!); return parsed; @@ -1439,6 +1441,7 @@ namespace ts { compilerHost.getSourceFile = cacheState.originalGetSourceFile; readFileWithCache = cacheState.originalReadFileWithCache; compilerHost.resolveModuleNames = cacheState.originalResolveModuleNames; + extendedConfigCache.clear(); if (moduleResolutionCache) { moduleResolutionCache.directoryToModuleNameMap.clear(); moduleResolutionCache.moduleNameToDirectoryMap.clear(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 62d0f27a6981b..5e2d6aba474ee 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2482,7 +2482,7 @@ namespace ts { export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression?: JSDocTypeExpression; + typeExpression: JSDocTypeExpression; } export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { @@ -5131,6 +5131,7 @@ namespace ts { /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution; /* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; // TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesnt use compilerHost as base /*@internal*/createDirectory?(directory: string): void; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 188f2f8630209..45dc980296be7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3960,6 +3960,16 @@ namespace ts { return isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } + export function tryGetPropertyAccessOrIdentifierToString(expr: Expression): string | undefined { + if (isPropertyAccessExpression(expr)) { + return tryGetPropertyAccessOrIdentifierToString(expr.expression) + "." + expr.name; + } + if (isIdentifier(expr)) { + return unescapeLeadingUnderscores(expr.escapedText); + } + return undefined; + } + export function isPrototypeAccess(node: Node): node is PropertyAccessExpression { return isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; } diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index ccada2e0069c9..4d48d5cf40aaf 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -9,7 +9,7 @@ interface Array { * predicate. If it is not provided, undefined is used instead. */ find(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -20,7 +20,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -330,7 +330,7 @@ interface ReadonlyArray { * predicate. If it is not provided, undefined is used instead. */ find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -341,7 +341,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): number; } interface RegExp { diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index 2a98f215193a0..83776137c33c1 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -98,79 +98,15 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + race(values: T[]): Promise ? U : T>; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. + * @param values An iterable of Promises. * @returns A new Promise. */ - race(values: (T | PromiseLike)[]): Promise; + race(values: Iterable): Promise ? U : T>; /** * Creates a new rejected promise for the provided reason. diff --git a/src/lib/es2019.d.ts b/src/lib/es2019.d.ts index b25f9e1d76af9..29212ecfe0f1b 100644 --- a/src/lib/es2019.d.ts +++ b/src/lib/es2019.d.ts @@ -1,4 +1,5 @@ /// /// +/// /// /// diff --git a/src/lib/es2019.object.d.ts b/src/lib/es2019.object.d.ts new file mode 100644 index 0000000000000..69b185d7ca91c --- /dev/null +++ b/src/lib/es2019.object.d.ts @@ -0,0 +1,15 @@ +/// + +interface ObjectConstructor { + /** + * Returns an object created by key-value entries for properties and methods + * @param entries An iterable object that contains key-value entries for properties and methods. + */ + fromEntries(entries: Iterable): { [k in PropertyKey]: T }; + + /** + * Returns an object created by key-value entries for properties and methods + * @param entries An iterable object that contains key-value entries for properties and methods. + */ + fromEntries(entries: Iterable): any; +} diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 994fb1d765330..827c2aaddd50c 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -60,7 +60,7 @@ declare function encodeURI(uri: string): string; * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ -declare function encodeURIComponent(uriComponent: string): string; +declare function encodeURIComponent(uriComponent: string | number | boolean): string; /** * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. @@ -513,7 +513,7 @@ interface Boolean { interface BooleanConstructor { new(value?: any): Boolean; - (value?: any): boolean; + (value?: T): value is Exclude; readonly prototype: Boolean; } @@ -1273,13 +1273,13 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. @@ -1303,7 +1303,7 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; + filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. diff --git a/src/lib/libs.json b/src/lib/libs.json index 74611a938609c..ac2f2db5b6bb0 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -36,6 +36,7 @@ "es2018.promise", "es2018.intl", "es2019.array", + "es2019.object", "es2019.string", "es2019.symbol", "es2020.string", diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 8016b0e9ff655..f14a3a1e5d528 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -134,7 +134,7 @@ namespace ts.JsDoc { case SyntaxKind.JSDocTemplateTag: return withList((tag as JSDocTemplateTag).typeParameters); case SyntaxKind.JSDocTypeTag: - return withNode((tag as JSDocTypeTag).typeExpression!); + return withNode((tag as JSDocTypeTag).typeExpression); case SyntaxKind.JSDocTypedefTag: case SyntaxKind.JSDocCallbackTag: case SyntaxKind.JSDocPropertyTag: diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 450b27e01ed4f..3c033d658ef6c 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, diff --git a/src/testRunner/unittests/tsbuild/helpers.ts b/src/testRunner/unittests/tsbuild/helpers.ts index 88eb61cd422c4..579573a876e6e 100644 --- a/src/testRunner/unittests/tsbuild/helpers.ts +++ b/src/testRunner/unittests/tsbuild/helpers.ts @@ -62,7 +62,7 @@ namespace ts { } } - const libContent = `${TestFSWithWatch.libFile.content} + export const libContent = `${TestFSWithWatch.libFile.content} interface ReadonlyArray {} declare const console: { log(msg: any): void; };`; diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index 6e31ada9ee575..5ad63d76dc7ee 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -279,7 +279,6 @@ namespace ts { [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.json"], [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] ); }); @@ -309,8 +308,7 @@ namespace ts { [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"], [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.base.json"], - [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"] ); }); }); @@ -761,6 +759,56 @@ class someClass { }`), baselineOnly: true, verifyDiagnostics: true }); + + verifyTsbuildOutput({ + scenario: "when target option changes", + projFs: () => projFs, + time, + tick, + proj: "sample1", + rootNames: ["/src/core"], + expectedMapFileNames: emptyArray, + lastProjectOutputJs: "/src/core/index.js", + initialBuild: { + modifyFs: fs => { + fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// +/// `); + fs.writeFileSync("/lib/lib.esnext.d.ts", libContent); + fs.writeFileSync("/lib/lib.d.ts", `/// +/// `); + fs.writeFileSync("/src/core/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, +"listFiles": true, +"listEmittedFiles": true, + "target": "esnext", + } +}`); + }, + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], + ] + }, + incrementalDtsChangedBuild: { + modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"), + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/tsconfig.json"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"] + ] + }, + outputFiles: [ + "/src/core/anotherModule.js", + "/src/core/anotherModule.d.ts", + "/src/core/index.js", + "/src/core/index.d.ts", + "/src/core/tsconfig.tsbuildinfo", + ], + baselineOnly: true, + verifyDiagnostics: true + }); }); }); } diff --git a/tests/baselines/reference/1.0lib-noErrors.js b/tests/baselines/reference/1.0lib-noErrors.js index ade0f4bf903b9..3dac98d9e5647 100644 --- a/tests/baselines/reference/1.0lib-noErrors.js +++ b/tests/baselines/reference/1.0lib-noErrors.js @@ -78,7 +78,7 @@ declare function encodeURI(uri: string): string; * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ -declare function encodeURIComponent(uriComponent: string): string; +declare function encodeURIComponent(uriComponent: string | number | boolean): string; interface PropertyDescriptor { configurable?: boolean; @@ -1141,7 +1141,7 @@ declare var Array: { (...items: T[]): T[]; isArray(arg: any): boolean; prototype: Array; -} +} //// [1.0lib-noErrors.js] /* ***************************************************************************** diff --git a/tests/baselines/reference/1.0lib-noErrors.symbols b/tests/baselines/reference/1.0lib-noErrors.symbols index adedbdb9aa2dc..d67952e201c98 100644 --- a/tests/baselines/reference/1.0lib-noErrors.symbols +++ b/tests/baselines/reference/1.0lib-noErrors.symbols @@ -98,12 +98,12 @@ declare function encodeURI(uri: string): string; * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ -declare function encodeURIComponent(uriComponent: string): string; +declare function encodeURIComponent(uriComponent: string | number | boolean): string; >encodeURIComponent : Symbol(encodeURIComponent, Decl(1.0lib-noErrors.ts, 73, 48)) >uriComponent : Symbol(uriComponent, Decl(1.0lib-noErrors.ts, 79, 36)) interface PropertyDescriptor { ->PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 85)) configurable?: boolean; >configurable : Symbol(PropertyDescriptor.configurable, Decl(1.0lib-noErrors.ts, 81, 30)) @@ -130,7 +130,7 @@ interface PropertyDescriptorMap { [s: string]: PropertyDescriptor; >s : Symbol(s, Decl(1.0lib-noErrors.ts, 91, 5)) ->PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 85)) } interface Object { @@ -217,7 +217,7 @@ declare var Object: { >getOwnPropertyDescriptor : Symbol(getOwnPropertyDescriptor, Decl(1.0lib-noErrors.ts, 141, 32)) >o : Symbol(o, Decl(1.0lib-noErrors.ts, 149, 29)) >p : Symbol(p, Decl(1.0lib-noErrors.ts, 149, 36)) ->PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 85)) /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly @@ -250,7 +250,7 @@ declare var Object: { >o : Symbol(o, Decl(1.0lib-noErrors.ts, 171, 19)) >p : Symbol(p, Decl(1.0lib-noErrors.ts, 171, 26)) >attributes : Symbol(attributes, Decl(1.0lib-noErrors.ts, 171, 37)) ->PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 85)) /** * Adds one or more properties to an object, and/or modifies attributes of existing properties. @@ -2084,3 +2084,4 @@ declare var Array: { >prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 1140, 31)) >Array : Symbol(Array, Decl(1.0lib-noErrors.ts, 973, 23), Decl(1.0lib-noErrors.ts, 1133, 11)) } + diff --git a/tests/baselines/reference/1.0lib-noErrors.types b/tests/baselines/reference/1.0lib-noErrors.types index 1d9c67834e702..91e5fdc7b7356 100644 --- a/tests/baselines/reference/1.0lib-noErrors.types +++ b/tests/baselines/reference/1.0lib-noErrors.types @@ -98,9 +98,9 @@ declare function encodeURI(uri: string): string; * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ -declare function encodeURIComponent(uriComponent: string): string; ->encodeURIComponent : (uriComponent: string) => string ->uriComponent : string +declare function encodeURIComponent(uriComponent: string | number | boolean): string; +>encodeURIComponent : (uriComponent: string | number | boolean) => string +>uriComponent : string | number | boolean interface PropertyDescriptor { configurable?: boolean; @@ -1911,3 +1911,4 @@ declare var Array: { prototype: Array; >prototype : any[] } + diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index f9f0e726dde3f..77fab3209e193 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -24,11 +24,11 @@ class Board { return this.ships.every(function (val) { return val.isSunk; }); >this.ships.every(function (val) { return val.isSunk; }) : boolean ->this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any) => boolean >this.ships : Ship[] >this : this >ships : Ship[] ->every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any) => boolean >function (val) { return val.isSunk; } : (val: Ship) => boolean >val : Ship >val.isSunk : boolean diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.errors.txt new file mode 100644 index 0000000000000..7cc9f3617c034 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/ambient/testB.ts(1,22): error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. + + +==== tests/cases/conformance/ambient/types.ts (0 errors) ==== + declare module "*.foo" { + let everywhere: string; + } + + +==== tests/cases/conformance/ambient/testA.ts (0 errors) ==== + import { everywhere, onlyInA } from "a.foo"; + declare module "a.foo" { + let onlyInA: number; + } + +==== tests/cases/conformance/ambient/testB.ts (1 errors) ==== + import { everywhere, onlyInA } from "b.foo"; // Error + ~~~~~~~ +!!! error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. + \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js new file mode 100644 index 0000000000000..56abd8298cdf2 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging1.ts] //// + +//// [types.ts] +declare module "*.foo" { + let everywhere: string; +} + + +//// [testA.ts] +import { everywhere, onlyInA } from "a.foo"; +declare module "a.foo" { + let onlyInA: number; +} + +//// [testB.ts] +import { everywhere, onlyInA } from "b.foo"; // Error + + +//// [types.js] +//// [testA.js] +"use strict"; +exports.__esModule = true; +//// [testB.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.symbols new file mode 100644 index 0000000000000..aba5c7e23f142 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0)) + + let everywhere: string; +>everywhere : Symbol(everywhere, Decl(types.ts, 1, 5)) +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA } from "a.foo"; +>everywhere : Symbol(everywhere, Decl(testA.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 0, 20)) + +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(testA.ts, 0, 44), Decl(types.ts, 0, 0)) + + let onlyInA: number; +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 2, 5)) +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA } from "b.foo"; // Error +>everywhere : Symbol(everywhere, Decl(testB.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testB.ts, 0, 20)) + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.types b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.types new file mode 100644 index 0000000000000..4e3f190f16261 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : typeof import("*.foo") + + let everywhere: string; +>everywhere : string +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA } from "a.foo"; +>everywhere : string +>onlyInA : number + +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + let onlyInA: number; +>onlyInA : number +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA } from "b.foo"; // Error +>everywhere : string +>onlyInA : any + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.errors.txt new file mode 100644 index 0000000000000..67c44a528b534 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/ambient/testB.ts(1,22): error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. +tests/cases/conformance/ambient/testB.ts(1,31): error TS2305: Module '"*.foo"' has no exported member 'alsoOnlyInA'. + + +==== tests/cases/conformance/ambient/types.ts (0 errors) ==== + declare module "*.foo" { + let everywhere: string; + } + + +==== tests/cases/conformance/ambient/testA.ts (0 errors) ==== + import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; + declare module "a.foo" { + let onlyInA: number; + } + +==== tests/cases/conformance/ambient/testB.ts (2 errors) ==== + import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error + ~~~~~~~ +!!! error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. + ~~~~~~~~~~~ +!!! error TS2305: Module '"*.foo"' has no exported member 'alsoOnlyInA'. + declare module "a.foo" { + let alsoOnlyInA: number; + } \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js new file mode 100644 index 0000000000000..65726bba7225e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js @@ -0,0 +1,27 @@ +//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging2.ts] //// + +//// [types.ts] +declare module "*.foo" { + let everywhere: string; +} + + +//// [testA.ts] +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +declare module "a.foo" { + let onlyInA: number; +} + +//// [testB.ts] +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +declare module "a.foo" { + let alsoOnlyInA: number; +} + +//// [types.js] +//// [testA.js] +"use strict"; +exports.__esModule = true; +//// [testB.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.symbols new file mode 100644 index 0000000000000..447cd999c981e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0)) + + let everywhere: string; +>everywhere : Symbol(everywhere, Decl(types.ts, 1, 5)) +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +>everywhere : Symbol(everywhere, Decl(testA.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 0, 20)) +>alsoOnlyInA : Symbol(alsoOnlyInA, Decl(testA.ts, 0, 29)) + +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(testA.ts, 0, 57), Decl(types.ts, 0, 0), Decl(testB.ts, 0, 57)) + + let onlyInA: number; +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 2, 5)) +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +>everywhere : Symbol(everywhere, Decl(testB.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testB.ts, 0, 20)) +>alsoOnlyInA : Symbol(alsoOnlyInA, Decl(testB.ts, 0, 29)) + +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(testA.ts, 0, 57), Decl(types.ts, 0, 0), Decl(testB.ts, 0, 57)) + + let alsoOnlyInA: number; +>alsoOnlyInA : Symbol(alsoOnlyInA, Decl(testB.ts, 2, 5)) +} diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.types b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.types new file mode 100644 index 0000000000000..b4f0d50db1989 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : typeof import("*.foo") + + let everywhere: string; +>everywhere : string +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +>everywhere : string +>onlyInA : number +>alsoOnlyInA : number + +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + let onlyInA: number; +>onlyInA : number +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +>everywhere : string +>onlyInA : any +>alsoOnlyInA : any + +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + let alsoOnlyInA: number; +>alsoOnlyInA : number +} diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.errors.txt new file mode 100644 index 0000000000000..ce32367fd3cf3 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/ambient/test.ts(6,6): error TS2339: Property 'a' does not exist on type 'OhNo'. + + +==== tests/cases/conformance/ambient/types.ts (0 errors) ==== + declare module "*.foo" { + export interface OhNo { star: string } + } + +==== tests/cases/conformance/ambient/test.ts (1 errors) ==== + declare module "a.foo" { + export interface OhNo { a: string } + } + import { OhNo } from "b.foo" + declare let ohno: OhNo; + ohno.a // oh no + ~ +!!! error TS2339: Property 'a' does not exist on type 'OhNo'. + \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.js new file mode 100644 index 0000000000000..763f0e94bdb56 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging3.ts] //// + +//// [types.ts] +declare module "*.foo" { + export interface OhNo { star: string } +} + +//// [test.ts] +declare module "a.foo" { + export interface OhNo { a: string } +} +import { OhNo } from "b.foo" +declare let ohno: OhNo; +ohno.a // oh no + + +//// [types.js] +//// [test.js] +"use strict"; +exports.__esModule = true; +ohno.a; // oh no diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.symbols new file mode 100644 index 0000000000000..141a17b698909 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0)) + + export interface OhNo { star: string } +>OhNo : Symbol(OhNo, Decl(types.ts, 0, 24)) +>star : Symbol(OhNo.star, Decl(types.ts, 1, 25)) +} + +=== tests/cases/conformance/ambient/test.ts === +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(test.ts, 0, 0), Decl(types.ts, 0, 0)) + + export interface OhNo { a: string } +>OhNo : Symbol(OhNo, Decl(test.ts, 0, 24), Decl(types.ts, 0, 24)) +>a : Symbol(OhNo.a, Decl(test.ts, 1, 25)) +} +import { OhNo } from "b.foo" +>OhNo : Symbol(OhNo, Decl(test.ts, 3, 8)) + +declare let ohno: OhNo; +>ohno : Symbol(ohno, Decl(test.ts, 4, 11)) +>OhNo : Symbol(OhNo, Decl(test.ts, 3, 8)) + +ohno.a // oh no +>ohno : Symbol(ohno, Decl(test.ts, 4, 11)) + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.types b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.types new file mode 100644 index 0000000000000..df731d94fc96a --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : typeof import("*.foo") + + export interface OhNo { star: string } +>star : string +} + +=== tests/cases/conformance/ambient/test.ts === +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + export interface OhNo { a: string } +>a : string +} +import { OhNo } from "b.foo" +>OhNo : any + +declare let ohno: OhNo; +>ohno : OhNo + +ohno.a // oh no +>ohno.a : any +>ohno : OhNo +>a : any + diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 66b2839b89baf..fb95102e79126 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1603,7 +1603,7 @@ declare namespace ts { } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression?: JSDocTypeExpression; + typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -2761,6 +2761,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } interface SourceMapRange extends TextRange { source?: SourceMapSource; @@ -3632,7 +3633,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -3674,7 +3675,20 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, /*@internal*/ extendedConfigCache?: Map): ParsedCommandLine; + interface ParsedTsconfig { + raw: any; + options?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; + } + interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index bf3ad5a7e35ec..170cb00b9e879 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1603,7 +1603,7 @@ declare namespace ts { } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression?: JSDocTypeExpression; + typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -2761,6 +2761,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } interface SourceMapRange extends TextRange { source?: SourceMapSource; @@ -3632,7 +3633,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -3674,7 +3675,20 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, /*@internal*/ extendedConfigCache?: Map): ParsedCommandLine; + interface ParsedTsconfig { + raw: any; + options?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; + } + interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index 7d91ef4ed322b..97c94995e5d5f 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -22,9 +22,9 @@ var foo = [ foo.filter(x => x.name); //should accepted all possible types not only boolean! >foo.filter(x => x.name) : { name: string; }[] ->foo.filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any): { name: string; }[]; } +>foo.filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => unknown, thisArg?: any): { name: string; }[]; } >foo : { name: string; }[] ->filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any): { name: string; }[]; } +>filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => unknown, thisArg?: any): { name: string; }[]; } >x => x.name : (x: { name: string; }) => string >x : { name: string; } >x.name : string diff --git a/tests/baselines/reference/arrayFind.types b/tests/baselines/reference/arrayFind.types index 530f07be3f829..12eead1630cb8 100644 --- a/tests/baselines/reference/arrayFind.types +++ b/tests/baselines/reference/arrayFind.types @@ -24,9 +24,9 @@ const arrayOfStringsNumbersAndBooleans = ["string", false, 0, "strung", 1, true] const foundNumber: number | undefined = arrayOfStringsNumbersAndBooleans.find(isNumber); >foundNumber : number >arrayOfStringsNumbersAndBooleans.find(isNumber) : number ->arrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>arrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >arrayOfStringsNumbersAndBooleans : (string | number | boolean)[] ->find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >isNumber : (x: any) => x is number const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBooleans as ReadonlyArray; @@ -37,8 +37,8 @@ const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBoolean const readonlyFoundNumber: number | undefined = readonlyArrayOfStringsNumbersAndBooleans.find(isNumber); >readonlyFoundNumber : number >readonlyArrayOfStringsNumbersAndBooleans.find(isNumber) : number ->readonlyArrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>readonlyArrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >readonlyArrayOfStringsNumbersAndBooleans : readonly (string | number | boolean)[] ->find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >isNumber : (x: any) => x is number diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt index aeab178743988..a0c856cae96f7 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt @@ -14,24 +14,30 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(62,1): error TS2322: Type '(x: (arg: Base) => Derived) => Base' is not assignable to type '(x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(65,1): error TS2322: Type '(x: (arg: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(68,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(71,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(74,1): error TS2322: Type '(...x: Derived[]) => Derived' is not assignable to type '(...x: T[]) => T'. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(77,1): error TS2322: Type '(x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type '(x: T, y: T) => T'. Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type '{ foo: string; bar: string; }'. @@ -43,6 +49,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'Base' is missing the following properties from type 'Derived2': baz, bar tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. + 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(85,1): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. @@ -136,6 +143,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b6: (x: (arg: T) => U) => T; a6 = b6; // ok b6 = a6; // ok @@ -144,6 +152,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b7: (x: (arg: T) => U) => (r: T) => U; a7 = b7; // ok b7 = a7; // ok @@ -152,6 +161,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; a8 = b8; // ok b8 = a8; // ok @@ -160,6 +170,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b9: (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; a9 = b9; // ok b9 = a9; // ok @@ -168,12 +179,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: (...x: T[]) => T; a10 = b10; // ok b10 = a10; // ok ~~~ !!! error TS2322: Type '(...x: Derived[]) => Derived' is not assignable to type '(...x: T[]) => T'. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. var b11: (x: T, y: T) => T; a11 = b11; // ok b11 = a11; // ok @@ -198,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. +!!! error TS2322: 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. var b14: (x: { a: T; b: T }) => T; a14 = b14; // ok ~~~ diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 0a2ae4789895f..ecc1dbd848f99 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. Types of parameters 'arg2' and 'arg2' are incompatible. @@ -15,6 +16,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(58,9): error TS2322: Type '(...x: Base[]) => Base' is not assignable to type '(...x: T[]) => T'. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(62,9): error TS2322: Type '(x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type '(x: T, y: T) => T'. @@ -45,6 +47,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(89,9): error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(90,9): error TS2322: Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. Type 'T[]' is not assignable to type 'string[]'. Type 'T' is not assignable to type 'string'. @@ -54,6 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(96,9): error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (15 errors) ==== @@ -115,6 +119,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; a8 = b8; // error, { foo: number } and Base are incompatible @@ -131,6 +136,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: (...x: T[]) => T; @@ -205,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b2 = a2; ~~ !!! error TS2322: Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. @@ -224,5 +231,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt index 57944ae986389..d3bb6e0b2e262 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt @@ -5,11 +5,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(55,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. Types of property 'b' are incompatible. Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(58,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -79,6 +81,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b15: (x: { a: U; b: V; }) => U[]; a15 = b15; // ok, T = U, T = V b15 = a15; // ok @@ -88,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. !!! error TS2322: Types of property 'b' are incompatible. !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var b16: (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt index e3d7fda7ba35f..c26a01c3a5127 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(42,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -61,6 +62,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b16: (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt index 1db469b6a4fa7..52b7a9280a537 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt @@ -14,24 +14,30 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(62,1): error TS2322: Type 'new (x: (arg: Base) => Derived) => Base' is not assignable to type 'new (x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(65,1): error TS2322: Type 'new (x: (arg: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(68,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(71,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(74,1): error TS2322: Type 'new (...x: Derived[]) => Derived' is not assignable to type 'new (...x: T[]) => T'. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(77,1): error TS2322: Type 'new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type 'new (x: T, y: T) => T'. Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type '{ foo: string; bar: string; }'. @@ -43,6 +49,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'Base' is missing the following properties from type 'Derived2': baz, bar tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. + 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(85,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. @@ -136,6 +143,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b6: new (x: (arg: T) => U) => T; a6 = b6; // ok b6 = a6; // ok @@ -144,6 +152,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b7: new (x: (arg: T) => U) => (r: T) => U; a7 = b7; // ok b7 = a7; // ok @@ -152,6 +161,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: new (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; a8 = b8; // ok b8 = a8; // ok @@ -160,6 +170,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b9: new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; a9 = b9; // ok b9 = a9; // ok @@ -168,12 +179,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: new (...x: T[]) => T; a10 = b10; // ok b10 = a10; // ok ~~~ !!! error TS2322: Type 'new (...x: Derived[]) => Derived' is not assignable to type 'new (...x: T[]) => T'. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. var b11: new (x: T, y: T) => T; a11 = b11; // ok b11 = a11; // ok @@ -198,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. +!!! error TS2322: 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. var b14: new (x: { a: T; b: T }) => T; a14 = b14; // ok ~~~ diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 620e83e1603b8..fb9ba55b5efcb 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(52,9): error TS2322: Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. Types of parameters 'arg2' and 'arg2' are incompatible. @@ -15,6 +16,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(58,9): error TS2322: Type 'new (...x: Base[]) => Base' is not assignable to type 'new (...x: T[]) => T'. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(62,9): error TS2322: Type 'new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type 'new (x: T, y: T) => T'. @@ -61,6 +63,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(89,9): error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(90,9): error TS2322: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. Type 'T[]' is not assignable to type 'string[]'. Type 'T' is not assignable to type 'string'. @@ -70,6 +73,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(96,9): error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts (19 errors) ==== @@ -131,6 +135,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; a8 = b8; // error, type mismatch @@ -147,6 +152,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: new (...x: T[]) => T; @@ -241,6 +247,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b2 = a2; // ok ~~ !!! error TS2322: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. @@ -260,5 +267,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt index 5445d9ee35a14..bfd92f7e93004 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt @@ -5,11 +5,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(55,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. Types of property 'b' are incompatible. Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(58,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -79,6 +81,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b15: new (x: { a: U; b: V; }) => U[]; a15 = b15; // ok b15 = a15; // ok @@ -88,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. !!! error TS2322: Types of property 'b' are incompatible. !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var b16: new (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt index 399a56e413659..1397dfe528b1f 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(42,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -61,6 +62,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b16: new (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt new file mode 100644 index 0000000000000..e5e3ee8b49992 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt @@ -0,0 +1,224 @@ +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts(44,5): error TS2322: Type 'S' is not assignable to type 'T'. + Type 'S' is not assignable to type '{ a: 2; b: 3; }'. + Types of property 'a' are incompatible. + Type '0 | 2' is not assignable to type '2'. + Type '0' is not assignable to type '2'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts(58,5): error TS2322: Type 'S' is not assignable to type 'T'. + Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 4 | 3; c: string; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts(82,5): error TS2322: Type 'S' is not assignable to type 'T'. + Type 'S' is not assignable to type '{ a: 0 | 2 | 1; b: 0 | 2 | 1; c: 2; }'. + Types of property 'c' are incompatible. + Type '0 | 2 | 1' is not assignable to type '2'. + Type '0' is not assignable to type '2'. + + +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts (3 errors) ==== + // see 'typeRelatedToDiscriminatedType' in checker.ts: + + // IteratorResult + namespace Example1 { + type S = { done: boolean, value: number }; + type T = + | { done: true, value: number } // T0 + | { done: false, value: number }; // T1 + + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; + } + + // Dropping constituents of T + namespace Example2 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; + } + + // Unmatched discriminants + namespace Example3 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 | 4 } // T1 + | { a: 2, b: 3 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: Type 'S' is not assignable to type '{ a: 2; b: 3; }'. +!!! error TS2322: Types of property 'a' are incompatible. +!!! error TS2322: Type '0 | 2' is not assignable to type '2'. +!!! error TS2322: Type '0' is not assignable to type '2'. + } + + // Unmatched non-discriminants + namespace Example4 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4, c: string }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 4 | 3; c: string; }'. +!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts:52:36: 'c' is declared here. + } + + // Maximum discriminant combinations + namespace Example5 { + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; + type S = { a: N, b: N, c: N }; + type T = { a: 0, b: N, c: N } + | { a: 1, b: N, c: N } + | { a: 2, b: N, c: N } + | { a: N, b: 0, c: N } + | { a: N, b: 1, c: N } + | { a: N, b: 2, c: N } + | { a: N, b: N, c: 0 } + | { a: N, b: N, c: 1 } + | { a: N, b: N, c: 2 }; + declare let s: S; + declare let t: T; + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: Type 'S' is not assignable to type '{ a: 0 | 2 | 1; b: 0 | 2 | 1; c: 2; }'. +!!! error TS2322: Types of property 'c' are incompatible. +!!! error TS2322: Type '0 | 2 | 1' is not assignable to type '2'. +!!! error TS2322: Type '0' is not assignable to type '2'. + } + + // https://github.com/Microsoft/TypeScript/issues/14865 + namespace GH14865 { + type Style1 = { + type: "A"; + data: string; + } | { + type: "B"; + data: string; + }; + + type Style2 = { + type: "A" | "B"; + data: string; + } + + const a: Style2 = { type: "A", data: "whatevs" }; + let b: Style1; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable + } + + // https://github.com/Microsoft/TypeScript/issues/30170 + namespace GH30170 { + interface Blue { + color: 'blue' + } + interface Yellow { + color?: 'yellow', + } + function draw(val: Blue | Yellow) { } + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { + return draw({ color: currentColor }); + } + } + + // https://github.com/Microsoft/TypeScript/issues/12052 + namespace GH12052 { + interface ILinearAxis { type: "linear"; } + + interface ICategoricalAxis { type: "categorical"; } + + type IAxis = ILinearAxis | ICategoricalAxis; + type IAxisType = "linear" | "categorical"; + + function getAxisType(): IAxisType { + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; + const good: IAxis = { type: undefined }; + good.type = getAxisType(); + } + + // https://github.com/Microsoft/TypeScript/issues/18421 + namespace GH18421 { + interface ThingTypeOne { + type: 'one'; + } + + interface ThingTypeTwo { + type: 'two'; + } + + type ThingType = 'one' | 'two'; + + type Thing = ThingTypeOne | ThingTypeTwo; + + function makeNewThing(thingType: ThingType): Thing { + return { + type: thingType + }; + } + } + + // https://github.com/Microsoft/TypeScript/issues/15907 + namespace GH15907 { + type Action = { type: 'activate' } | { type: 'disactivate' }; + + function dispatchAction(action: Action): void { + + } + + const active = true; + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); + } + + // https://github.com/Microsoft/TypeScript/issues/20889 + namespace GH20889 { + interface A1 { + type: "A1"; + } + interface A2 { + type: "A2"; + } + type AU = A1 | A2; + + function foo(obj1: AU) { + const obj2: AU = { + type: obj1.type + }; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js new file mode 100644 index 0000000000000..2719a525ba7a5 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js @@ -0,0 +1,291 @@ +//// [assignmentCompatWithDiscriminatedUnion.ts] +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { + type S = { done: boolean, value: number }; + type T = + | { done: true, value: number } // T0 + | { done: false, value: number }; // T1 + + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +} + +// Dropping constituents of T +namespace Example2 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +} + +// Unmatched discriminants +namespace Example3 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 | 4 } // T1 + | { a: 2, b: 3 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +} + +// Unmatched non-discriminants +namespace Example4 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4, c: string }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +} + +// Maximum discriminant combinations +namespace Example5 { + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; + type S = { a: N, b: N, c: N }; + type T = { a: 0, b: N, c: N } + | { a: 1, b: N, c: N } + | { a: 2, b: N, c: N } + | { a: N, b: 0, c: N } + | { a: N, b: 1, c: N } + | { a: N, b: 2, c: N } + | { a: N, b: N, c: 0 } + | { a: N, b: N, c: 1 } + | { a: N, b: N, c: 2 }; + declare let s: S; + declare let t: T; + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { + type Style1 = { + type: "A"; + data: string; + } | { + type: "B"; + data: string; + }; + + type Style2 = { + type: "A" | "B"; + data: string; + } + + const a: Style2 = { type: "A", data: "whatevs" }; + let b: Style1; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { + interface Blue { + color: 'blue' + } + interface Yellow { + color?: 'yellow', + } + function draw(val: Blue | Yellow) { } + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { + return draw({ color: currentColor }); + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { + interface ILinearAxis { type: "linear"; } + + interface ICategoricalAxis { type: "categorical"; } + + type IAxis = ILinearAxis | ICategoricalAxis; + type IAxisType = "linear" | "categorical"; + + function getAxisType(): IAxisType { + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; + const good: IAxis = { type: undefined }; + good.type = getAxisType(); +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { + interface ThingTypeOne { + type: 'one'; + } + + interface ThingTypeTwo { + type: 'two'; + } + + type ThingType = 'one' | 'two'; + + type Thing = ThingTypeOne | ThingTypeTwo; + + function makeNewThing(thingType: ThingType): Thing { + return { + type: thingType + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { + type Action = { type: 'activate' } | { type: 'disactivate' }; + + function dispatchAction(action: Action): void { + + } + + const active = true; + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { + interface A1 { + type: "A1"; + } + interface A2 { + type: "A2"; + } + type AU = A1 | A2; + + function foo(obj1: AU) { + const obj2: AU = { + type: obj1.type + }; + } +} + +//// [assignmentCompatWithDiscriminatedUnion.js] +// see 'typeRelatedToDiscriminatedType' in checker.ts: +// IteratorResult +var Example1; +(function (Example1) { + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +})(Example1 || (Example1 = {})); +// Dropping constituents of T +var Example2; +(function (Example2) { + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +})(Example2 || (Example2 = {})); +// Unmatched discriminants +var Example3; +(function (Example3) { + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +})(Example3 || (Example3 = {})); +// Unmatched non-discriminants +var Example4; +(function (Example4) { + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +})(Example4 || (Example4 = {})); +// Maximum discriminant combinations +var Example5; +(function (Example5) { + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +})(Example5 || (Example5 = {})); +// https://github.com/Microsoft/TypeScript/issues/14865 +var GH14865; +(function (GH14865) { + var a = { type: "A", data: "whatevs" }; + var b; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable +})(GH14865 || (GH14865 = {})); +// https://github.com/Microsoft/TypeScript/issues/30170 +var GH30170; +(function (GH30170) { + function draw(val) { } + function drawWithColor(currentColor) { + return draw({ color: currentColor }); + } +})(GH30170 || (GH30170 = {})); +// https://github.com/Microsoft/TypeScript/issues/12052 +var GH12052; +(function (GH12052) { + function getAxisType() { + if (1 == 1) { + return "categorical"; + } + else { + return "linear"; + } + } + var bad = { type: getAxisType() }; + var good = { type: undefined }; + good.type = getAxisType(); +})(GH12052 || (GH12052 = {})); +// https://github.com/Microsoft/TypeScript/issues/18421 +var GH18421; +(function (GH18421) { + function makeNewThing(thingType) { + return { + type: thingType + }; + } +})(GH18421 || (GH18421 = {})); +// https://github.com/Microsoft/TypeScript/issues/15907 +var GH15907; +(function (GH15907) { + function dispatchAction(action) { + } + var active = true; + dispatchAction({ type: (active ? 'disactivate' : 'activate') }); +})(GH15907 || (GH15907 = {})); +// https://github.com/Microsoft/TypeScript/issues/20889 +var GH20889; +(function (GH20889) { + function foo(obj1) { + var obj2 = { + type: obj1.type + }; + } +})(GH20889 || (GH20889 = {})); diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols new file mode 100644 index 0000000000000..1d0afd3fd91dc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols @@ -0,0 +1,494 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts === +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { +>Example1 : Symbol(Example1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 0, 0)) + + type S = { done: boolean, value: number }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 3, 20)) +>done : Symbol(done, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 14)) +>value : Symbol(value, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 29)) + + type T = +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 46)) + + | { done: true, value: number } // T0 +>done : Symbol(done, Decl(assignmentCompatWithDiscriminatedUnion.ts, 6, 11)) +>value : Symbol(value, Decl(assignmentCompatWithDiscriminatedUnion.ts, 6, 23)) + + | { done: false, value: number }; // T1 +>done : Symbol(done, Decl(assignmentCompatWithDiscriminatedUnion.ts, 7, 11)) +>value : Symbol(value, Decl(assignmentCompatWithDiscriminatedUnion.ts, 7, 24)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 9, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 3, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 10, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 46)) + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 10, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 9, 15)) +} + +// Dropping constituents of T +namespace Example2 { +>Example2 : Symbol(Example2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 15, 1)) + + type S = { a: 0 | 2, b: 4 }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 18, 20)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 24)) + + type T = { a: 0, b: 1 | 4 } // T0 +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 32)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 20, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 20, 20)) + + | { a: 1, b: 2 } // T1 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 21, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 21, 20)) + + | { a: 2, b: 3 | 4 }; // T2 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 22, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 22, 20)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 23, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 18, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 24, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 32)) + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 24, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 23, 15)) +} + +// Unmatched discriminants +namespace Example3 { +>Example3 : Symbol(Example3, Decl(assignmentCompatWithDiscriminatedUnion.ts, 29, 1)) + + type S = { a: 0 | 2, b: 4 }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 32, 20)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 24)) + + type T = { a: 0, b: 1 | 4 } // T0 +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 32)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 34, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 34, 20)) + + | { a: 1, b: 2 | 4 } // T1 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 35, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 35, 20)) + + | { a: 2, b: 3 }; // T2 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 36, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 36, 20)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 37, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 32, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 38, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 32)) + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 38, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 37, 15)) +} + +// Unmatched non-discriminants +namespace Example4 { +>Example4 : Symbol(Example4, Decl(assignmentCompatWithDiscriminatedUnion.ts, 44, 1)) + + type S = { a: 0 | 2, b: 4 }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 47, 20)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 24)) + + type T = { a: 0, b: 1 | 4 } // T0 +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 32)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 49, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 49, 20)) + + | { a: 1, b: 2 } // T1 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 50, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 50, 20)) + + | { a: 2, b: 3 | 4, c: string }; // T2 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 51, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 51, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 51, 34)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 52, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 47, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 53, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 32)) + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 53, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 52, 15)) +} + +// Maximum discriminant combinations +namespace Example5 { +>Example5 : Symbol(Example5, Decl(assignmentCompatWithDiscriminatedUnion.ts, 58, 1)) + + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + type S = { a: N, b: N, c: N }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 65, 23)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + type T = { a: 0, b: N, c: N } +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 34)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 67, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 67, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 67, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: 1, b: N, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 68, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 68, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 68, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: 2, b: N, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 69, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 69, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 69, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: 0, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 70, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 70, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 70, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: 1, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 71, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 71, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 71, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: 2, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 72, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 72, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 72, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: N, c: 0 } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 73, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 73, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 73, 26)) + + | { a: N, b: N, c: 1 } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 74, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 74, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 74, 26)) + + | { a: N, b: N, c: 2 }; +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 75, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 75, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 75, 26)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 76, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 65, 23)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 77, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 34)) + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 77, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 76, 15)) +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { +>GH14865 : Symbol(GH14865, Decl(assignmentCompatWithDiscriminatedUnion.ts, 82, 1)) + + type Style1 = { +>Style1 : Symbol(Style1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 85, 19)) + + type: "A"; +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 86, 19)) + + data: string; +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 87, 18)) + + } | { + type: "B"; +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 89, 9)) + + data: string; +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 90, 18)) + + }; + + type Style2 = { +>Style2 : Symbol(Style2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 92, 6)) + + type: "A" | "B"; +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 94, 19)) + + data: string; +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 95, 24)) + } + + const a: Style2 = { type: "A", data: "whatevs" }; +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 9)) +>Style2 : Symbol(Style2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 92, 6)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 23)) +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 34)) + + let b: Style1; +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 100, 7)) +>Style1 : Symbol(Style1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 85, 19)) + + a.type; // "A" | "B" +>a.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 94, 19)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 9)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 94, 19)) + + b.type; // "A" | "B" +>b.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 86, 19), Decl(assignmentCompatWithDiscriminatedUnion.ts, 89, 9)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 100, 7)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 86, 19), Decl(assignmentCompatWithDiscriminatedUnion.ts, 89, 9)) + + b = a; // should be assignable +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 100, 7)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 9)) +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { +>GH30170 : Symbol(GH30170, Decl(assignmentCompatWithDiscriminatedUnion.ts, 104, 1)) + + interface Blue { +>Blue : Symbol(Blue, Decl(assignmentCompatWithDiscriminatedUnion.ts, 107, 19)) + + color: 'blue' +>color : Symbol(Blue.color, Decl(assignmentCompatWithDiscriminatedUnion.ts, 108, 20)) + } + interface Yellow { +>Yellow : Symbol(Yellow, Decl(assignmentCompatWithDiscriminatedUnion.ts, 110, 5)) + + color?: 'yellow', +>color : Symbol(Yellow.color, Decl(assignmentCompatWithDiscriminatedUnion.ts, 111, 22)) + } + function draw(val: Blue | Yellow) { } +>draw : Symbol(draw, Decl(assignmentCompatWithDiscriminatedUnion.ts, 113, 5)) +>val : Symbol(val, Decl(assignmentCompatWithDiscriminatedUnion.ts, 114, 18)) +>Blue : Symbol(Blue, Decl(assignmentCompatWithDiscriminatedUnion.ts, 107, 19)) +>Yellow : Symbol(Yellow, Decl(assignmentCompatWithDiscriminatedUnion.ts, 110, 5)) + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { +>drawWithColor : Symbol(drawWithColor, Decl(assignmentCompatWithDiscriminatedUnion.ts, 114, 41)) +>currentColor : Symbol(currentColor, Decl(assignmentCompatWithDiscriminatedUnion.ts, 116, 27)) + + return draw({ color: currentColor }); +>draw : Symbol(draw, Decl(assignmentCompatWithDiscriminatedUnion.ts, 113, 5)) +>color : Symbol(color, Decl(assignmentCompatWithDiscriminatedUnion.ts, 117, 21)) +>currentColor : Symbol(currentColor, Decl(assignmentCompatWithDiscriminatedUnion.ts, 116, 27)) + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { +>GH12052 : Symbol(GH12052, Decl(assignmentCompatWithDiscriminatedUnion.ts, 119, 1)) + + interface ILinearAxis { type: "linear"; } +>ILinearAxis : Symbol(ILinearAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 122, 19)) +>type : Symbol(ILinearAxis.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27)) + + interface ICategoricalAxis { type: "categorical"; } +>ICategoricalAxis : Symbol(ICategoricalAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 45)) +>type : Symbol(ICategoricalAxis.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) + + type IAxis = ILinearAxis | ICategoricalAxis; +>IAxis : Symbol(IAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 55)) +>ILinearAxis : Symbol(ILinearAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 122, 19)) +>ICategoricalAxis : Symbol(ICategoricalAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 45)) + + type IAxisType = "linear" | "categorical"; +>IAxisType : Symbol(IAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 127, 48)) + + function getAxisType(): IAxisType { +>getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) +>IAxisType : Symbol(IAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 127, 48)) + + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; +>bad : Symbol(bad, Decl(assignmentCompatWithDiscriminatedUnion.ts, 138, 9)) +>IAxis : Symbol(IAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 55)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 138, 24)) +>getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) + + const good: IAxis = { type: undefined }; +>good : Symbol(good, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 9)) +>IAxis : Symbol(IAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 55)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 25)) +>undefined : Symbol(undefined) + + good.type = getAxisType(); +>good.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27), Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) +>good : Symbol(good, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 9)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27), Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) +>getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { +>GH18421 : Symbol(GH18421, Decl(assignmentCompatWithDiscriminatedUnion.ts, 141, 1)) + + interface ThingTypeOne { +>ThingTypeOne : Symbol(ThingTypeOne, Decl(assignmentCompatWithDiscriminatedUnion.ts, 144, 19)) + + type: 'one'; +>type : Symbol(ThingTypeOne.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 145, 28)) + } + + interface ThingTypeTwo { +>ThingTypeTwo : Symbol(ThingTypeTwo, Decl(assignmentCompatWithDiscriminatedUnion.ts, 147, 5)) + + type: 'two'; +>type : Symbol(ThingTypeTwo.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 149, 28)) + } + + type ThingType = 'one' | 'two'; +>ThingType : Symbol(ThingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 151, 5)) + + type Thing = ThingTypeOne | ThingTypeTwo; +>Thing : Symbol(Thing, Decl(assignmentCompatWithDiscriminatedUnion.ts, 153, 35)) +>ThingTypeOne : Symbol(ThingTypeOne, Decl(assignmentCompatWithDiscriminatedUnion.ts, 144, 19)) +>ThingTypeTwo : Symbol(ThingTypeTwo, Decl(assignmentCompatWithDiscriminatedUnion.ts, 147, 5)) + + function makeNewThing(thingType: ThingType): Thing { +>makeNewThing : Symbol(makeNewThing, Decl(assignmentCompatWithDiscriminatedUnion.ts, 155, 45)) +>thingType : Symbol(thingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 157, 26)) +>ThingType : Symbol(ThingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 151, 5)) +>Thing : Symbol(Thing, Decl(assignmentCompatWithDiscriminatedUnion.ts, 153, 35)) + + return { + type: thingType +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 158, 16)) +>thingType : Symbol(thingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 157, 26)) + + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { +>GH15907 : Symbol(GH15907, Decl(assignmentCompatWithDiscriminatedUnion.ts, 162, 1)) + + type Action = { type: 'activate' } | { type: 'disactivate' }; +>Action : Symbol(Action, Decl(assignmentCompatWithDiscriminatedUnion.ts, 165, 19)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 19)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 42)) + + function dispatchAction(action: Action): void { +>dispatchAction : Symbol(dispatchAction, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 65)) +>action : Symbol(action, Decl(assignmentCompatWithDiscriminatedUnion.ts, 168, 28)) +>Action : Symbol(Action, Decl(assignmentCompatWithDiscriminatedUnion.ts, 165, 19)) + + } + + const active = true; +>active : Symbol(active, Decl(assignmentCompatWithDiscriminatedUnion.ts, 172, 9)) + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +>dispatchAction : Symbol(dispatchAction, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 65)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 174, 20)) +>active : Symbol(active, Decl(assignmentCompatWithDiscriminatedUnion.ts, 172, 9)) +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { +>GH20889 : Symbol(GH20889, Decl(assignmentCompatWithDiscriminatedUnion.ts, 175, 1)) + + interface A1 { +>A1 : Symbol(A1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 178, 19)) + + type: "A1"; +>type : Symbol(A1.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 179, 18)) + } + interface A2 { +>A2 : Symbol(A2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 181, 5)) + + type: "A2"; +>type : Symbol(A2.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 182, 18)) + } + type AU = A1 | A2; +>AU : Symbol(AU, Decl(assignmentCompatWithDiscriminatedUnion.ts, 184, 5)) +>A1 : Symbol(A1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 178, 19)) +>A2 : Symbol(A2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 181, 5)) + + function foo(obj1: AU) { +>foo : Symbol(foo, Decl(assignmentCompatWithDiscriminatedUnion.ts, 185, 22)) +>obj1 : Symbol(obj1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 187, 17)) +>AU : Symbol(AU, Decl(assignmentCompatWithDiscriminatedUnion.ts, 184, 5)) + + const obj2: AU = { +>obj2 : Symbol(obj2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 188, 13)) +>AU : Symbol(AU, Decl(assignmentCompatWithDiscriminatedUnion.ts, 184, 5)) + + type: obj1.type +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 188, 26)) +>obj1.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 179, 18), Decl(assignmentCompatWithDiscriminatedUnion.ts, 182, 18)) +>obj1 : Symbol(obj1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 187, 17)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 179, 18), Decl(assignmentCompatWithDiscriminatedUnion.ts, 182, 18)) + + }; + } +} diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types new file mode 100644 index 0000000000000..76bdb2716d20e --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types @@ -0,0 +1,466 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts === +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { +>Example1 : typeof Example1 + + type S = { done: boolean, value: number }; +>S : S +>done : boolean +>value : number + + type T = +>T : T + + | { done: true, value: number } // T0 +>done : true +>true : true +>value : number + + | { done: false, value: number }; // T1 +>done : false +>false : false +>value : number + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +>t = s : S +>t : T +>s : S +} + +// Dropping constituents of T +namespace Example2 { +>Example2 : typeof Example2 + + type S = { a: 0 | 2, b: 4 }; +>S : S +>a : 0 | 2 +>b : 4 + + type T = { a: 0, b: 1 | 4 } // T0 +>T : T +>a : 0 +>b : 4 | 1 + + | { a: 1, b: 2 } // T1 +>a : 1 +>b : 2 + + | { a: 2, b: 3 | 4 }; // T2 +>a : 2 +>b : 4 | 3 + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +>t = s : S +>t : T +>s : S +} + +// Unmatched discriminants +namespace Example3 { +>Example3 : typeof Example3 + + type S = { a: 0 | 2, b: 4 }; +>S : S +>a : 0 | 2 +>b : 4 + + type T = { a: 0, b: 1 | 4 } // T0 +>T : T +>a : 0 +>b : 4 | 1 + + | { a: 1, b: 2 | 4 } // T1 +>a : 1 +>b : 2 | 4 + + | { a: 2, b: 3 }; // T2 +>a : 2 +>b : 3 + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +>t = s : S +>t : T +>s : S +} + +// Unmatched non-discriminants +namespace Example4 { +>Example4 : typeof Example4 + + type S = { a: 0 | 2, b: 4 }; +>S : S +>a : 0 | 2 +>b : 4 + + type T = { a: 0, b: 1 | 4 } // T0 +>T : T +>a : 0 +>b : 4 | 1 + + | { a: 1, b: 2 } // T1 +>a : 1 +>b : 2 + + | { a: 2, b: 3 | 4, c: string }; // T2 +>a : 2 +>b : 4 | 3 +>c : string + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +>t = s : S +>t : T +>s : S +} + +// Maximum discriminant combinations +namespace Example5 { +>Example5 : typeof Example5 + + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; +>N : 0 | 2 | 1 + + type S = { a: N, b: N, c: N }; +>S : S +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + type T = { a: 0, b: N, c: N } +>T : T +>a : 0 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + | { a: 1, b: N, c: N } +>a : 1 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + | { a: 2, b: N, c: N } +>a : 2 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + | { a: N, b: 0, c: N } +>a : 0 | 2 | 1 +>b : 0 +>c : 0 | 2 | 1 + + | { a: N, b: 1, c: N } +>a : 0 | 2 | 1 +>b : 1 +>c : 0 | 2 | 1 + + | { a: N, b: 2, c: N } +>a : 0 | 2 | 1 +>b : 2 +>c : 0 | 2 | 1 + + | { a: N, b: N, c: 0 } +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 0 + + | { a: N, b: N, c: 1 } +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 1 + + | { a: N, b: N, c: 2 }; +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 2 + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +>t = s : S +>t : T +>s : S +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { +>GH14865 : typeof GH14865 + + type Style1 = { +>Style1 : Style1 + + type: "A"; +>type : "A" + + data: string; +>data : string + + } | { + type: "B"; +>type : "B" + + data: string; +>data : string + + }; + + type Style2 = { +>Style2 : Style2 + + type: "A" | "B"; +>type : "A" | "B" + + data: string; +>data : string + } + + const a: Style2 = { type: "A", data: "whatevs" }; +>a : Style2 +>{ type: "A", data: "whatevs" } : { type: "A"; data: string; } +>type : "A" +>"A" : "A" +>data : string +>"whatevs" : "whatevs" + + let b: Style1; +>b : Style1 + + a.type; // "A" | "B" +>a.type : "A" | "B" +>a : Style2 +>type : "A" | "B" + + b.type; // "A" | "B" +>b.type : "A" | "B" +>b : Style1 +>type : "A" | "B" + + b = a; // should be assignable +>b = a : Style2 +>b : Style1 +>a : Style2 +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { +>GH30170 : typeof GH30170 + + interface Blue { + color: 'blue' +>color : "blue" + } + interface Yellow { + color?: 'yellow', +>color : "yellow" + } + function draw(val: Blue | Yellow) { } +>draw : (val: Blue | Yellow) => void +>val : Blue | Yellow + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { +>drawWithColor : (currentColor: "blue" | "yellow") => void +>currentColor : "blue" | "yellow" + + return draw({ color: currentColor }); +>draw({ color: currentColor }) : void +>draw : (val: Blue | Yellow) => void +>{ color: currentColor } : { color: "blue" | "yellow"; } +>color : "blue" | "yellow" +>currentColor : "blue" | "yellow" + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { +>GH12052 : typeof GH12052 + + interface ILinearAxis { type: "linear"; } +>type : "linear" + + interface ICategoricalAxis { type: "categorical"; } +>type : "categorical" + + type IAxis = ILinearAxis | ICategoricalAxis; +>IAxis : IAxis + + type IAxisType = "linear" | "categorical"; +>IAxisType : IAxisType + + function getAxisType(): IAxisType { +>getAxisType : () => IAxisType + + if (1 == 1) { +>1 == 1 : boolean +>1 : 1 +>1 : 1 + + return "categorical"; +>"categorical" : "categorical" + + } else { + return "linear"; +>"linear" : "linear" + } + } + + const bad: IAxis = { type: getAxisType() }; +>bad : IAxis +>{ type: getAxisType() } : { type: IAxisType; } +>type : IAxisType +>getAxisType() : IAxisType +>getAxisType : () => IAxisType + + const good: IAxis = { type: undefined }; +>good : IAxis +>{ type: undefined } : { type: undefined; } +>type : undefined +>undefined : undefined + + good.type = getAxisType(); +>good.type = getAxisType() : IAxisType +>good.type : IAxisType +>good : IAxis +>type : IAxisType +>getAxisType() : IAxisType +>getAxisType : () => IAxisType +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { +>GH18421 : typeof GH18421 + + interface ThingTypeOne { + type: 'one'; +>type : "one" + } + + interface ThingTypeTwo { + type: 'two'; +>type : "two" + } + + type ThingType = 'one' | 'two'; +>ThingType : ThingType + + type Thing = ThingTypeOne | ThingTypeTwo; +>Thing : Thing + + function makeNewThing(thingType: ThingType): Thing { +>makeNewThing : (thingType: ThingType) => Thing +>thingType : ThingType + + return { +>{ type: thingType } : { type: ThingType; } + + type: thingType +>type : ThingType +>thingType : ThingType + + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { +>GH15907 : typeof GH15907 + + type Action = { type: 'activate' } | { type: 'disactivate' }; +>Action : Action +>type : "activate" +>type : "disactivate" + + function dispatchAction(action: Action): void { +>dispatchAction : (action: Action) => void +>action : Action + + } + + const active = true; +>active : true +>true : true + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +>dispatchAction({ type : (active? 'disactivate' : 'activate') }) : void +>dispatchAction : (action: Action) => void +>{ type : (active? 'disactivate' : 'activate') } : { type: "activate" | "disactivate"; } +>type : "activate" | "disactivate" +>(active? 'disactivate' : 'activate') : "activate" | "disactivate" +>active? 'disactivate' : 'activate' : "activate" | "disactivate" +>active : true +>'disactivate' : "disactivate" +>'activate' : "activate" +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { +>GH20889 : typeof GH20889 + + interface A1 { + type: "A1"; +>type : "A1" + } + interface A2 { + type: "A2"; +>type : "A2" + } + type AU = A1 | A2; +>AU : AU + + function foo(obj1: AU) { +>foo : (obj1: AU) => void +>obj1 : AU + + const obj2: AU = { +>obj2 : AU +>{ type: obj1.type } : { type: "A1" | "A2"; } + + type: obj1.type +>type : "A1" | "A2" +>obj1.type : "A1" | "A2" +>obj1 : AU +>type : "A1" | "A2" + + }; + } +} diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt index 38f03ca68c441..adf305d868d19 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(15,1): error TS2322: Type 'B' is not assignable to type 'A'. Types of parameters 'y' and 'y' are incompatible. Type 'T[]' is not assignable to type 'T'. + 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(16,1): error TS2322: Type 'A' is not assignable to type 'B'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'S[]'. @@ -26,6 +27,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'B' is not assignable to type 'A'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'T[]' is not assignable to type 'T'. +!!! error TS2322: 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b = a; ~ !!! error TS2322: Type 'A' is not assignable to type 'B'. diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt index dbad415c5f83d..d5b212a414a9c 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt @@ -2,68 +2,91 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(23,13): error TS2322: Type '(x: T, y: T) => any' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(63,9): error TS2322: Type '() => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(64,9): error TS2322: Type '(x?: T) => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(65,9): error TS2322: Type '(x: T) => T' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(66,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(67,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(69,9): error TS2322: Type '() => T' is not assignable to type '(x?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(70,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(71,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(72,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(73,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(75,9): error TS2322: Type '() => T' is not assignable to type '(x: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(76,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(77,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(78,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(79,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(81,9): error TS2322: Type '() => T' is not assignable to type '(x: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(82,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(83,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(84,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(85,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(87,9): error TS2322: Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(88,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(89,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(90,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(91,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(107,13): error TS2322: Type '(x: T) => any' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(116,13): error TS2322: Type '(x: T, y: T) => any' is not assignable to type '(x: T) => T'. @@ -139,10 +162,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type '() => T' is not assignable to type '() => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a = t.a2; ~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '() => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a = t.a3; ~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '() => T'. @@ -153,106 +178,127 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '() => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt index 9f60ca5500221..7358455430c80 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -14,6 +15,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -66,6 +68,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. @@ -79,6 +82,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt index e063a16fd3f4c..f4b2e46f44f96 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -14,6 +15,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -66,6 +68,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. @@ -79,6 +82,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt index 845edafd82ca8..1f279ba2858f7 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts(33,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts (3 errors) ==== @@ -57,6 +58,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. b = a; // ok var b2: { [x: number]: T; }; diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt index 523c6b9733774..b3970325dc298 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt @@ -13,6 +13,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -20,6 +21,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -94,6 +96,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b3 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. @@ -107,6 +110,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b4 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt index 180012decc2dd..f90f8a41feb05 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt @@ -13,6 +13,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -20,6 +21,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -94,6 +96,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b3 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. @@ -107,6 +110,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b4 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentStricterConstraints.errors.txt b/tests/baselines/reference/assignmentStricterConstraints.errors.txt index c83e2fa3440d0..f00b8313eac8d 100644 --- a/tests/baselines/reference/assignmentStricterConstraints.errors.txt +++ b/tests/baselines/reference/assignmentStricterConstraints.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/assignmentStricterConstraints.ts(7,1): error TS2322: Type '(x: T, y: S) => void' is not assignable to type '(x: T, y: S) => void'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'T'. + 'S' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/assignmentStricterConstraints.ts (1 errors) ==== @@ -15,5 +16,6 @@ tests/cases/compiler/assignmentStricterConstraints.ts(7,1): error TS2322: Type ' !!! error TS2322: Type '(x: T, y: S) => void' is not assignable to type '(x: T, y: S) => void'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: 'S' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. g(1, "") \ No newline at end of file diff --git a/tests/baselines/reference/baseConstraintOfDecorator.errors.txt b/tests/baselines/reference/baseConstraintOfDecorator.errors.txt index 3af8756fac29a..8317e5c55c660 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.errors.txt +++ b/tests/baselines/reference/baseConstraintOfDecorator.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(2,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. + 'typeof decoratorFunc' is assignable to the constraint of type 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/baseConstraintOfDecorator.ts(2,40): error TS2507: Type 'TFunction' is not a constructor function type. tests/cases/compiler/baseConstraintOfDecorator.ts(12,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TFunction' is not a constructor function type. @@ -22,6 +23,7 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TF }; ~~~~~~ !!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. +!!! error TS2322: 'typeof decoratorFunc' is assignable to the constraint of type 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint '{}'. } class MyClass { private x; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt index 3d9ecd65e3d89..2ca3bb1aaf00a 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Types of property 'a2' are incompatible. Type '(x: T) => string' is not assignable to type '(x: T) => T'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts (2 errors) ==== @@ -82,6 +83,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type '(x: T) => string' is not assignable to type '(x: T) => T'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 33af0d9f4bf0f..671c09b3d7906 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '(x: T) => U[]' is not assignable to type '(x: number) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(60,19): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a8' are incompatible. Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. @@ -30,6 +31,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(109,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'. Types of property 'a2' are incompatible. Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. @@ -95,6 +97,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => U[]' is not assignable to type '(x: number) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'T'. +!!! error TS2430: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic } @@ -175,6 +178,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. !!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => string[]; // error } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt index 602e40dfcfb57..f6526347975c7 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt @@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '(x: T) => T[]' is not assignable to type '(x: T) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(28,11): error TS2430: Interface 'I2' incorrectly extends interface 'A'. Types of property 'a2' are incompatible. Type '(x: T) => string[]' is not assignable to type '(x: T) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(32,11): error TS2430: Interface 'I3' incorrectly extends interface 'A'. Types of property 'a3' are incompatible. Type '(x: T) => T' is not assignable to type '(x: T) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(36,11): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a4' are incompatible. Type '(x: T, y: U) => string' is not assignable to type '(x: T, y: U) => string'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(40,11): error TS2430: Interface 'I5' incorrectly extends interface 'A'. Types of property 'a5' are incompatible. Type '(x: (arg: T) => U) => T' is not assignable to type '(x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(44,11): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a11' are incompatible. Type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base'. @@ -31,6 +36,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(48,11): error TS2430: Interface 'I9' incorrectly extends interface 'A'. Types of property 'a16' are incompatible. Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. @@ -38,7 +44,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - Type 'Base' is not assignable to type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts (7 errors) ==== @@ -72,6 +80,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => T[]' is not assignable to type '(x: T) => T[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: (x: T) => T[]; } @@ -82,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => string[]' is not assignable to type '(x: T) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => string[]; } @@ -92,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => T' is not assignable to type '(x: T) => void'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: (x: T) => T; } @@ -102,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T, y: U) => string' is not assignable to type '(x: T, y: U) => string'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: (x: T, y: U) => string; } @@ -113,6 +125,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: (x: (arg: T) => U) => T; } @@ -125,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'foo' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; } @@ -137,6 +151,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a16: (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt index 6f03e711886ba..e0091e407dfc5 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt @@ -1,5 +1,7 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(7,49): error TS2322: Type 'T' is not assignable to type 'S'. + 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(10,35): error TS2322: Type 'T' is not assignable to type 'S'. + 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2322: Type '""' is not assignable to type 'number'. @@ -15,12 +17,14 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete (new Chain(t)).then(tt => s).then(ss => t); ~ !!! error TS2322: Type 'T' is not assignable to type 'S'. +!!! error TS2322: 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. !!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:3:27: The expected type comes from the return type of this signature. // But error to try to climb up the chain (new Chain(s)).then(ss => t); ~ !!! error TS2322: Type 'T' is not assignable to type 'S'. +!!! error TS2322: 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. !!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:3:27: The expected type comes from the return type of this signature. // Staying at T or S should be fine diff --git a/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt b/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt index 32e8464a19573..d2c8c0111aede 100644 --- a/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt +++ b/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts(6,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts(12,9): error TS2322: Type 'T2' is not assignable to type 'T1'. + 'T2' is assignable to the constraint of type 'T1', but 'T1' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts (2 errors) ==== @@ -19,4 +20,5 @@ tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOpera var result: T1 = (x, y); //error here ~~~~~~ !!! error TS2322: Type 'T2' is not assignable to type 'T1'. +!!! error TS2322: 'T2' is assignable to the constraint of type 'T1', but 'T1' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/complexRecursiveCollections.errors.txt b/tests/baselines/reference/complexRecursiveCollections.errors.txt index aaed4f2636092..27bb24bc5cc14 100644 --- a/tests/baselines/reference/complexRecursiveCollections.errors.txt +++ b/tests/baselines/reference/complexRecursiveCollections.errors.txt @@ -2,14 +2,17 @@ tests/cases/compiler/immutable.ts(341,22): error TS2430: Interface 'Keyed' Types of property 'toSeq' are incompatible. Type '() => Keyed' is not assignable to type '() => this'. Type 'Keyed' is not assignable to type 'this'. + 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. tests/cases/compiler/immutable.ts(359,22): error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Indexed' is not assignable to type '() => this'. Type 'Indexed' is not assignable to type 'this'. + 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Set' is not assignable to type '() => this'. Type 'Set' is not assignable to type 'this'. + 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. ==== tests/cases/compiler/complex.ts (0 errors) ==== @@ -380,6 +383,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco !!! error TS2430: Types of property 'toSeq' are incompatible. !!! error TS2430: Type '() => Keyed' is not assignable to type '() => this'. !!! error TS2430: Type 'Keyed' is not assignable to type 'this'. +!!! error TS2430: 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. toJS(): Object; toJSON(): { [key: string]: V }; toSeq(): Seq.Keyed; @@ -403,6 +407,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco !!! error TS2430: Types of property 'toSeq' are incompatible. !!! error TS2430: Type '() => Indexed' is not assignable to type '() => this'. !!! error TS2430: Type 'Indexed' is not assignable to type 'this'. +!!! error TS2430: 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. toJS(): Array; toJSON(): Array; // Reading values @@ -440,6 +445,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco !!! error TS2430: Types of property 'toSeq' are incompatible. !!! error TS2430: Type '() => Set' is not assignable to type '() => this'. !!! error TS2430: Type 'Set' is not assignable to type 'this'. +!!! error TS2430: 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. toJS(): Array; toJSON(): Array; toSeq(): Seq.Set; diff --git a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt index 97cd312b2637a..af63c18523d6a 100644 --- a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt +++ b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt @@ -10,13 +10,15 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t Type '"text"' is not assignable to type 'ChannelOfType["type"]'. Type '"text"' is not assignable to type 'T & "text"'. Type '"text"' is not assignable to type 'T'. - Type 'T' is not assignable to type 'T & "text"'. - Type '"text" | "email"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T'. - Type 'T' is not assignable to type '"text"'. - Type '"text" | "email"' is not assignable to type '"text"'. - Type '"email"' is not assignable to type '"text"'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type 'T & "text"'. + Type '"text" | "email"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type '"text"'. + Type '"text" | "email"' is not assignable to type '"text"'. + Type '"email"' is not assignable to type '"text"'. ==== tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.ts (1 errors) ==== @@ -66,13 +68,15 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. !!! error TS2322: Type '"text"' is not assignable to type 'T'. -!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T'. -!!! error TS2322: Type 'T' is not assignable to type '"text"'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. -!!! error TS2322: Type '"email"' is not assignable to type '"text"'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type '"text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. +!!! error TS2322: Type '"email"' is not assignable to type '"text"'. } const newTextChannel = makeNewChannel('text'); diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index ec35f89161589..c84ce90642a3a 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -14,7 +14,9 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(30,9): error TS23 Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick' is not assignable to type 'T'. + 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'Pick' is not assignable to type 'T'. + 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. Type 'keyof T' is not assignable to type 'never'. @@ -40,10 +42,14 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(135,5): error TS2 tests/cases/conformance/types/conditional/conditionalTypes1.ts(136,22): error TS2540: Cannot assign to 'id' because it is a read-only property. tests/cases/conformance/types/conditional/conditionalTypes1.ts(137,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2322: Type 'ZeroOf' is not assignable to type 'T'. - Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. - Type '0' is not assignable to type 'T'. - Type '"" | 0' is not assignable to type 'T'. - Type '""' is not assignable to type 'T'. + 'ZeroOf' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. + Type '0' is not assignable to type 'T'. + '0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + Type '"" | 0' is not assignable to type 'T'. + '"" | 0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + Type '""' is not assignable to type 'T'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf'. Type 'string | number' is not assignable to type 'ZeroOf'. Type 'string' is not assignable to type 'ZeroOf'. @@ -179,9 +185,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS x = y; // Error ~ !!! error TS2322: Type 'Pick' is not assignable to type 'T'. +!!! error TS2322: 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. x = z; // Error ~ !!! error TS2322: Type 'Pick' is not assignable to type 'T'. +!!! error TS2322: 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; y = z; // Error ~ @@ -273,10 +281,14 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS x = y; // Error ~ !!! error TS2322: Type 'ZeroOf' is not assignable to type 'T'. -!!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. -!!! error TS2322: Type '0' is not assignable to type 'T'. -!!! error TS2322: Type '"" | 0' is not assignable to type 'T'. -!!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: 'ZeroOf' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. +!!! error TS2322: Type '0' is not assignable to type 'T'. +!!! error TS2322: '0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'T'. +!!! error TS2322: '"" | 0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. y = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'ZeroOf'. diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index ee7c10ada5891..f17a55dd61c6f 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -1,7 +1,9 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. Type 'A' is not assignable to type 'B'. + 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(19,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. Type 'A' is not assignable to type 'B'. + 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. @@ -19,6 +21,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS23 Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. Type 'A' is not assignable to type 'B'. + 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. @@ -49,6 +52,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 ~ !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. } function f2(a: Contravariant, b: Contravariant) { @@ -56,6 +60,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 ~ !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. b = a; } @@ -81,6 +86,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. } // Extract is a T that is known to be a Function diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt index cc2c1e871e5ed..e326d163c8ced 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Types of property 'a2' are incompatible. Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts (2 errors) ==== @@ -86,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: new (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 1a9edc159af19..59d8105c59cc9 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type 'new (x: T) => U[]' is not assignable to type 'new (x: number) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(50,19): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a8' are incompatible. Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. @@ -30,6 +31,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(95,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'. Types of property 'a2' are incompatible. Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. @@ -85,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => U[]' is not assignable to type 'new (x: number) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'T'. +!!! error TS2430: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic } @@ -161,6 +164,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => string[]; // error } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt index 6245fead91964..a2ea2c70c65ee 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt @@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(28,11): error TS2430: Interface 'I2' incorrectly extends interface 'A'. Types of property 'a2' are incompatible. Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(32,11): error TS2430: Interface 'I3' incorrectly extends interface 'A'. Types of property 'a3' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x: T) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(36,11): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a4' are incompatible. Type 'new (x: T, y: U) => string' is not assignable to type 'new (x: T, y: U) => string'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(40,11): error TS2430: Interface 'I5' incorrectly extends interface 'A'. Types of property 'a5' are incompatible. Type 'new (x: (arg: T) => U) => T' is not assignable to type 'new (x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(44,11): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a11' are incompatible. Type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base'. @@ -31,6 +36,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(48,11): error TS2430: Interface 'I9' incorrectly extends interface 'A'. Types of property 'a16' are incompatible. Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. @@ -38,7 +44,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - Type 'Base' is not assignable to type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts (7 errors) ==== @@ -72,6 +80,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new (x: T) => T[]; } @@ -82,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => string[]; } @@ -92,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x: T) => void'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new (x: T) => T; } @@ -102,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T, y: U) => string' is not assignable to type 'new (x: T, y: U) => string'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new (x: T, y: U) => string; } @@ -113,6 +125,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new (x: (arg: T) => U) => T; } @@ -125,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'foo' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; } @@ -137,6 +151,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a16: new (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt index 9cad967dd7727..38fadde8f5b99 100644 --- a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt +++ b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(3,17): error TS2322: Type '1' is not assignable to type 'string'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,17): error TS2322: Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,27): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(17,17): error TS2322: Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. ==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts (4 errors) ==== @@ -19,8 +22,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x: T = 1, public y: U = x) { // error ~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'T'. +!!! error TS2322: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var z = x; } } @@ -30,6 +35,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x: T = new Date()) { // error ~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. var y = x; } } \ No newline at end of file diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index 6d3644eabb035..499b31460b7dc 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,18): error TS2322: Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== @@ -39,6 +40,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class. ~ !!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. !!! related TS6500 tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts:24:5: The expected type comes from property 'x' which is declared here on type 'F' } } diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index df0b788459476..4e6f9f71c923e 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -105,9 +105,9 @@ >(...numbers) => numbers.every(n => n > 0) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean >numbers : [number, number, number] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >numbers : [number, number, number] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean @@ -123,9 +123,9 @@ >(...mixed) => mixed.every(n => !!n) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean >mixed : [number, string, string] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >mixed : [number, string, string] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >n => !!n : (n: string | number) => boolean >n : string | number >!!n : boolean @@ -141,9 +141,9 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : () => boolean >noNumbers : [] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >noNumbers : [] ->some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: never) => boolean >n : never >n > 0 : boolean diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types index e20c08a20debf..18ad0a1241f73 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.types +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -105,9 +105,9 @@ >(...numbers) => numbers.every(n => n > 0) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean >numbers : [number, number, number] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >numbers : [number, number, number] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean @@ -123,9 +123,9 @@ >(...mixed) => mixed.every(n => !!n) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean >mixed : [number, string, string] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >mixed : [number, string, string] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >n => !!n : (n: string | number) => boolean >n : string | number >!!n : boolean @@ -141,9 +141,9 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : () => boolean >noNumbers : [] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >noNumbers : [] ->some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: never) => boolean >n : never >n > 0 : boolean diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index f545baeb443bb..56ff62f6e1d4e 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -26,14 +26,14 @@ export async function runSampleWorks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >el => !!el : (el: bluebird) => boolean >el : bluebird >!!el : boolean @@ -88,14 +88,14 @@ export async function runSampleBreaks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >el => !!el : (el: bluebird) => boolean >el : bluebird >!!el : boolean diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index 359fab212e909..e63849e4aa887 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -3,7 +3,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type '""' is not assignable to type 'T'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E' is not assignable to type 'C'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'number'. @@ -50,10 +52,12 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. foo(): T { return ''; // error ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. } } diff --git a/tests/baselines/reference/destructuringAssignabilityCheck.errors.txt b/tests/baselines/reference/destructuringAssignabilityCheck.errors.txt new file mode 100644 index 0000000000000..bbb4812cf00ed --- /dev/null +++ b/tests/baselines/reference/destructuringAssignabilityCheck.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(1,7): error TS2461: Type '{}' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(2,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(3,3): error TS2461: Type '{}' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(4,3): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(6,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(9,14): error TS2461: Type '{}' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(13,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(15,7): error TS2461: Type '{}' is not an array type. + + +==== tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts (8 errors) ==== + const [] = {}; // should be error + ~~ +!!! error TS2461: Type '{}' is not an array type. + const {} = undefined; // error correctly + ~~ +!!! error TS2532: Object is possibly 'undefined'. + (([]) => 0)({}); // should be error + ~~ +!!! error TS2461: Type '{}' is not an array type. + (({}) => 0)(undefined); // should be error + ~~ +!!! error TS2532: Object is possibly 'undefined'. + + function foo({}: undefined) { + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + return 0 + } + function bar([]: {}) { + ~~~~~~ +!!! error TS2461: Type '{}' is not an array type. + return 0 + } + + const { }: undefined = 1 + ~~~ +!!! error TS2532: Object is possibly 'undefined'. + + const []: {} = {} + ~~ +!!! error TS2461: Type '{}' is not an array type. + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringAssignabilityCheck.js b/tests/baselines/reference/destructuringAssignabilityCheck.js new file mode 100644 index 0000000000000..2702d8b7f5c59 --- /dev/null +++ b/tests/baselines/reference/destructuringAssignabilityCheck.js @@ -0,0 +1,32 @@ +//// [destructuringAssignabilityCheck.ts] +const [] = {}; // should be error +const {} = undefined; // error correctly +(([]) => 0)({}); // should be error +(({}) => 0)(undefined); // should be error + +function foo({}: undefined) { + return 0 +} +function bar([]: {}) { + return 0 +} + +const { }: undefined = 1 + +const []: {} = {} + + +//// [destructuringAssignabilityCheck.js] +"use strict"; +var _a = {}; // should be error +var _b = undefined; // error correctly +(function (_a) { return 0; })({}); // should be error +(function (_a) { return 0; })(undefined); // should be error +function foo(_a) { + return 0; +} +function bar(_a) { + return 0; +} +var _c = 1; +var _d = {}; diff --git a/tests/baselines/reference/destructuringAssignabilityCheck.symbols b/tests/baselines/reference/destructuringAssignabilityCheck.symbols new file mode 100644 index 0000000000000..c9465f0e41aea --- /dev/null +++ b/tests/baselines/reference/destructuringAssignabilityCheck.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts === +const [] = {}; // should be error +const {} = undefined; // error correctly +>undefined : Symbol(undefined) + +(([]) => 0)({}); // should be error +(({}) => 0)(undefined); // should be error +>undefined : Symbol(undefined) + +function foo({}: undefined) { +>foo : Symbol(foo, Decl(destructuringAssignabilityCheck.ts, 3, 23)) + + return 0 +} +function bar([]: {}) { +>bar : Symbol(bar, Decl(destructuringAssignabilityCheck.ts, 7, 1)) + + return 0 +} + +const { }: undefined = 1 + +const []: {} = {} + diff --git a/tests/baselines/reference/destructuringAssignabilityCheck.types b/tests/baselines/reference/destructuringAssignabilityCheck.types new file mode 100644 index 0000000000000..df4467cce6433 --- /dev/null +++ b/tests/baselines/reference/destructuringAssignabilityCheck.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts === +const [] = {}; // should be error +>{} : {} + +const {} = undefined; // error correctly +>undefined : undefined + +(([]) => 0)({}); // should be error +>(([]) => 0)({}) : number +>(([]) => 0) : ([]: {}) => number +>([]) => 0 : ([]: {}) => number +>0 : 0 +>{} : {} + +(({}) => 0)(undefined); // should be error +>(({}) => 0)(undefined) : number +>(({}) => 0) : ({}: undefined) => number +>({}) => 0 : ({}: undefined) => number +>0 : 0 +>undefined : undefined + +function foo({}: undefined) { +>foo : ({}: undefined) => number + + return 0 +>0 : 0 +} +function bar([]: {}) { +>bar : ([]: {}) => number + + return 0 +>0 : 0 +} + +const { }: undefined = 1 +>1 : 1 + +const []: {} = {} +>{} : {} + diff --git a/tests/baselines/reference/duplicateLocalVariable1.types b/tests/baselines/reference/duplicateLocalVariable1.types index 4a7dcb41919a7..9ad7673412e18 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.types +++ b/tests/baselines/reference/duplicateLocalVariable1.types @@ -41,9 +41,9 @@ export class TestRunner { return (arg1.every(function (val, index) { return val === arg2[index] })); >(arg1.every(function (val, index) { return val === arg2[index] })) : boolean >arg1.every(function (val, index) { return val === arg2[index] }) : boolean ->arg1.every : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>arg1.every : (callbackfn: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean >arg1 : any[] ->every : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean >function (val, index) { return val === arg2[index] } : (val: any, index: number) => boolean >val : any >index : number diff --git a/tests/baselines/reference/enumAssignability.errors.txt b/tests/baselines/reference/enumAssignability.errors.txt index bfabb5eae8819..b582f9f8048ce 100644 --- a/tests/baselines/reference/enumAssignability.errors.txt +++ b/tests/baselines/reference/enumAssignability.errors.txt @@ -14,10 +14,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(43,9): error TS2322: Type 'E' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(45,9): error TS2322: Type 'E' is not assignable to type 'String'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(48,9): error TS2322: Type 'E' is not assignable to type 'T'. + 'E' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(49,9): error TS2322: Type 'E' is not assignable to type 'U'. + 'E' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(50,9): error TS2322: Type 'E' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(51,13): error TS2322: Type 'E' is not assignable to type 'A'. + 'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(52,13): error TS2322: Type 'E' is not assignable to type 'B'. + 'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts (20 errors) ==== @@ -101,17 +105,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi x = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'T'. +!!! error TS2322: 'E' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'U'. +!!! error TS2322: 'E' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. z = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'V'. var a: A = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'A'. +!!! error TS2322: 'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'. var b: B = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'B'. +!!! error TS2322: 'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'. } } \ No newline at end of file diff --git a/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt b/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt index e2b18aa2fc35a..6cfeeb8aeb816 100644 --- a/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt +++ b/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(2,5): error TS2322: Type '{ a: string; b: number; c: number; }' is not assignable to type 'T'. tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(6,5): error TS2322: Type '{ a: number; }' is not assignable to type 'T'. tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(10,5): error TS2322: Type '{ a: string; }' is not assignable to type 'T'. + '{ a: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ a: string; }'. ==== tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts (3 errors) ==== @@ -20,5 +21,6 @@ tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(10,5 x = { a: "not ok" }; ~ !!! error TS2322: Type '{ a: string; }' is not assignable to type 'T'. +!!! error TS2322: '{ a: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ a: string; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt b/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt index e37ff82aa7b54..2ca7218764a00 100644 --- a/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt +++ b/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt @@ -1,6 +1,9 @@ tests/cases/compiler/errorMessagesIntersectionTypes03.ts(17,5): error TS2322: Type 'A & B' is not assignable to type 'T'. + 'A & B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(18,5): error TS2322: Type 'A & B' is not assignable to type 'U'. + 'A & B' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(19,5): error TS2322: Type 'A & B' is not assignable to type 'V'. + 'A & B' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(22,5): error TS2322: Type 'T & B' is not assignable to type 'U'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(23,5): error TS2322: Type 'T & B' is not assignable to type 'V'. @@ -25,12 +28,15 @@ tests/cases/compiler/errorMessagesIntersectionTypes03.ts(23,5): error TS2322: Ty t = a_and_b; ~ !!! error TS2322: Type 'A & B' is not assignable to type 'T'. +!!! error TS2322: 'A & B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = a_and_b; ~ !!! error TS2322: Type 'A & B' is not assignable to type 'U'. +!!! error TS2322: 'A & B' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'A'. v = a_and_b; ~ !!! error TS2322: Type 'A & B' is not assignable to type 'V'. +!!! error TS2322: 'A & B' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'A'. t = t_and_b; u = t_and_b; diff --git a/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt b/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt index 33d06763bbea2..732235157224d 100644 --- a/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt +++ b/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts(9,1): error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. Type 'unknown[]' is not assignable to type 'T'. + 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts (1 errors) ==== @@ -15,6 +16,7 @@ tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts(9,1): error TS2322: ~ !!! error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. !!! error TS2322: Type 'unknown[]' is not assignable to type 'T'. +!!! error TS2322: 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var s = f("str").toUpperCase(); console.log(s); diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt index ca3e195a8a762..16f2e47a1b951 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt @@ -3,12 +3,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,24): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. 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) => 1'. Type 'string' is not assignable to type '1'. @@ -51,6 +54,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r10 = foo2(1, (x) => ''); // string var r11 = foo3(1, (x: T) => '', ''); // error @@ -58,11 +62,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r11b = foo3(1, (x: T) => '', 1); // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. 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) => 1'. diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types index 1cd9e7ccd111f..9699261a641fb 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types @@ -78,15 +78,15 @@ var r4 = foo2(1, i2); // error >i2 : I2 var r4b = foo2(1, a); // any ->r4b : unknown ->foo2(1, a) : unknown +>r4b : number +>foo2(1, a) : number >foo2 : (x: T, cb: new (a: T) => U) => U >1 : 1 >a : new (x: T) => T var r5 = foo2(1, i); // any ->r5 : unknown ->foo2(1, i) : unknown +>r5 : number +>foo2(1, i) : number >foo2 : (x: T, cb: new (a: T) => U) => U >1 : 1 >i : I @@ -112,16 +112,16 @@ function foo3(x: T, cb: new(a: T) => U, y: U) { } var r7 = foo3(null, i, ''); // any ->r7 : unknown ->foo3(null, i, '') : unknown +>r7 : any +>foo3(null, i, '') : any >foo3 : (x: T, cb: new (a: T) => U, y: U) => U >null : null >i : I >'' : "" var r7b = foo3(null, a, ''); // any ->r7b : unknown ->foo3(null, a, '') : unknown +>r7b : any +>foo3(null, a, '') : any >foo3 : (x: T, cb: new (a: T) => U, y: U) => U >null : null >a : new (x: T) => T diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index a66672f515131..c308e16c224c0 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -2,12 +2,14 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type '1' 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'. Types of parameters 'a' and 'x' are incompatible. Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,43): error TS2322: Type 'F' is not assignable to type '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'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type '1' 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'. Types of parameters 'a' and 'x' are incompatible. @@ -38,6 +40,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen var r9 = r7(new Date()); // should be ok ~~~~~~~~~~ !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. +!!! error TS2345: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. var r10 = r7(1); // error ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. @@ -84,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen var r9 = r7(new Date()); ~~~~~~~~~~ !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. +!!! error TS2345: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. var r10 = r7(1); ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt index 08b5dbc177136..1f4db6be557b7 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts(19,17): error TS2345: Argument of type 'C' is not assignable to parameter of type 'D'. Property 'y' is missing in type 'C' but required in type 'D'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts(30,24): error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts (2 errors) ==== @@ -40,6 +41,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var r5 = foo(c, d); // error ~ !!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. +!!! error TS2345: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt index 0fd0f98209aa9..df3b228bf059d 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(19,23): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'. Type 'void' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(22,24): error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts (3 errors) ==== @@ -37,5 +38,6 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var r5 = foo(c, d); // error ~ !!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. +!!! error TS2345: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt index b65b21e127b43..1e3e2466ed3f0 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt @@ -1,7 +1,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(6,37): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(8,56): error TS2322: Type 'U' is not assignable to type 'V'. - Type 'T' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'V'. + 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts (3 errors) ==== @@ -12,12 +16,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC function foo3(x: T = 1) { } // error ~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'T'. +!!! error TS2322: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. function foo4(x: T, y: U = x) { } // error ~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. function foo5(x: U, y: T = x) { } // ok function foo6(x: T, y: U, z: V = y) { } // error ~~~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'V'. -!!! error TS2322: Type 'T' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'V'. +!!! error TS2322: 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. function foo7(x: V, y: U = x) { } // should be ok \ No newline at end of file diff --git a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt index ff4c2235b4925..26f97751caaf8 100644 --- a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt +++ b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt @@ -1,9 +1,11 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(2,16): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(3,16): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(4,16): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(8,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(9,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(12,17): error TS2345: Argument of type 'U' is not assignable to parameter of type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(13,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17): error TS2558: Expected 0 type arguments, but got 1. @@ -16,6 +18,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17 var r2 = f(1); ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r3 = f(null); ~~~ !!! error TS2558: Expected 0 type arguments, but got 1. @@ -33,6 +36,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17 var r12 = f(y); ~ !!! error TS2345: Argument of type 'U' is not assignable to parameter of type 'T'. +!!! error TS2345: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r22 = f(y); ~~~~~~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt index c44a1e155ac54..5366fbc9aeb32 100644 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt @@ -1,12 +1,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,29): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,30): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,31): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. 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) => 1'. Type 'string' is not assignable to type '1'. @@ -73,6 +76,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r10 = c.foo2(1, (x) => ''); // string var r11 = c3.foo3(1, (x: T) => '', ''); // error @@ -80,11 +84,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r11b = c3.foo3(1, (x: T) => '', 1); // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. 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) => 1'. diff --git a/tests/baselines/reference/genericContextualTypes1.types b/tests/baselines/reference/genericContextualTypes1.types index fb97b190d659e..e52f26e73d919 100644 --- a/tests/baselines/reference/genericContextualTypes1.types +++ b/tests/baselines/reference/genericContextualTypes1.types @@ -155,9 +155,9 @@ const arrayFilter = (f: (x: T) => boolean) => (a: T[]) => a.filter(f); >(a: T[]) => a.filter(f) : (a: T[]) => T[] >a : T[] >a.filter(f) : T[] ->a.filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; } +>a.filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; } >a : T[] ->filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; } +>filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; } >f : (x: T) => boolean const f20: (a: string[]) => number[] = arrayMap(x => x.length); diff --git a/tests/baselines/reference/genericDefaultsErrors.errors.txt b/tests/baselines/reference/genericDefaultsErrors.errors.txt index e1dca77d958d0..91d4d608f1aef 100644 --- a/tests/baselines/reference/genericDefaultsErrors.errors.txt +++ b/tests/baselines/reference/genericDefaultsErrors.errors.txt @@ -3,6 +3,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(4,59): error TS2344: Type 'T' does Type 'string' is not assignable to type 'number'. tests/cases/compiler/genericDefaultsErrors.ts(5,44): error TS2344: Type 'T' does not satisfy the constraint 'number'. tests/cases/compiler/genericDefaultsErrors.ts(6,39): error TS2344: Type 'number' does not satisfy the constraint 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericDefaultsErrors.ts(10,5): error TS2558: Expected 2-3 type arguments, but got 1. tests/cases/compiler/genericDefaultsErrors.ts(13,5): error TS2558: Expected 2-3 type arguments, but got 4. tests/cases/compiler/genericDefaultsErrors.ts(17,13): error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'. @@ -16,6 +17,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(27,52): error TS2344: Type 'T' doe Type 'string' is not assignable to type 'number'. tests/cases/compiler/genericDefaultsErrors.ts(28,37): error TS2344: Type 'T' does not satisfy the constraint 'number'. tests/cases/compiler/genericDefaultsErrors.ts(29,32): error TS2344: Type 'number' does not satisfy the constraint 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericDefaultsErrors.ts(32,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. tests/cases/compiler/genericDefaultsErrors.ts(33,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. tests/cases/compiler/genericDefaultsErrors.ts(36,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. @@ -40,6 +42,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet declare function f06(): void; // error ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'T'. +!!! error TS2344: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. declare function f11(): void; f11(); // ok @@ -88,6 +91,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet interface i08 { } // error ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'T'. +!!! error TS2344: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. interface i09 { } type i09t00 = i09; // error diff --git a/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt b/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt index 4f24a4560235e..4c15da868c5ac 100644 --- a/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt +++ b/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts(6,1): error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. Type 'unknown[]' is not assignable to type 'T'. + 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts (1 errors) ==== @@ -12,6 +13,7 @@ tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts(6,1): err ~ !!! error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. !!! error TS2322: Type 'unknown[]' is not assignable to type 'T'. +!!! error TS2322: 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var s = f("str").toUpperCase(); diff --git a/tests/baselines/reference/genericFunctionInference1.errors.txt b/tests/baselines/reference/genericFunctionInference1.errors.txt index 7fcbc93ea0dca..5c910e7ff5d26 100644 --- a/tests/baselines/reference/genericFunctionInference1.errors.txt +++ b/tests/baselines/reference/genericFunctionInference1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. +tests/cases/compiler/genericFunctionInference1.ts(135,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. Type 'number' is not assignable to type 'string'. @@ -67,6 +67,53 @@ tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument let f60 = wrap3(baz); + declare const list2: { + (a: T): T[]; + foo: string; + bar(): number; + } + + let f70 = pipe(list2, box); + let f71 = pipe(box, list2); + + declare class Point { + constructor(x: number, y: number); + readonly x: number; + readonly y: number; + } + + declare class Bag { + constructor(...args: T[]); + contains(value: T): boolean; + static foo: string; + } + + function asFunction(cf: new (...args: A) => B) { + return (...args: A) => new cf(...args); + } + + const newPoint = asFunction(Point); + const newBag = asFunction(Bag); + const p1 = new Point(10, 20); + const p2 = newPoint(10, 20); + const bag1 = new Bag(1, 2, 3); + const bag2 = newBag('a', 'b', 'c'); + + declare class Comp

{ + props: P; + constructor(props: P); + } + + type CompClass

= new (props: P) => Comp

; + + declare function myHoc

(C: CompClass

): CompClass

; + + type GenericProps = { foo: number, stuff: T }; + + declare class GenericComp extends Comp> {} + + const GenericComp2 = myHoc(GenericComp); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } diff --git a/tests/baselines/reference/genericFunctionInference1.js b/tests/baselines/reference/genericFunctionInference1.js index 7180fca9033ac..c4a23217023fc 100644 --- a/tests/baselines/reference/genericFunctionInference1.js +++ b/tests/baselines/reference/genericFunctionInference1.js @@ -63,6 +63,53 @@ declare function baz(t1: T, t2: T, u: U): [T, U]; let f60 = wrap3(baz); +declare const list2: { + (a: T): T[]; + foo: string; + bar(): number; +} + +let f70 = pipe(list2, box); +let f71 = pipe(box, list2); + +declare class Point { + constructor(x: number, y: number); + readonly x: number; + readonly y: number; +} + +declare class Bag { + constructor(...args: T[]); + contains(value: T): boolean; + static foo: string; +} + +function asFunction(cf: new (...args: A) => B) { + return (...args: A) => new cf(...args); +} + +const newPoint = asFunction(Point); +const newBag = asFunction(Bag); +const p1 = new Point(10, 20); +const p2 = newPoint(10, 20); +const bag1 = new Bag(1, 2, 3); +const bag2 = newBag('a', 'b', 'c'); + +declare class Comp

{ + props: P; + constructor(props: P); +} + +type CompClass

= new (props: P) => Comp

; + +declare function myHoc

(C: CompClass

): CompClass

; + +type GenericProps = { foo: number, stuff: T }; + +declare class GenericComp extends Comp> {} + +const GenericComp2 = myHoc(GenericComp); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } @@ -242,6 +289,18 @@ const f40 = pipe4([list, box]); const f41 = pipe4([box, list]); const f50 = pipe5(list); // No higher order inference let f60 = wrap3(baz); +let f70 = pipe(list2, box); +let f71 = pipe(box, list2); +function asFunction(cf) { + return (...args) => new cf(...args); +} +const newPoint = asFunction(Point); +const newBag = asFunction(Bag); +const p1 = new Point(10, 20); +const p2 = newPoint(10, 20); +const bag1 = new Bag(1, 2, 3); +const bag2 = newBag('a', 'b', 'c'); +const GenericComp2 = myHoc(GenericComp); // #417 function mirror(f) { return f; } var identityM = mirror(identity); diff --git a/tests/baselines/reference/genericFunctionInference1.symbols b/tests/baselines/reference/genericFunctionInference1.symbols index 9d6005de9cf31..0c2881bb1ce62 100644 --- a/tests/baselines/reference/genericFunctionInference1.symbols +++ b/tests/baselines/reference/genericFunctionInference1.symbols @@ -497,299 +497,449 @@ let f60 = wrap3(baz); >wrap3 : Symbol(wrap3, Decl(genericFunctionInference1.ts, 57, 24)) >baz : Symbol(baz, Decl(genericFunctionInference1.ts, 59, 89)) +declare const list2: { +>list2 : Symbol(list2, Decl(genericFunctionInference1.ts, 64, 13)) + + (a: T): T[]; +>T : Symbol(T, Decl(genericFunctionInference1.ts, 65, 5)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 65, 8)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 65, 5)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 65, 5)) + + foo: string; +>foo : Symbol(foo, Decl(genericFunctionInference1.ts, 65, 19)) + + bar(): number; +>bar : Symbol(bar, Decl(genericFunctionInference1.ts, 66, 16)) +} + +let f70 = pipe(list2, box); +>f70 : Symbol(f70, Decl(genericFunctionInference1.ts, 70, 3)) +>pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) +>list2 : Symbol(list2, Decl(genericFunctionInference1.ts, 64, 13)) +>box : Symbol(box, Decl(genericFunctionInference1.ts, 4, 36)) + +let f71 = pipe(box, list2); +>f71 : Symbol(f71, Decl(genericFunctionInference1.ts, 71, 3)) +>pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) +>box : Symbol(box, Decl(genericFunctionInference1.ts, 4, 36)) +>list2 : Symbol(list2, Decl(genericFunctionInference1.ts, 64, 13)) + +declare class Point { +>Point : Symbol(Point, Decl(genericFunctionInference1.ts, 71, 27)) + + constructor(x: number, y: number); +>x : Symbol(x, Decl(genericFunctionInference1.ts, 74, 16)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 74, 26)) + + readonly x: number; +>x : Symbol(Point.x, Decl(genericFunctionInference1.ts, 74, 38)) + + readonly y: number; +>y : Symbol(Point.y, Decl(genericFunctionInference1.ts, 75, 23)) +} + +declare class Bag { +>Bag : Symbol(Bag, Decl(genericFunctionInference1.ts, 77, 1)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 79, 18)) + + constructor(...args: T[]); +>args : Symbol(args, Decl(genericFunctionInference1.ts, 80, 16)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 79, 18)) + + contains(value: T): boolean; +>contains : Symbol(Bag.contains, Decl(genericFunctionInference1.ts, 80, 30)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 81, 13)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 79, 18)) + + static foo: string; +>foo : Symbol(Bag.foo, Decl(genericFunctionInference1.ts, 81, 32)) +} + +function asFunction(cf: new (...args: A) => B) { +>asFunction : Symbol(asFunction, Decl(genericFunctionInference1.ts, 83, 1)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 85, 20)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 85, 36)) +>cf : Symbol(cf, Decl(genericFunctionInference1.ts, 85, 40)) +>args : Symbol(args, Decl(genericFunctionInference1.ts, 85, 49)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 85, 20)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 85, 36)) + + return (...args: A) => new cf(...args); +>args : Symbol(args, Decl(genericFunctionInference1.ts, 86, 12)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 85, 20)) +>cf : Symbol(cf, Decl(genericFunctionInference1.ts, 85, 40)) +>args : Symbol(args, Decl(genericFunctionInference1.ts, 86, 12)) +} + +const newPoint = asFunction(Point); +>newPoint : Symbol(newPoint, Decl(genericFunctionInference1.ts, 89, 5)) +>asFunction : Symbol(asFunction, Decl(genericFunctionInference1.ts, 83, 1)) +>Point : Symbol(Point, Decl(genericFunctionInference1.ts, 71, 27)) + +const newBag = asFunction(Bag); +>newBag : Symbol(newBag, Decl(genericFunctionInference1.ts, 90, 5)) +>asFunction : Symbol(asFunction, Decl(genericFunctionInference1.ts, 83, 1)) +>Bag : Symbol(Bag, Decl(genericFunctionInference1.ts, 77, 1)) + +const p1 = new Point(10, 20); +>p1 : Symbol(p1, Decl(genericFunctionInference1.ts, 91, 5)) +>Point : Symbol(Point, Decl(genericFunctionInference1.ts, 71, 27)) + +const p2 = newPoint(10, 20); +>p2 : Symbol(p2, Decl(genericFunctionInference1.ts, 92, 5)) +>newPoint : Symbol(newPoint, Decl(genericFunctionInference1.ts, 89, 5)) + +const bag1 = new Bag(1, 2, 3); +>bag1 : Symbol(bag1, Decl(genericFunctionInference1.ts, 93, 5)) +>Bag : Symbol(Bag, Decl(genericFunctionInference1.ts, 77, 1)) + +const bag2 = newBag('a', 'b', 'c'); +>bag2 : Symbol(bag2, Decl(genericFunctionInference1.ts, 94, 5)) +>newBag : Symbol(newBag, Decl(genericFunctionInference1.ts, 90, 5)) + +declare class Comp

{ +>Comp : Symbol(Comp, Decl(genericFunctionInference1.ts, 94, 35)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 96, 19)) + + props: P; +>props : Symbol(Comp.props, Decl(genericFunctionInference1.ts, 96, 23)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 96, 19)) + + constructor(props: P); +>props : Symbol(props, Decl(genericFunctionInference1.ts, 98, 16)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 96, 19)) +} + +type CompClass

= new (props: P) => Comp

; +>CompClass : Symbol(CompClass, Decl(genericFunctionInference1.ts, 99, 1)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 101, 15)) +>props : Symbol(props, Decl(genericFunctionInference1.ts, 101, 25)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 101, 15)) +>Comp : Symbol(Comp, Decl(genericFunctionInference1.ts, 94, 35)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 101, 15)) + +declare function myHoc

(C: CompClass

): CompClass

; +>myHoc : Symbol(myHoc, Decl(genericFunctionInference1.ts, 101, 46)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 103, 23)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 103, 26)) +>CompClass : Symbol(CompClass, Decl(genericFunctionInference1.ts, 99, 1)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 103, 23)) +>CompClass : Symbol(CompClass, Decl(genericFunctionInference1.ts, 99, 1)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 103, 23)) + +type GenericProps = { foo: number, stuff: T }; +>GenericProps : Symbol(GenericProps, Decl(genericFunctionInference1.ts, 103, 57)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 105, 18)) +>foo : Symbol(foo, Decl(genericFunctionInference1.ts, 105, 24)) +>stuff : Symbol(stuff, Decl(genericFunctionInference1.ts, 105, 37)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 105, 18)) + +declare class GenericComp extends Comp> {} +>GenericComp : Symbol(GenericComp, Decl(genericFunctionInference1.ts, 105, 49)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 107, 26)) +>Comp : Symbol(Comp, Decl(genericFunctionInference1.ts, 94, 35)) +>GenericProps : Symbol(GenericProps, Decl(genericFunctionInference1.ts, 103, 57)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 107, 26)) + +const GenericComp2 = myHoc(GenericComp); +>GenericComp2 : Symbol(GenericComp2, Decl(genericFunctionInference1.ts, 109, 5)) +>myHoc : Symbol(myHoc, Decl(genericFunctionInference1.ts, 101, 46)) +>GenericComp : Symbol(GenericComp, Decl(genericFunctionInference1.ts, 105, 49)) + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } ->mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 62, 21)) ->A : Symbol(A, Decl(genericFunctionInference1.ts, 66, 16)) ->B : Symbol(B, Decl(genericFunctionInference1.ts, 66, 18)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 66, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 66, 26)) ->A : Symbol(A, Decl(genericFunctionInference1.ts, 66, 16)) ->B : Symbol(B, Decl(genericFunctionInference1.ts, 66, 18)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 66, 40)) ->A : Symbol(A, Decl(genericFunctionInference1.ts, 66, 16)) ->B : Symbol(B, Decl(genericFunctionInference1.ts, 66, 18)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 66, 22)) +>mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 109, 40)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 113, 16)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 113, 18)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 113, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 26)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 113, 16)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 113, 18)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 40)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 113, 16)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 113, 18)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 113, 22)) var identityM = mirror(identity); ->identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 67, 3)) ->mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 62, 21)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 114, 3)) +>mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 109, 40)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) var x = 1; ->x : Symbol(x, Decl(genericFunctionInference1.ts, 69, 3)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 116, 3)) var y = identity(x); ->y : Symbol(y, Decl(genericFunctionInference1.ts, 70, 3)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 69, 3)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 117, 3)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 116, 3)) var z = identityM(x); ->z : Symbol(z, Decl(genericFunctionInference1.ts, 71, 3)) ->identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 67, 3)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 69, 3)) +>z : Symbol(z, Decl(genericFunctionInference1.ts, 118, 3)) +>identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 114, 3)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 116, 3)) // #3038 export function keyOf(value: { key: a; }): a { ->keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 71, 21)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 75, 22)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 75, 25)) ->key : Symbol(key, Decl(genericFunctionInference1.ts, 75, 33)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 75, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 75, 22)) +>keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 118, 21)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 122, 22)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 122, 25)) +>key : Symbol(key, Decl(genericFunctionInference1.ts, 122, 33)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 122, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 122, 22)) return value.key; ->value.key : Symbol(key, Decl(genericFunctionInference1.ts, 75, 33)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 75, 25)) ->key : Symbol(key, Decl(genericFunctionInference1.ts, 75, 33)) +>value.key : Symbol(key, Decl(genericFunctionInference1.ts, 122, 33)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 122, 25)) +>key : Symbol(key, Decl(genericFunctionInference1.ts, 122, 33)) } export interface Data { ->Data : Symbol(Data, Decl(genericFunctionInference1.ts, 77, 1)) +>Data : Symbol(Data, Decl(genericFunctionInference1.ts, 124, 1)) key: number; ->key : Symbol(Data.key, Decl(genericFunctionInference1.ts, 78, 23)) +>key : Symbol(Data.key, Decl(genericFunctionInference1.ts, 125, 23)) value: Date; ->value : Symbol(Data.value, Decl(genericFunctionInference1.ts, 79, 16)) +>value : Symbol(Data.value, Decl(genericFunctionInference1.ts, 126, 16)) >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } var data: Data[] = []; ->data : Symbol(data, Decl(genericFunctionInference1.ts, 83, 3)) ->Data : Symbol(Data, Decl(genericFunctionInference1.ts, 77, 1)) +>data : Symbol(data, Decl(genericFunctionInference1.ts, 130, 3)) +>Data : Symbol(Data, Decl(genericFunctionInference1.ts, 124, 1)) declare function toKeys(values: a[], toKey: (value: a) => string): string[]; ->toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 83, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 85, 24)) ->values : Symbol(values, Decl(genericFunctionInference1.ts, 85, 27)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 85, 24)) ->toKey : Symbol(toKey, Decl(genericFunctionInference1.ts, 85, 39)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 85, 48)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 85, 24)) +>toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 130, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 132, 24)) +>values : Symbol(values, Decl(genericFunctionInference1.ts, 132, 27)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 132, 24)) +>toKey : Symbol(toKey, Decl(genericFunctionInference1.ts, 132, 39)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 132, 48)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 132, 24)) toKeys(data, keyOf); // Error ->toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 83, 22)) ->data : Symbol(data, Decl(genericFunctionInference1.ts, 83, 3)) ->keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 71, 21)) +>toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 130, 22)) +>data : Symbol(data, Decl(genericFunctionInference1.ts, 130, 3)) +>keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 118, 21)) // #9366 function flip(f: (a: a, b: b) => c): (b: b, a: a) => c { ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) ->c : Symbol(c, Decl(genericFunctionInference1.ts, 91, 19)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 91, 23)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 27)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 32)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) ->c : Symbol(c, Decl(genericFunctionInference1.ts, 91, 19)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 47)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 52)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) ->c : Symbol(c, Decl(genericFunctionInference1.ts, 91, 19)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 134, 20)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 138, 14)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 138, 16)) +>c : Symbol(c, Decl(genericFunctionInference1.ts, 138, 19)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 138, 23)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 138, 27)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 138, 14)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 138, 32)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 138, 16)) +>c : Symbol(c, Decl(genericFunctionInference1.ts, 138, 19)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 138, 47)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 138, 16)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 138, 52)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 138, 14)) +>c : Symbol(c, Decl(genericFunctionInference1.ts, 138, 19)) return (b: b, a: a) => f(a, b); ->b : Symbol(b, Decl(genericFunctionInference1.ts, 92, 10)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 92, 15)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 91, 23)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 92, 15)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 92, 10)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 139, 10)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 138, 16)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 139, 15)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 138, 14)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 138, 23)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 139, 15)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 139, 10)) } function zip(x: T, y: U): [T, U] { ->zip : Symbol(zip, Decl(genericFunctionInference1.ts, 93, 1)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 94, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 94, 15)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 94, 19)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 94, 13)) ->y : Symbol(y, Decl(genericFunctionInference1.ts, 94, 24)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 94, 15)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 94, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 94, 15)) +>zip : Symbol(zip, Decl(genericFunctionInference1.ts, 140, 1)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 141, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 141, 15)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 141, 19)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 141, 13)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 141, 24)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 141, 15)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 141, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 141, 15)) return [x, y]; ->x : Symbol(x, Decl(genericFunctionInference1.ts, 94, 19)) ->y : Symbol(y, Decl(genericFunctionInference1.ts, 94, 24)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 141, 19)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 141, 24)) } var expected: (y: U, x: T) => [T, U] = flip(zip); ->expected : Symbol(expected, Decl(genericFunctionInference1.ts, 98, 3)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 15)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 17)) ->y : Symbol(y, Decl(genericFunctionInference1.ts, 98, 21)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 17)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 98, 26)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 15)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 15)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 17)) ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) ->zip : Symbol(zip, Decl(genericFunctionInference1.ts, 93, 1)) +>expected : Symbol(expected, Decl(genericFunctionInference1.ts, 145, 3)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 145, 15)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 145, 17)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 145, 21)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 145, 17)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 145, 26)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 145, 15)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 145, 15)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 145, 17)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 134, 20)) +>zip : Symbol(zip, Decl(genericFunctionInference1.ts, 140, 1)) var actual = flip(zip); ->actual : Symbol(actual, Decl(genericFunctionInference1.ts, 99, 3)) ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) ->zip : Symbol(zip, Decl(genericFunctionInference1.ts, 93, 1)) +>actual : Symbol(actual, Decl(genericFunctionInference1.ts, 146, 3)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 134, 20)) +>zip : Symbol(zip, Decl(genericFunctionInference1.ts, 140, 1)) // #9366 const map = (transform: (t: T) => U) => ->map : Symbol(map, Decl(genericFunctionInference1.ts, 103, 5)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 103, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 103, 15)) ->transform : Symbol(transform, Decl(genericFunctionInference1.ts, 103, 19)) ->t : Symbol(t, Decl(genericFunctionInference1.ts, 103, 31)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 103, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 103, 15)) +>map : Symbol(map, Decl(genericFunctionInference1.ts, 150, 5)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 150, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 150, 15)) +>transform : Symbol(transform, Decl(genericFunctionInference1.ts, 150, 19)) +>t : Symbol(t, Decl(genericFunctionInference1.ts, 150, 31)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 150, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 150, 15)) (arr: T[]) => arr.map(transform) ->arr : Symbol(arr, Decl(genericFunctionInference1.ts, 104, 5)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 103, 13)) +>arr : Symbol(arr, Decl(genericFunctionInference1.ts, 151, 5)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 150, 13)) >arr.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->arr : Symbol(arr, Decl(genericFunctionInference1.ts, 104, 5)) +>arr : Symbol(arr, Decl(genericFunctionInference1.ts, 151, 5)) >map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->transform : Symbol(transform, Decl(genericFunctionInference1.ts, 103, 19)) +>transform : Symbol(transform, Decl(genericFunctionInference1.ts, 150, 19)) const identityStr = (t: string) => t; ->identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 106, 5)) ->t : Symbol(t, Decl(genericFunctionInference1.ts, 106, 21)) ->t : Symbol(t, Decl(genericFunctionInference1.ts, 106, 21)) +>identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 153, 5)) +>t : Symbol(t, Decl(genericFunctionInference1.ts, 153, 21)) +>t : Symbol(t, Decl(genericFunctionInference1.ts, 153, 21)) const arr: string[] = map(identityStr)(['a']); ->arr : Symbol(arr, Decl(genericFunctionInference1.ts, 108, 5)) ->map : Symbol(map, Decl(genericFunctionInference1.ts, 103, 5)) ->identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 106, 5)) +>arr : Symbol(arr, Decl(genericFunctionInference1.ts, 155, 5)) +>map : Symbol(map, Decl(genericFunctionInference1.ts, 150, 5)) +>identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 153, 5)) const arr1: string[] = map(identity)(['a']); ->arr1 : Symbol(arr1, Decl(genericFunctionInference1.ts, 109, 5)) ->map : Symbol(map, Decl(genericFunctionInference1.ts, 103, 5)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>arr1 : Symbol(arr1, Decl(genericFunctionInference1.ts, 156, 5)) +>map : Symbol(map, Decl(genericFunctionInference1.ts, 150, 5)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) // #9949 function of2(one: a, two: b): [a, b] { ->of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 109, 44)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 13)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 113, 15)) ->one : Symbol(one, Decl(genericFunctionInference1.ts, 113, 19)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 13)) ->two : Symbol(two, Decl(genericFunctionInference1.ts, 113, 26)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 113, 15)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 13)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 113, 15)) +>of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 156, 44)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 160, 13)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 160, 15)) +>one : Symbol(one, Decl(genericFunctionInference1.ts, 160, 19)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 160, 13)) +>two : Symbol(two, Decl(genericFunctionInference1.ts, 160, 26)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 160, 15)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 160, 13)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 160, 15)) return [one, two]; ->one : Symbol(one, Decl(genericFunctionInference1.ts, 113, 19)) ->two : Symbol(two, Decl(genericFunctionInference1.ts, 113, 26)) +>one : Symbol(one, Decl(genericFunctionInference1.ts, 160, 19)) +>two : Symbol(two, Decl(genericFunctionInference1.ts, 160, 26)) } const flipped = flip(of2); ->flipped : Symbol(flipped, Decl(genericFunctionInference1.ts, 117, 5)) ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) ->of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 109, 44)) +>flipped : Symbol(flipped, Decl(genericFunctionInference1.ts, 164, 5)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 134, 20)) +>of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 156, 44)) // #29904.1 type Component

= (props: P) => {}; ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 121, 15)) ->props : Symbol(props, Decl(genericFunctionInference1.ts, 121, 21)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 121, 15)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 164, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 168, 15)) +>props : Symbol(props, Decl(genericFunctionInference1.ts, 168, 21)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 168, 15)) declare const myHoc1:

(C: Component

) => Component

; ->myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 123, 13)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 123, 23)) ->C : Symbol(C, Decl(genericFunctionInference1.ts, 123, 26)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 123, 23)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 123, 23)) +>myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 170, 13)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 170, 23)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 170, 26)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 164, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 170, 23)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 164, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 170, 23)) declare const myHoc2:

(C: Component

) => Component

; ->myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 124, 13)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 124, 23)) ->C : Symbol(C, Decl(genericFunctionInference1.ts, 124, 26)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 124, 23)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 124, 23)) +>myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 171, 13)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 171, 23)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 171, 26)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 164, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 171, 23)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 164, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 171, 23)) declare const MyComponent1: Component<{ foo: 1 }>; ->MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 126, 13)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) ->foo : Symbol(foo, Decl(genericFunctionInference1.ts, 126, 39)) +>MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 173, 13)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 164, 26)) +>foo : Symbol(foo, Decl(genericFunctionInference1.ts, 173, 39)) const enhance = pipe( ->enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 128, 5)) +>enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 175, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) myHoc1, ->myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 123, 13)) +>myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 170, 13)) myHoc2, ->myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 124, 13)) +>myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 171, 13)) ); const MyComponent2 = enhance(MyComponent1); ->MyComponent2 : Symbol(MyComponent2, Decl(genericFunctionInference1.ts, 133, 5)) ->enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 128, 5)) ->MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 126, 13)) +>MyComponent2 : Symbol(MyComponent2, Decl(genericFunctionInference1.ts, 180, 5)) +>enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 175, 5)) +>MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 173, 13)) // #29904.2 const fn20 = pipe((_a?: {}) => 1); ->fn20 : Symbol(fn20, Decl(genericFunctionInference1.ts, 137, 5)) +>fn20 : Symbol(fn20, Decl(genericFunctionInference1.ts, 184, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) ->_a : Symbol(_a, Decl(genericFunctionInference1.ts, 137, 19)) +>_a : Symbol(_a, Decl(genericFunctionInference1.ts, 184, 19)) // #29904.3 type Fn = (n: number) => number; ->Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 137, 34)) ->n : Symbol(n, Decl(genericFunctionInference1.ts, 141, 11)) +>Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 184, 34)) +>n : Symbol(n, Decl(genericFunctionInference1.ts, 188, 11)) const fn30: Fn = pipe( ->fn30 : Symbol(fn30, Decl(genericFunctionInference1.ts, 142, 5)) ->Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 137, 34)) +>fn30 : Symbol(fn30, Decl(genericFunctionInference1.ts, 189, 5)) +>Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 184, 34)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) x => x + 1, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 142, 22)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 142, 22)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 189, 22)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 189, 22)) x => x * 2, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 143, 15)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 143, 15)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 190, 15)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 190, 15)) ); const promise = Promise.resolve(1); ->promise : Symbol(promise, Decl(genericFunctionInference1.ts, 147, 5)) +>promise : Symbol(promise, Decl(genericFunctionInference1.ts, 194, 5)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) promise.then( >promise.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->promise : Symbol(promise, Decl(genericFunctionInference1.ts, 147, 5)) +>promise : Symbol(promise, Decl(genericFunctionInference1.ts, 194, 5)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) pipe( >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) x => x + 1, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 149, 9)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 149, 9)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 196, 9)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 196, 9)) x => x * 2, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 150, 19)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 150, 19)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 197, 19)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 197, 19)) ), ); @@ -797,137 +947,137 @@ promise.then( // #29904.4 declare const getString: () => string; ->getString : Symbol(getString, Decl(genericFunctionInference1.ts, 157, 13)) +>getString : Symbol(getString, Decl(genericFunctionInference1.ts, 204, 13)) declare const orUndefined: (name: string) => string | undefined; ->orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 158, 13)) ->name : Symbol(name, Decl(genericFunctionInference1.ts, 158, 28)) +>orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 205, 13)) +>name : Symbol(name, Decl(genericFunctionInference1.ts, 205, 28)) declare const identity: (value: T) => T; ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 159, 25)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 159, 28)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 159, 25)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 159, 25)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 206, 25)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 206, 28)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 206, 25)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 206, 25)) const fn40 = pipe( ->fn40 : Symbol(fn40, Decl(genericFunctionInference1.ts, 161, 5)) +>fn40 : Symbol(fn40, Decl(genericFunctionInference1.ts, 208, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getString, ->getString : Symbol(getString, Decl(genericFunctionInference1.ts, 157, 13)) +>getString : Symbol(getString, Decl(genericFunctionInference1.ts, 204, 13)) string => orUndefined(string), ->string : Symbol(string, Decl(genericFunctionInference1.ts, 162, 14)) ->orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 158, 13)) ->string : Symbol(string, Decl(genericFunctionInference1.ts, 162, 14)) +>string : Symbol(string, Decl(genericFunctionInference1.ts, 209, 14)) +>orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 205, 13)) +>string : Symbol(string, Decl(genericFunctionInference1.ts, 209, 14)) identity, ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) ); // #29904.6 declare const getArray: () => string[]; ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 216, 13)) declare const first: (ts: T[]) => T; ->first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 170, 22)) ->ts : Symbol(ts, Decl(genericFunctionInference1.ts, 170, 25)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 170, 22)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 170, 22)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 217, 13)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 217, 22)) +>ts : Symbol(ts, Decl(genericFunctionInference1.ts, 217, 25)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 217, 22)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 217, 22)) const fn60 = pipe( ->fn60 : Symbol(fn60, Decl(genericFunctionInference1.ts, 172, 5)) +>fn60 : Symbol(fn60, Decl(genericFunctionInference1.ts, 219, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getArray, ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 216, 13)) x => x, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 173, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 173, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 220, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 220, 13)) first, ->first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 217, 13)) ); const fn61 = pipe( ->fn61 : Symbol(fn61, Decl(genericFunctionInference1.ts, 178, 5)) +>fn61 : Symbol(fn61, Decl(genericFunctionInference1.ts, 225, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getArray, ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 216, 13)) identity, ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) first, ->first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 217, 13)) ); const fn62 = pipe( ->fn62 : Symbol(fn62, Decl(genericFunctionInference1.ts, 184, 5)) +>fn62 : Symbol(fn62, Decl(genericFunctionInference1.ts, 231, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getArray, ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 216, 13)) x => x, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 185, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 185, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 232, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 232, 13)) x => first(x), ->x : Symbol(x, Decl(genericFunctionInference1.ts, 186, 11)) ->first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 186, 11)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 233, 11)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 217, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 233, 11)) ); // Repro from #30297 declare function foo2(fn: T, a?: U, b?: U): [T, U]; ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) ->fn : Symbol(fn, Decl(genericFunctionInference1.ts, 192, 32)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 192, 38)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 192, 45)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 235, 2)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 239, 22)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 239, 24)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 239, 22)) +>fn : Symbol(fn, Decl(genericFunctionInference1.ts, 239, 32)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 239, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 239, 38)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 239, 24)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 239, 45)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 239, 24)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 239, 22)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 239, 24)) foo2(() => {}); ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 235, 2)) foo2(identity); ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 235, 2)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) foo2(identity, 1); ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 235, 2)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) // Repro from #30324 declare function times(fn: (i: number) => T): (n: number) => T[]; ->times : Symbol(times, Decl(genericFunctionInference1.ts, 196, 18)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 200, 23)) ->fn : Symbol(fn, Decl(genericFunctionInference1.ts, 200, 26)) ->i : Symbol(i, Decl(genericFunctionInference1.ts, 200, 31)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 200, 23)) ->n : Symbol(n, Decl(genericFunctionInference1.ts, 200, 50)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 200, 23)) +>times : Symbol(times, Decl(genericFunctionInference1.ts, 243, 18)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 247, 23)) +>fn : Symbol(fn, Decl(genericFunctionInference1.ts, 247, 26)) +>i : Symbol(i, Decl(genericFunctionInference1.ts, 247, 31)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 247, 23)) +>n : Symbol(n, Decl(genericFunctionInference1.ts, 247, 50)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 247, 23)) const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] ->a2 : Symbol(a2, Decl(genericFunctionInference1.ts, 201, 5)) ->times : Symbol(times, Decl(genericFunctionInference1.ts, 196, 18)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>a2 : Symbol(a2, Decl(genericFunctionInference1.ts, 248, 5)) +>times : Symbol(times, Decl(genericFunctionInference1.ts, 243, 18)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 206, 13)) diff --git a/tests/baselines/reference/genericFunctionInference1.types b/tests/baselines/reference/genericFunctionInference1.types index 5df3fa398c51c..1974fe17bea80 100644 --- a/tests/baselines/reference/genericFunctionInference1.types +++ b/tests/baselines/reference/genericFunctionInference1.types @@ -443,6 +443,150 @@ let f60 = wrap3(baz); >wrap3 : (f: (a: A, b1: B, b2: B) => C) => (a: A, b1: B, b2: B) => C >baz : (t1: T, t2: T, u: U) => [T, U] +declare const list2: { +>list2 : { (a: T): T[]; foo: string; bar(): number; } + + (a: T): T[]; +>a : T + + foo: string; +>foo : string + + bar(): number; +>bar : () => number +} + +let f70 = pipe(list2, box); +>f70 : (a: T) => { value: T[]; } +>pipe(list2, box) : (a: T) => { value: T[]; } +>pipe : { (ab: (...args: A) => B): (...args: A) => B; (ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; (ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; } +>list2 : { (a: T): T[]; foo: string; bar(): number; } +>box : (x: V) => { value: V; } + +let f71 = pipe(box, list2); +>f71 : (x: V) => { value: V; }[] +>pipe(box, list2) : (x: V) => { value: V; }[] +>pipe : { (ab: (...args: A) => B): (...args: A) => B; (ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; (ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; } +>box : (x: V) => { value: V; } +>list2 : { (a: T): T[]; foo: string; bar(): number; } + +declare class Point { +>Point : Point + + constructor(x: number, y: number); +>x : number +>y : number + + readonly x: number; +>x : number + + readonly y: number; +>y : number +} + +declare class Bag { +>Bag : Bag + + constructor(...args: T[]); +>args : T[] + + contains(value: T): boolean; +>contains : (value: T) => boolean +>value : T + + static foo: string; +>foo : string +} + +function asFunction(cf: new (...args: A) => B) { +>asFunction : (cf: new (...args: A) => B) => (...args: A) => B +>cf : new (...args: A) => B +>args : A + + return (...args: A) => new cf(...args); +>(...args: A) => new cf(...args) : (...args: A) => B +>args : A +>new cf(...args) : B +>cf : new (...args: A) => B +>...args : any +>args : A +} + +const newPoint = asFunction(Point); +>newPoint : (x: number, y: number) => Point +>asFunction(Point) : (x: number, y: number) => Point +>asFunction : (cf: new (...args: A) => B) => (...args: A) => B +>Point : typeof Point + +const newBag = asFunction(Bag); +>newBag : (...args: T[]) => Bag +>asFunction(Bag) : (...args: T[]) => Bag +>asFunction : (cf: new (...args: A) => B) => (...args: A) => B +>Bag : typeof Bag + +const p1 = new Point(10, 20); +>p1 : Point +>new Point(10, 20) : Point +>Point : typeof Point +>10 : 10 +>20 : 20 + +const p2 = newPoint(10, 20); +>p2 : Point +>newPoint(10, 20) : Point +>newPoint : (x: number, y: number) => Point +>10 : 10 +>20 : 20 + +const bag1 = new Bag(1, 2, 3); +>bag1 : Bag +>new Bag(1, 2, 3) : Bag +>Bag : typeof Bag +>1 : 1 +>2 : 2 +>3 : 3 + +const bag2 = newBag('a', 'b', 'c'); +>bag2 : Bag +>newBag('a', 'b', 'c') : Bag +>newBag : (...args: T[]) => Bag +>'a' : "a" +>'b' : "b" +>'c' : "c" + +declare class Comp

{ +>Comp : Comp

+ + props: P; +>props : P + + constructor(props: P); +>props : P +} + +type CompClass

= new (props: P) => Comp

; +>CompClass : CompClass

+>props : P + +declare function myHoc

(C: CompClass

): CompClass

; +>myHoc :

(C: CompClass

) => CompClass

+>C : CompClass

+ +type GenericProps = { foo: number, stuff: T }; +>GenericProps : GenericProps +>foo : number +>stuff : T + +declare class GenericComp extends Comp> {} +>GenericComp : GenericComp +>Comp : Comp> + +const GenericComp2 = myHoc(GenericComp); +>GenericComp2 : new (props: GenericProps) => Comp> +>myHoc(GenericComp) : new (props: GenericProps) => Comp> +>myHoc :

(C: CompClass

) => CompClass

+>GenericComp : typeof GenericComp + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } @@ -835,7 +979,7 @@ foo2(() => {}); >() => {} : () => void foo2(identity); ->foo2(identity) : [(value: T) => T, unknown] +>foo2(identity) : [(value: T) => T, (value: T) => T] >foo2 : (fn: T, a?: U | undefined, b?: U | undefined) => [T, U] >identity : (value: T) => T diff --git a/tests/baselines/reference/genericMethodOverspecialization.types b/tests/baselines/reference/genericMethodOverspecialization.types index dbc3a62653c2d..23475f966d684 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.types +++ b/tests/baselines/reference/genericMethodOverspecialization.types @@ -47,9 +47,9 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : HTMLElement[] >elements.filter(function (e) { return !e.isDisabled;}) : HTMLElement[] ->elements.filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any): HTMLElement[]; } +>elements.filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => unknown, thisArg?: any): HTMLElement[]; } >elements : HTMLElement[] ->filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any): HTMLElement[]; } +>filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => unknown, thisArg?: any): HTMLElement[]; } >function (e) { return !e.isDisabled;} : (e: HTMLElement) => boolean >e : HTMLElement diff --git a/tests/baselines/reference/genericTypeAssertions4.errors.txt b/tests/baselines/reference/genericTypeAssertions4.errors.txt index 4c23bd6d4585b..6a74d8fe26513 100644 --- a/tests/baselines/reference/genericTypeAssertions4.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions4.errors.txt @@ -1,8 +1,13 @@ tests/cases/compiler/genericTypeAssertions4.ts(19,5): error TS2322: Type 'A' is not assignable to type 'T'. + 'A' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions4.ts(20,5): error TS2322: Type 'B' is not assignable to type 'T'. + 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions4.ts(21,5): error TS2322: Type 'C' is not assignable to type 'T'. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions4.ts(23,9): error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions4.ts(24,9): error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. ==== tests/cases/compiler/genericTypeAssertions4.ts (5 errors) ==== @@ -27,17 +32,22 @@ tests/cases/compiler/genericTypeAssertions4.ts(24,9): error TS2352: Conversion o y = a; // error: cannot convert A to T ~ !!! error TS2322: Type 'A' is not assignable to type 'T'. +!!! error TS2322: 'A' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = b; // error: cannot convert B to T ~ !!! error TS2322: Type 'B' is not assignable to type 'T'. +!!! error TS2322: 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = c; // error: cannot convert C to T ~ !!! error TS2322: Type 'C' is not assignable to type 'T'. +!!! error TS2322: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = a; y = b; // error: cannot convert B to T ~~~~ !!! error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = c; // error: cannot convert C to T ~~~~ !!! error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeAssertions5.errors.txt b/tests/baselines/reference/genericTypeAssertions5.errors.txt index e01b90d72a5f8..d2eea8157aa60 100644 --- a/tests/baselines/reference/genericTypeAssertions5.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions5.errors.txt @@ -1,8 +1,13 @@ tests/cases/compiler/genericTypeAssertions5.ts(19,5): error TS2322: Type 'A' is not assignable to type 'T'. + 'A' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions5.ts(20,5): error TS2322: Type 'B' is not assignable to type 'T'. + 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions5.ts(21,5): error TS2322: Type 'C' is not assignable to type 'T'. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions5.ts(23,9): error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/genericTypeAssertions5.ts(24,9): error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. ==== tests/cases/compiler/genericTypeAssertions5.ts (5 errors) ==== @@ -27,17 +32,22 @@ tests/cases/compiler/genericTypeAssertions5.ts(24,9): error TS2352: Conversion o y = a; // error: cannot convert A to T ~ !!! error TS2322: Type 'A' is not assignable to type 'T'. +!!! error TS2322: 'A' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = b; // error: cannot convert B to T ~ !!! error TS2322: Type 'B' is not assignable to type 'T'. +!!! error TS2322: 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = c; // error: cannot convert C to T ~ !!! error TS2322: Type 'C' is not assignable to type 'T'. +!!! error TS2322: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = a; y = b; // error: cannot convert B to T ~~~~ !!! error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: 'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. y = c; // error: cannot convert C to T ~~~~ !!! error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeAssertions6.errors.txt b/tests/baselines/reference/genericTypeAssertions6.errors.txt index ef65803a47d98..9aeebcf11b12a 100644 --- a/tests/baselines/reference/genericTypeAssertions6.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions6.errors.txt @@ -1,7 +1,11 @@ tests/cases/compiler/genericTypeAssertions6.ts(8,13): error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Conversion of type 'T' to type 'U' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Type 'Date' is not comparable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not comparable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. ==== tests/cases/compiler/genericTypeAssertions6.ts (3 errors) ==== @@ -15,9 +19,11 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion x = y; ~~~~ !!! error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; ~~~~ !!! error TS2352: Conversion of type 'T' to type 'U' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } } @@ -30,7 +36,9 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion var e = new Date(); ~~~~~~~~~~~~~~~~ !!! error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Type 'Date' is not comparable to type 'T'. +!!! error TS2352: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2352: Type 'Date' is not comparable to type 'T'. +!!! error TS2352: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } } diff --git a/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt b/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt index 6a243650b1eab..fe1aaf3f8de08 100644 --- a/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt +++ b/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/genericWithOpenTypeParameters1.ts(7,40): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericWithOpenTypeParameters1.ts(8,41): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,41): error TS2558: Expected 0 type arguments, but got 1. @@ -13,6 +14,7 @@ tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,41): error TS2558: Expe var f = (x: B) => { return x.foo(1); } // error ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var f2 = (x: B) => { return x.foo(1); } // error ~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt index c9fae8cc89c4a..12770e4ca0ee0 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt @@ -4,6 +4,7 @@ tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A' is not assignable to type 'A'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/getAndSetNotIdenticalType2.ts (5 errors) ==== @@ -27,6 +28,7 @@ tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A' is not assignable to type 'A'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } diff --git a/tests/baselines/reference/globalThisCollision.errors.txt b/tests/baselines/reference/globalThisCollision.errors.txt new file mode 100644 index 0000000000000..ea0fb9d9f434b --- /dev/null +++ b/tests/baselines/reference/globalThisCollision.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es2019/globalThisCollision.js(1,5): error TS2397: Declaration name conflicts with built-in global identifier 'globalThis'. + + +==== tests/cases/conformance/es2019/globalThisCollision.js (1 errors) ==== + var globalThis; + ~~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'globalThis'. \ No newline at end of file diff --git a/tests/baselines/reference/globalThisCollision.symbols b/tests/baselines/reference/globalThisCollision.symbols new file mode 100644 index 0000000000000..088357fd537db --- /dev/null +++ b/tests/baselines/reference/globalThisCollision.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es2019/globalThisCollision.js === +var globalThis; +>globalThis : Symbol(globalThis, Decl(globalThisCollision.js, 0, 3)) + diff --git a/tests/baselines/reference/globalThisCollision.types b/tests/baselines/reference/globalThisCollision.types new file mode 100644 index 0000000000000..476533be18cae --- /dev/null +++ b/tests/baselines/reference/globalThisCollision.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es2019/globalThisCollision.js === +var globalThis; +>globalThis : any + diff --git a/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt b/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt index 576013f43c535..3174290c6ab51 100644 --- a/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt +++ b/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/implementGenericWithMismatchedTypes.ts(8,5): error TS2416: tests/cases/compiler/implementGenericWithMismatchedTypes.ts(17,5): error TS2416: Property 'foo' in type 'C2' is not assignable to the same property in base type 'IFoo2'. Type '(x: Tstring) => number' is not assignable to type '(x: T) => T'. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/implementGenericWithMismatchedTypes.ts (2 errors) ==== @@ -34,6 +35,7 @@ tests/cases/compiler/implementGenericWithMismatchedTypes.ts(17,5): error TS2416: !!! error TS2416: Property 'foo' in type 'C2' is not assignable to the same property in base type 'IFoo2'. !!! error TS2416: Type '(x: Tstring) => number' is not assignable to type '(x: T) => T'. !!! error TS2416: Type 'number' is not assignable to type 'T'. +!!! error TS2416: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. return null; } } \ No newline at end of file diff --git a/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt b/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt index e36eaf21311f7..590731e4a2965 100644 --- a/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt +++ b/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts(6,9): error TS2719: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts (1 errors) ==== @@ -10,6 +11,7 @@ tests/cases/compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts(6,9): erro this.x = a; ~~~~~~ !!! error TS2719: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2719: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } \ No newline at end of file diff --git a/tests/baselines/reference/indexSignatureAndMappedType.errors.txt b/tests/baselines/reference/indexSignatureAndMappedType.errors.txt index 623fcd11bd050..7e94dbed718c4 100644 --- a/tests/baselines/reference/indexSignatureAndMappedType.errors.txt +++ b/tests/baselines/reference/indexSignatureAndMappedType.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/indexSignatureAndMappedType.ts(6,5): error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record'. tests/cases/compiler/indexSignatureAndMappedType.ts(15,5): error TS2322: Type 'Record' is not assignable to type '{ [key: string]: T; }'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/indexSignatureAndMappedType.ts(16,5): error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record'. @@ -25,6 +26,7 @@ tests/cases/compiler/indexSignatureAndMappedType.ts(16,5): error TS2322: Type '{ ~ !!! error TS2322: Type 'Record' is not assignable to type '{ [key: string]: T; }'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Error ~ !!! error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record'. diff --git a/tests/baselines/reference/inferTypes2.js b/tests/baselines/reference/inferTypes2.js index 2b2c318716aa9..b71a339f3e079 100644 --- a/tests/baselines/reference/inferTypes2.js +++ b/tests/baselines/reference/inferTypes2.js @@ -12,6 +12,14 @@ export declare function foo2(obj: T): T extends { [K in keyof BadNested(obj: T) { return foo2(obj); } + +// Repros from #31099 + +type Weird = any extends infer U ? U : never; +type AlsoWeird = unknown extends infer U ? U : never; + +const a: Weird = null; +const b: string = a; //// [inferTypes2.js] @@ -26,6 +34,8 @@ function bar2(obj) { return foo2(obj); } exports.bar2 = bar2; +var a = null; +var b = a; //// [inferTypes2.d.ts] diff --git a/tests/baselines/reference/inferTypes2.symbols b/tests/baselines/reference/inferTypes2.symbols index d32d9a7012bee..8d792ea79c225 100644 --- a/tests/baselines/reference/inferTypes2.symbols +++ b/tests/baselines/reference/inferTypes2.symbols @@ -53,3 +53,23 @@ export function bar2(obj: T) { >obj : Symbol(obj, Decl(inferTypes2.ts, 10, 24)) } +// Repros from #31099 + +type Weird = any extends infer U ? U : never; +>Weird : Symbol(Weird, Decl(inferTypes2.ts, 12, 1)) +>U : Symbol(U, Decl(inferTypes2.ts, 16, 30)) +>U : Symbol(U, Decl(inferTypes2.ts, 16, 30)) + +type AlsoWeird = unknown extends infer U ? U : never; +>AlsoWeird : Symbol(AlsoWeird, Decl(inferTypes2.ts, 16, 45)) +>U : Symbol(U, Decl(inferTypes2.ts, 17, 38)) +>U : Symbol(U, Decl(inferTypes2.ts, 17, 38)) + +const a: Weird = null; +>a : Symbol(a, Decl(inferTypes2.ts, 19, 5)) +>Weird : Symbol(Weird, Decl(inferTypes2.ts, 12, 1)) + +const b: string = a; +>b : Symbol(b, Decl(inferTypes2.ts, 20, 5)) +>a : Symbol(a, Decl(inferTypes2.ts, 19, 5)) + diff --git a/tests/baselines/reference/inferTypes2.types b/tests/baselines/reference/inferTypes2.types index 95fec4307569e..04ca9ea6d0553 100644 --- a/tests/baselines/reference/inferTypes2.types +++ b/tests/baselines/reference/inferTypes2.types @@ -33,3 +33,19 @@ export function bar2(obj: T) { >obj : T } +// Repros from #31099 + +type Weird = any extends infer U ? U : never; +>Weird : any + +type AlsoWeird = unknown extends infer U ? U : never; +>AlsoWeird : unknown + +const a: Weird = null; +>a : any +>null : null + +const b: string = a; +>b : string +>a : any + diff --git a/tests/baselines/reference/infiniteExpansionThroughInstantiation.errors.txt b/tests/baselines/reference/infiniteExpansionThroughInstantiation.errors.txt index c8367bef57bd1..2df05fd6a04e0 100644 --- a/tests/baselines/reference/infiniteExpansionThroughInstantiation.errors.txt +++ b/tests/baselines/reference/infiniteExpansionThroughInstantiation.errors.txt @@ -4,6 +4,7 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansion tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts(21,5): error TS2322: Type 'OwnerList' is not assignable to type 'List'. Types of property 'data' are incompatible. Type 'List' is not assignable to type 'T'. + 'List' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts (2 errors) ==== @@ -36,6 +37,7 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansion !!! error TS2322: Type 'OwnerList' is not assignable to type 'List'. !!! error TS2322: Types of property 'data' are incompatible. !!! error TS2322: Type 'List' is not assignable to type 'T'. +!!! error TS2322: 'List' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeInference.errors.txt b/tests/baselines/reference/intersectionTypeInference.errors.txt index af0b1b447bcaf..b6c8ef8aa4e73 100644 --- a/tests/baselines/reference/intersectionTypeInference.errors.txt +++ b/tests/baselines/reference/intersectionTypeInference.errors.txt @@ -1,7 +1,9 @@ tests/cases/conformance/types/intersection/intersectionTypeInference.ts(5,5): error TS2322: Type 'T' is not assignable to type 'T & U'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): error TS2322: Type 'U' is not assignable to type 'T & U'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/intersection/intersectionTypeInference.ts (2 errors) ==== @@ -13,10 +15,12 @@ tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): er ~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'T & U'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. result = obj2; // Error ~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'T & U'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. return result; } diff --git a/tests/baselines/reference/invalidBooleanAssignments.errors.txt b/tests/baselines/reference/invalidBooleanAssignments.errors.txt index 06ec14b4dd6eb..bfa14d090a6f6 100644 --- a/tests/baselines/reference/invalidBooleanAssignments.errors.txt +++ b/tests/baselines/reference/invalidBooleanAssignments.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(15 tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(17,5): error TS2322: Type 'true' is not assignable to type '() => string'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(21,1): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(24,5): error TS2322: Type 'boolean' is not assignable to type 'T'. + 'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26,1): error TS2539: Cannot assign to 'i' because it is not a variable. @@ -53,6 +54,7 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26 a = x; ~ !!! error TS2322: Type 'boolean' is not assignable to type 'T'. +!!! error TS2322: 'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } i = x; ~ diff --git a/tests/baselines/reference/invalidNumberAssignments.errors.txt b/tests/baselines/reference/invalidNumberAssignments.errors.txt index 102376f1c501e..6ddda47eefab9 100644 --- a/tests/baselines/reference/invalidNumberAssignments.errors.txt +++ b/tests/baselines/reference/invalidNumberAssignments.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(14,5 tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(18,1): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(21,5): error TS2322: Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1): error TS2539: Cannot assign to 'i' because it is not a variable. @@ -50,6 +51,7 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1 a = x; ~ !!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } i = x; ~ diff --git a/tests/baselines/reference/invalidStringAssignments.errors.txt b/tests/baselines/reference/invalidStringAssignments.errors.txt index 728ce09e6b41e..5ef87e2b94dd5 100644 --- a/tests/baselines/reference/invalidStringAssignments.errors.txt +++ b/tests/baselines/reference/invalidStringAssignments.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5 tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2539: Cannot assign to 'i' because it is not a variable. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5): error TS2322: Type 'string' is not assignable to type 'E'. @@ -51,6 +52,7 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5 a = x; ~ !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } i = x; ~ diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt b/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt index 9a937066374ab..5b749df2cab36 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt @@ -8,7 +8,9 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(14,5): error TS273 tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(15,5): error TS2322: Type 'T' is not assignable to type '{ x: number; y: number; }'. Type '{ [key: string]: number; }' is missing the following properties from type '{ x: number; y: number; }': x, y tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(18,5): error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'T'. + '{ x: number; y: number; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ [key: string]: number; }'. tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(19,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type 'T'. + '{ [key: string]: number; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ [key: string]: number; }'. tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(26,7): error TS2339: Property 'x' does not exist on type 'T'. tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(27,5): error TS2322: Type '1' is not assignable to type 'T[keyof T]'. tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(31,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type '{ [P in K]: number; }'. @@ -65,9 +67,11 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23 c = a; // Error, constraint on target doesn't imply any properties or signatures ~ !!! error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'T'. +!!! error TS2322: '{ x: number; y: number; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ [key: string]: number; }'. c = b; // Error, constraint on target doesn't imply any properties or signatures ~ !!! error TS2322: Type '{ [key: string]: number; }' is not assignable to type 'T'. +!!! error TS2322: '{ [key: string]: number; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ [key: string]: number; }'. a.x; b.x; c.x; @@ -204,4 +208,15 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23 function fn2>(param: T, cb: (element: T[number]) => void) { cb(param[0]); } + + // Repro from #31149 + + function fn3>(param: T, cb: (element: T[number]) => void) { + cb(param[0]); + } + + function fn4() { + let x: Array[K] = 'abc'; + let y: ReadonlyArray[K] = 'abc'; + } \ No newline at end of file diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.js b/tests/baselines/reference/keyofAndIndexedAccess2.js index 906bcd0eab3de..7bf53b9fba491 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.js +++ b/tests/baselines/reference/keyofAndIndexedAccess2.js @@ -125,6 +125,17 @@ function fn} | {elements: Array}>(par function fn2>(param: T, cb: (element: T[number]) => void) { cb(param[0]); } + +// Repro from #31149 + +function fn3>(param: T, cb: (element: T[number]) => void) { + cb(param[0]); +} + +function fn4() { + let x: Array[K] = 'abc'; + let y: ReadonlyArray[K] = 'abc'; +} //// [keyofAndIndexedAccess2.js] @@ -207,3 +218,11 @@ function fn(param, cb) { function fn2(param, cb) { cb(param[0]); } +// Repro from #31149 +function fn3(param, cb) { + cb(param[0]); +} +function fn4() { + let x = 'abc'; + let y = 'abc'; +} diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.symbols b/tests/baselines/reference/keyofAndIndexedAccess2.symbols index 24e1a8b0674e7..2155451ef7497 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess2.symbols @@ -471,3 +471,35 @@ function fn2>(param: T, cb: (element: T[number]) => void >param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 123, 38)) } +// Repro from #31149 + +function fn3>(param: T, cb: (element: T[number]) => void) { +>fn3 : Symbol(fn3, Decl(keyofAndIndexedAccess2.ts, 125, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) +>param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 129, 46)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13)) +>cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 129, 55)) +>element : Symbol(element, Decl(keyofAndIndexedAccess2.ts, 129, 61)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13)) + + cb(param[0]); +>cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 129, 55)) +>param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 129, 46)) +} + +function fn4() { +>fn4 : Symbol(fn4, Decl(keyofAndIndexedAccess2.ts, 131, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) + + let x: Array[K] = 'abc'; +>x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 134, 7)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) + + let y: ReadonlyArray[K] = 'abc'; +>y : Symbol(y, Decl(keyofAndIndexedAccess2.ts, 135, 7)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) +} + diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.types b/tests/baselines/reference/keyofAndIndexedAccess2.types index 6c0f3dff934d8..af43ed0f4eb27 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.types +++ b/tests/baselines/reference/keyofAndIndexedAccess2.types @@ -471,3 +471,31 @@ function fn2>(param: T, cb: (element: T[number]) => void >0 : 0 } +// Repro from #31149 + +function fn3>(param: T, cb: (element: T[number]) => void) { +>fn3 : (param: T, cb: (element: T[number]) => void) => void +>param : T +>cb : (element: T[number]) => void +>element : T[number] + + cb(param[0]); +>cb(param[0]) : void +>cb : (element: T[number]) => void +>param[0] : string +>param : T +>0 : 0 +} + +function fn4() { +>fn4 : () => void + + let x: Array[K] = 'abc'; +>x : string[][K] +>'abc' : "abc" + + let y: ReadonlyArray[K] = 'abc'; +>y : readonly string[][K] +>'abc' : "abc" +} + diff --git a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt index b0eaac39c6d21..68e56efb38ab9 100644 --- a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt @@ -44,23 +44,36 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(87,5): error Type 'keyof T' is not assignable to type 'keyof T & keyof U'. Type 'keyof T' is not assignable to type 'keyof U'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(103,9): error TS2322: Type 'Extract' is not assignable to type 'K'. - Type 'string & keyof T' is not assignable to type 'K'. - Type 'string' is not assignable to type 'K'. - Type 'string' is not assignable to type 'K'. + 'Extract' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. + Type 'string & keyof T' is not assignable to type 'K'. + 'string & keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. + Type 'string' is not assignable to type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. + Type 'string' is not assignable to type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(105,9): error TS2322: Type 'T[Extract]' is not assignable to type 'T[K]'. Type 'Extract' is not assignable to type 'K'. + 'Extract' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(108,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(111,5): error TS2322: Type 'T[J]' is not assignable to type 'U[J]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(114,5): error TS2322: Type 'T[K]' is not assignable to type 'T[J]'. Type 'K' is not assignable to type 'J'. - Type 'Extract' is not assignable to type 'J'. - Type 'string & keyof T' is not assignable to type 'J'. - Type 'string' is not assignable to type 'J'. - Type 'string' is not assignable to type 'J'. + 'K' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. + Type 'Extract' is not assignable to type 'J'. + 'Extract' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. + Type 'string & keyof T' is not assignable to type 'J'. + 'string & keyof T' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. + Type 'string' is not assignable to type 'J'. + 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. + Type 'string' is not assignable to type 'J'. + 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error TS2322: Type 'T[K]' is not assignable to type 'U[J]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(122,5): error TS2322: Type '42' is not assignable to type 'keyof T'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error TS2322: Type '"hello"' is not assignable to type 'keyof T'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(140,5): error TS2322: Type '42' is not assignable to type 'T[K]'. @@ -249,42 +262,55 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error k = key // error, keyof T =/=> K ~ !!! error TS2322: Type 'Extract' is not assignable to type 'K'. -!!! error TS2322: Type 'string & keyof T' is not assignable to type 'K'. -!!! error TS2322: Type 'string' is not assignable to type 'K'. -!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'Extract' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'string & keyof T' is not assignable to type 'K'. +!!! error TS2322: 'string & keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. t[key] = tk; // ok, T[K] ==> T[keyof T] tk = t[key]; // error, T[keyof T] =/=> T[K] ~~ !!! error TS2322: Type 'T[Extract]' is not assignable to type 'T[K]'. !!! error TS2322: Type 'Extract' is not assignable to type 'K'. +!!! error TS2322: 'Extract' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. } tk = uk; uk = tk; // error ~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tj = uj; uj = tj; // error ~~ !!! error TS2322: Type 'T[J]' is not assignable to type 'U[J]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tk = tj; tj = tk; // error ~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'T[J]'. !!! error TS2322: Type 'K' is not assignable to type 'J'. -!!! error TS2322: Type 'Extract' is not assignable to type 'J'. -!!! error TS2322: Type 'string & keyof T' is not assignable to type 'J'. -!!! error TS2322: Type 'string' is not assignable to type 'J'. -!!! error TS2322: Type 'string' is not assignable to type 'J'. +!!! error TS2322: 'K' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'Extract' is not assignable to type 'J'. +!!! error TS2322: 'Extract' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'string & keyof T' is not assignable to type 'J'. +!!! error TS2322: 'string & keyof T' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'string' is not assignable to type 'J'. +!!! error TS2322: 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: Type 'string' is not assignable to type 'J'. +!!! error TS2322: 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. tk = uj; uj = tk; // error ~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[J]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } // The constraint of 'keyof T' is 'keyof T' diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index d66312c0f178e..6e76eb4721c10 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -1,7 +1,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(11,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(16,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(20,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(25,5): error TS2536: Type 'K' cannot be used to index type 'T'. @@ -17,8 +19,10 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2 Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T]'. Type 'T' is not assignable to type 'U'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. @@ -27,44 +31,61 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2 Type 'T[string]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. - Type 'T[keyof T]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'T[keyof T]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(72,5): error TS2322: Type 'Partial' is not assignable to type 'T'. + 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(78,5): error TS2322: Type 'Partial' is not assignable to type 'Partial'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(88,5): error TS2322: Type 'Readonly' is not assignable to type 'Readonly'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(127,5): error TS2322: Type 'Partial' is not assignable to type 'Identity'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(143,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(148,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. Type 'keyof U' is not assignable to type 'keyof T'. Type 'string | number | symbol' is not assignable to type 'keyof T'. Type 'string' is not assignable to type 'keyof T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(153,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. Type 'keyof T' is not assignable to type 'K'. - Type 'string | number | symbol' is not assignable to type 'K'. - Type 'string' is not assignable to type 'K'. + 'keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. + Type 'string | number | symbol' is not assignable to type 'K'. + 'string | number | symbol' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. + Type 'string' is not assignable to type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(158,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. Type 'keyof U' is not assignable to type 'K'. - Type 'string | number | symbol' is not assignable to type 'K'. - Type 'string' is not assignable to type 'K'. + 'keyof U' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. + Type 'string | number | symbol' is not assignable to type 'K'. + 'string | number | symbol' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. + Type 'string' is not assignable to type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(163,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. Type 'keyof T' is not assignable to type 'K'. - Type 'string | number | symbol' is not assignable to type 'K'. - Type 'string' is not assignable to type 'K'. + 'keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. + Type 'string | number | symbol' is not assignable to type 'K'. + 'string | number | symbol' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. + Type 'string' is not assignable to type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (28 errors) ==== @@ -82,6 +103,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function f4(x: T, y: U, k: K) { @@ -90,6 +112,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function f5(x: T, y: U, k: keyof U) { @@ -138,8 +161,10 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function f13(x: T, y: Partial, k: K) { @@ -155,10 +180,13 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function f20(x: T, y: Readonly, k: keyof T) { @@ -181,6 +209,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ~~~~ !!! error TS2542: Index signature in type 'Readonly' only permits reading. } @@ -191,6 +220,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ~~~~ !!! error TS2542: Index signature in type 'Readonly' only permits reading. } @@ -201,6 +231,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS x = y; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'T'. +!!! error TS2322: 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; } @@ -282,6 +313,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS !!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { @@ -300,8 +332,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~ !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. !!! error TS2322: Type 'keyof T' is not assignable to type 'K'. -!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'. -!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'. +!!! error TS2322: 'string | number | symbol' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. +!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. } function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { @@ -310,8 +345,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~ !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. !!! error TS2322: Type 'keyof U' is not assignable to type 'K'. -!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'. -!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'keyof U' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'. +!!! error TS2322: 'string | number | symbol' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. +!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. } function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { @@ -320,8 +358,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS ~ !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. !!! error TS2322: Type 'keyof T' is not assignable to type 'K'. -!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'. -!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'. +!!! error TS2322: 'string | number | symbol' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. +!!! error TS2322: Type 'string' is not assignable to type 'K'. +!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'. } function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { @@ -331,6 +372,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function f80(t: T): Partial { diff --git a/tests/baselines/reference/mappedTypes5.errors.txt b/tests/baselines/reference/mappedTypes5.errors.txt index 21d6f98964ae5..3b9f3423941ca 100644 --- a/tests/baselines/reference/mappedTypes5.errors.txt +++ b/tests/baselines/reference/mappedTypes5.errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/types/mapped/mappedTypes5.ts(6,9): error TS2322: Type 'P tests/cases/conformance/types/mapped/mappedTypes5.ts(8,9): error TS2322: Type 'Partial>' is not assignable to type 'Readonly'. tests/cases/conformance/types/mapped/mappedTypes5.ts(9,9): error TS2322: Type 'Readonly>' is not assignable to type 'Readonly'. Type 'Partial' is not assignable to type 'T'. + 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/mapped/mappedTypes5.ts (3 errors) ==== @@ -21,6 +22,7 @@ tests/cases/conformance/types/mapped/mappedTypes5.ts(9,9): error TS2322: Type 'R ~~ !!! error TS2322: Type 'Readonly>' is not assignable to type 'Readonly'. !!! error TS2322: Type 'Partial' is not assignable to type 'T'. +!!! error TS2322: 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. let c1: Partial> = p; let c2: Partial> = r; let c3: Partial> = pr; diff --git a/tests/baselines/reference/mappedTypes6.errors.txt b/tests/baselines/reference/mappedTypes6.errors.txt index 3c5c8eac2ed4e..590e9ff953476 100644 --- a/tests/baselines/reference/mappedTypes6.errors.txt +++ b/tests/baselines/reference/mappedTypes6.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(23,5): error TS2322: Type 'T' is not assignable to type 'Required'. tests/cases/conformance/types/mapped/mappedTypes6.ts(24,5): error TS2322: Type 'Partial' is not assignable to type 'Required'. tests/cases/conformance/types/mapped/mappedTypes6.ts(27,5): error TS2322: Type 'Partial' is not assignable to type 'T'. + 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypes6.ts(37,5): error TS2322: Type 'Required' is not assignable to type 'Denullified'. Type 'T[P]' is not assignable to type 'NonNullable'. Type 'T[keyof T]' is not assignable to type 'NonNullable'. @@ -11,9 +12,11 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(39,5): error TS2322: Type ' tests/cases/conformance/types/mapped/mappedTypes6.ts(42,5): error TS2322: Type 'T' is not assignable to type 'Required'. tests/cases/conformance/types/mapped/mappedTypes6.ts(43,5): error TS2322: Type 'Partial' is not assignable to type 'Required'. tests/cases/conformance/types/mapped/mappedTypes6.ts(47,5): error TS2322: Type 'Partial' is not assignable to type 'T'. + 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypes6.ts(56,5): error TS2322: Type '{}' is not assignable to type 'Denullified'. tests/cases/conformance/types/mapped/mappedTypes6.ts(57,5): error TS2322: Type '{}' is not assignable to type 'Required'. tests/cases/conformance/types/mapped/mappedTypes6.ts(58,5): error TS2322: Type '{}' is not assignable to type 'T'. + '{}' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/mapped/mappedTypes6.ts(92,1): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type 'Foo'. tests/cases/conformance/types/mapped/mappedTypes6.ts(104,1): error TS2739: Type '{ a: number; }' is missing the following properties from type 'Required': b, c, d tests/cases/conformance/types/mapped/mappedTypes6.ts(105,1): error TS2739: Type '{ a: number; b: number; }' is missing the following properties from type 'Required': c, d @@ -57,6 +60,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno y = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'T'. +!!! error TS2322: 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. z = x; z = y; z = z; @@ -93,6 +97,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno y = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'T'. +!!! error TS2322: 'Partial' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. z = w; z = x; z = y; @@ -110,6 +115,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno y = {}; // Error ~ !!! error TS2322: Type '{}' is not assignable to type 'T'. +!!! error TS2322: '{}' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. z = {}; } diff --git a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt index b3f3b4bc6e050..6df52aea46a88 100644 --- a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt +++ b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt @@ -1,8 +1,47 @@ tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(1,9): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(7,1): error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ? +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(8,13): error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ? +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(13,13): error TS7017: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature. +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(19,1): error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ? +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(20,1): error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ? +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(21,1): error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ? -==== tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts (1 errors) ==== - var x = {}["hello"]; +==== tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts (7 errors) ==== + var a = {}["hello"]; ~~~~~~~~~~~ !!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. - var y: string = { '': 'foo' }['']; \ No newline at end of file + var b: string = { '': 'foo' }['']; + + var c = { + get: (key: string) => 'foobar' + }; + c['hello']; + ~~~~~~~~~~ +!!! error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ? + const foo = c['hello']; + ~~~~~~~~~~ +!!! error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ? + + var d = { + set: (key: string) => 'foobar' + }; + const bar = d['hello']; + ~~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature. + + var e = { + set: (key: string) => 'foobar', + get: (key: string) => 'foobar' + }; + e['hello'] = 'modified'; + ~~~~~~~~~~ +!!! error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ? + e['hello'] += 1; + ~~~~~~~~~~ +!!! error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ? + e['hello'] ++; + ~~~~~~~~~~ +!!! error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ? + + \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.js b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.js index 2ea3291e5db7a..a02740351cff5 100644 --- a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.js +++ b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.js @@ -1,7 +1,44 @@ //// [noImplicitAnyStringIndexerOnObject.ts] -var x = {}["hello"]; -var y: string = { '': 'foo' }['']; +var a = {}["hello"]; +var b: string = { '': 'foo' }['']; + +var c = { + get: (key: string) => 'foobar' +}; +c['hello']; +const foo = c['hello']; + +var d = { + set: (key: string) => 'foobar' +}; +const bar = d['hello']; + +var e = { + set: (key: string) => 'foobar', + get: (key: string) => 'foobar' +}; +e['hello'] = 'modified'; +e['hello'] += 1; +e['hello'] ++; + + //// [noImplicitAnyStringIndexerOnObject.js] -var x = {}["hello"]; -var y = { '': 'foo' }['']; +var a = {}["hello"]; +var b = { '': 'foo' }['']; +var c = { + get: function (key) { return 'foobar'; } +}; +c['hello']; +var foo = c['hello']; +var d = { + set: function (key) { return 'foobar'; } +}; +var bar = d['hello']; +var e = { + set: function (key) { return 'foobar'; }, + get: function (key) { return 'foobar'; } +}; +e['hello'] = 'modified'; +e['hello'] += 1; +e['hello']++; diff --git a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.symbols b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.symbols index aa3990b0d7c62..f86c0d14b6ff7 100644 --- a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.symbols +++ b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.symbols @@ -1,9 +1,58 @@ === tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts === -var x = {}["hello"]; ->x : Symbol(x, Decl(noImplicitAnyStringIndexerOnObject.ts, 0, 3)) +var a = {}["hello"]; +>a : Symbol(a, Decl(noImplicitAnyStringIndexerOnObject.ts, 0, 3)) -var y: string = { '': 'foo' }['']; ->y : Symbol(y, Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 3)) +var b: string = { '': 'foo' }['']; +>b : Symbol(b, Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 3)) >'' : Symbol('', Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 17)) >'' : Symbol('', Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 17)) +var c = { +>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3)) + + get: (key: string) => 'foobar' +>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 9)) +>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 8)) + +}; +c['hello']; +>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3)) + +const foo = c['hello']; +>foo : Symbol(foo, Decl(noImplicitAnyStringIndexerOnObject.ts, 7, 5)) +>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3)) + +var d = { +>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 3)) + + set: (key: string) => 'foobar' +>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 9)) +>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 8)) + +}; +const bar = d['hello']; +>bar : Symbol(bar, Decl(noImplicitAnyStringIndexerOnObject.ts, 12, 5)) +>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 3)) + +var e = { +>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3)) + + set: (key: string) => 'foobar', +>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 9)) +>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 15, 8)) + + get: (key: string) => 'foobar' +>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 15, 33)) +>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 8)) + +}; +e['hello'] = 'modified'; +>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3)) + +e['hello'] += 1; +>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3)) + +e['hello'] ++; +>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3)) + + diff --git a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.types b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.types index a1b78eaca57da..dcf01d8c5e8df 100644 --- a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.types +++ b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.types @@ -1,15 +1,92 @@ === tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts === -var x = {}["hello"]; ->x : any +var a = {}["hello"]; +>a : any >{}["hello"] : any >{} : {} >"hello" : "hello" -var y: string = { '': 'foo' }['']; ->y : string +var b: string = { '': 'foo' }['']; +>b : string >{ '': 'foo' }[''] : string >{ '': 'foo' } : { '': string; } >'' : string >'foo' : "foo" >'' : "" +var c = { +>c : { get: (key: string) => string; } +>{ get: (key: string) => 'foobar'} : { get: (key: string) => string; } + + get: (key: string) => 'foobar' +>get : (key: string) => string +>(key: string) => 'foobar' : (key: string) => string +>key : string +>'foobar' : "foobar" + +}; +c['hello']; +>c['hello'] : any +>c : { get: (key: string) => string; } +>'hello' : "hello" + +const foo = c['hello']; +>foo : any +>c['hello'] : any +>c : { get: (key: string) => string; } +>'hello' : "hello" + +var d = { +>d : { set: (key: string) => string; } +>{ set: (key: string) => 'foobar'} : { set: (key: string) => string; } + + set: (key: string) => 'foobar' +>set : (key: string) => string +>(key: string) => 'foobar' : (key: string) => string +>key : string +>'foobar' : "foobar" + +}; +const bar = d['hello']; +>bar : any +>d['hello'] : any +>d : { set: (key: string) => string; } +>'hello' : "hello" + +var e = { +>e : { set: (key: string) => string; get: (key: string) => string; } +>{ set: (key: string) => 'foobar', get: (key: string) => 'foobar'} : { set: (key: string) => string; get: (key: string) => string; } + + set: (key: string) => 'foobar', +>set : (key: string) => string +>(key: string) => 'foobar' : (key: string) => string +>key : string +>'foobar' : "foobar" + + get: (key: string) => 'foobar' +>get : (key: string) => string +>(key: string) => 'foobar' : (key: string) => string +>key : string +>'foobar' : "foobar" + +}; +e['hello'] = 'modified'; +>e['hello'] = 'modified' : "modified" +>e['hello'] : any +>e : { set: (key: string) => string; get: (key: string) => string; } +>'hello' : "hello" +>'modified' : "modified" + +e['hello'] += 1; +>e['hello'] += 1 : any +>e['hello'] : any +>e : { set: (key: string) => string; get: (key: string) => string; } +>'hello' : "hello" +>1 : 1 + +e['hello'] ++; +>e['hello'] ++ : number +>e['hello'] : any +>e : { set: (key: string) => string; get: (key: string) => string; } +>'hello' : "hello" + + diff --git a/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt b/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt index 83ce98f1cd625..7e69f57747635 100644 --- a/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt +++ b/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts(10,9): error TS2322: Type 'T' is not assignable to type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable to type 'object | U'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts (2 errors) ==== @@ -20,5 +21,6 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts(11,9) ~ !!! error TS2322: Type 'T' is not assignable to type 'object | U'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/objectFromEntries.js b/tests/baselines/reference/objectFromEntries.js new file mode 100644 index 0000000000000..fc5b9a107a3be --- /dev/null +++ b/tests/baselines/reference/objectFromEntries.js @@ -0,0 +1,20 @@ +//// [objectFromEntries.ts] +const o = Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]); +const o2 = Object.fromEntries(new URLSearchParams()); +const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]])); + +const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +const o4 = Object.fromEntries(frozenArray); + +const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +const o5 = Object.fromEntries(frozenArray2); + + +//// [objectFromEntries.js] +const o = Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]); +const o2 = Object.fromEntries(new URLSearchParams()); +const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]])); +const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +const o4 = Object.fromEntries(frozenArray); +const frozenArray2 = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +const o5 = Object.fromEntries(frozenArray2); diff --git a/tests/baselines/reference/objectFromEntries.symbols b/tests/baselines/reference/objectFromEntries.symbols new file mode 100644 index 0000000000000..882b553eb558c --- /dev/null +++ b/tests/baselines/reference/objectFromEntries.symbols @@ -0,0 +1,48 @@ +=== tests/cases/compiler/objectFromEntries.ts === +const o = Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]); +>o : Symbol(o, Decl(objectFromEntries.ts, 0, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) + +const o2 = Object.fromEntries(new URLSearchParams()); +>o2 : Symbol(o2, Decl(objectFromEntries.ts, 1, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>URLSearchParams : Symbol(URLSearchParams, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.iterable.d.ts, --, --)) + +const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]])); +>o3 : Symbol(o3, Decl(objectFromEntries.ts, 2, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) + +const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +>frozenArray : Symbol(frozenArray, Decl(objectFromEntries.ts, 4, 5)) +>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +const o4 = Object.fromEntries(frozenArray); +>o4 : Symbol(o4, Decl(objectFromEntries.ts, 5, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>frozenArray : Symbol(frozenArray, Decl(objectFromEntries.ts, 4, 5)) + +const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +>frozenArray2 : Symbol(frozenArray2, Decl(objectFromEntries.ts, 7, 5)) +>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +const o5 = Object.fromEntries(frozenArray2); +>o5 : Symbol(o5, Decl(objectFromEntries.ts, 8, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>frozenArray2 : Symbol(frozenArray2, Decl(objectFromEntries.ts, 7, 5)) + diff --git a/tests/baselines/reference/objectFromEntries.types b/tests/baselines/reference/objectFromEntries.types new file mode 100644 index 0000000000000..265cbd2d87813 --- /dev/null +++ b/tests/baselines/reference/objectFromEntries.types @@ -0,0 +1,92 @@ +=== tests/cases/compiler/objectFromEntries.ts === +const o = Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]); +>o : { [x: string]: number; [x: number]: number; } +>Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]) : { [x: string]: number; [x: number]: number; } +>Object.fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>[['a', 1], ['b', 2], ['c', 3]] : [string, number][] +>['a', 1] : [string, number] +>'a' : "a" +>1 : 1 +>['b', 2] : [string, number] +>'b' : "b" +>2 : 2 +>['c', 3] : [string, number] +>'c' : "c" +>3 : 3 + +const o2 = Object.fromEntries(new URLSearchParams()); +>o2 : { [x: string]: string; [x: number]: string; } +>Object.fromEntries(new URLSearchParams()) : { [x: string]: string; [x: number]: string; } +>Object.fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>new URLSearchParams() : URLSearchParams +>URLSearchParams : { new (init?: string | URLSearchParams | string[][] | Record): URLSearchParams; prototype: URLSearchParams; } + +const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]])); +>o3 : { [x: string]: string; [x: number]: string; } +>Object.fromEntries(new Map([[Symbol("key"), "value"]])) : { [x: string]: string; [x: number]: string; } +>Object.fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>new Map([[Symbol("key"), "value"]]) : Map +>Map : MapConstructor +>[[Symbol("key"), "value"]] : [symbol, string][] +>[Symbol("key"), "value"] : [symbol, string] +>Symbol("key") : symbol +>Symbol : SymbolConstructor +>"key" : "key" +>"value" : "value" + +const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +>frozenArray : readonly (string | number)[][] +>Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly (string | number)[][] +>Object.freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; } +>Object : ObjectConstructor +>freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; } +>[['a', 1], ['b', 2], ['c', 3]] : (string | number)[][] +>['a', 1] : (string | number)[] +>'a' : "a" +>1 : 1 +>['b', 2] : (string | number)[] +>'b' : "b" +>2 : 2 +>['c', 3] : (string | number)[] +>'c' : "c" +>3 : 3 + +const o4 = Object.fromEntries(frozenArray); +>o4 : any +>Object.fromEntries(frozenArray) : any +>Object.fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>frozenArray : readonly (string | number)[][] + +const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +>frozenArray2 : readonly [string, number][] +>Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly [string, number][] +>Object.freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; } +>Object : ObjectConstructor +>freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; } +>[['a', 1], ['b', 2], ['c', 3]] : [string, number][] +>['a', 1] : [string, number] +>'a' : "a" +>1 : 1 +>['b', 2] : [string, number] +>'b' : "b" +>2 : 2 +>['c', 3] : [string, number] +>'c' : "c" +>3 : 3 + +const o5 = Object.fromEntries(frozenArray2); +>o5 : { [x: string]: number; [x: number]: number; } +>Object.fromEntries(frozenArray2) : { [x: string]: number; [x: number]: number; } +>Object.fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [x: string]: T; [x: number]: T; }; (entries: Iterable): any; } +>frozenArray2 : readonly [string, number][] + diff --git a/tests/baselines/reference/objectLiteralExcessProperties.errors.txt b/tests/baselines/reference/objectLiteralExcessProperties.errors.txt index e4fc4d69fca99..4721cc7288227 100644 --- a/tests/baselines/reference/objectLiteralExcessProperties.errors.txt +++ b/tests/baselines/reference/objectLiteralExcessProperties.errors.txt @@ -23,8 +23,10 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'? tests/cases/compiler/objectLiteralExcessProperties.ts(37,25): error TS2304: Cannot find name 'IFoo'. tests/cases/compiler/objectLiteralExcessProperties.ts(39,11): error TS2322: Type '{ name: string; }' is not assignable to type 'T'. + '{ name: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'any'. tests/cases/compiler/objectLiteralExcessProperties.ts(41,11): error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T & { prop: boolean; }'. Type '{ name: string; prop: boolean; }' is not assignable to type 'T'. + '{ name: string; prop: boolean; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'any'. tests/cases/compiler/objectLiteralExcessProperties.ts(43,43): error TS2322: Type '{ name: string; prop: true; }' is not assignable to type 'T | { prop: boolean; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ prop: boolean; }'. tests/cases/compiler/objectLiteralExcessProperties.ts(45,76): error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type '{ name: string; } | (T & { prop: boolean; })'. @@ -111,11 +113,13 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(49,44): error TS2322: Type const obj1: T = { name: "test" }; ~~~~ !!! error TS2322: Type '{ name: string; }' is not assignable to type 'T'. +!!! error TS2322: '{ name: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'any'. // No excess property checks on intersections involving generics const obj2: T & { prop: boolean } = { name: "test", prop: true }; ~~~~ !!! error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T & { prop: boolean; }'. !!! error TS2322: Type '{ name: string; prop: boolean; }' is not assignable to type 'T'. +!!! error TS2322: '{ name: string; prop: boolean; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'any'. // Excess property checks only on non-generic parts of unions const obj3: T | { prop: boolean } = { name: "test", prop: true }; ~~~~~~~~~~~~ diff --git a/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt b/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt index f112a590071a9..72093dab99e9a 100644 --- a/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt +++ b/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt @@ -5,11 +5,17 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec Types of property 'data' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(30,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'MyList' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. + Type 'MyList' is not assignable to type 'T'. + 'MyList' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(31,5): error TS2322: Type 'T' is not assignable to type 'U'. - Type 'List' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. + Type 'List' is not assignable to type 'U'. + 'List' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(42,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'MyList' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyList'. + Type 'MyList' is not assignable to type 'T'. + 'MyList' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyList'. ==== tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts (5 errors) ==== @@ -53,11 +59,15 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'MyList' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. +!!! error TS2322: Type 'MyList' is not assignable to type 'T'. +!!! error TS2322: 'MyList' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'List' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. +!!! error TS2322: Type 'List' is not assignable to type 'U'. +!!! error TS2322: 'List' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. var a: List; var b: MyList; @@ -71,7 +81,9 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'MyList' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyList'. +!!! error TS2322: Type 'MyList' is not assignable to type 'T'. +!!! error TS2322: 'MyList' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyList'. u = t; // was error, ok after constraint made illegal, doesn't matter var a: List; diff --git a/tests/baselines/reference/parserRegularExpression4.types b/tests/baselines/reference/parserRegularExpression4.types index 1a0db05a48e48..1af56c7a24fc6 100644 --- a/tests/baselines/reference/parserRegularExpression4.types +++ b/tests/baselines/reference/parserRegularExpression4.types @@ -61,7 +61,7 @@ if (Ca.test(c.href) || Ba.test(c.href) && /(\\?|&)adurl=/.test(c.href) && !/(\\? >"&q=" + encodeURIComponent(W("q") || W("as_q") || A) : string >"&q=" : "&q=" >encodeURIComponent(W("q") || W("as_q") || A) : string ->encodeURIComponent : (uriComponent: string) => string +>encodeURIComponent : (uriComponent: string | number | boolean) => string >W("q") || W("as_q") || A : any >W("q") || W("as_q") : any >W("q") : any diff --git a/tests/baselines/reference/parserharness.types b/tests/baselines/reference/parserharness.types index eb5a2884edf06..5fde386f90acf 100644 --- a/tests/baselines/reference/parserharness.types +++ b/tests/baselines/reference/parserharness.types @@ -3931,9 +3931,9 @@ module Harness { if (!matchingIdentifiers.some(value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type))) { >!matchingIdentifiers.some(value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type)) : boolean >matchingIdentifiers.some(value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type)) : boolean ->matchingIdentifiers.some : (callbackfn: (value: Type, index: number, array: Type[]) => boolean, thisArg?: any) => boolean +>matchingIdentifiers.some : (callbackfn: (value: Type, index: number, array: Type[]) => unknown, thisArg?: any) => boolean >matchingIdentifiers : Type[] ->some : (callbackfn: (value: Type, index: number, array: Type[]) => boolean, thisArg?: any) => boolean +>some : (callbackfn: (value: Type, index: number, array: Type[]) => unknown, thisArg?: any) => boolean >value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type) : (value: Type) => boolean >value : Type >(value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type) : boolean @@ -4020,9 +4020,9 @@ module Harness { if (!matchingIdentifiers.some(value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type))) { >!matchingIdentifiers.some(value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type)) : boolean >matchingIdentifiers.some(value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type)) : boolean ->matchingIdentifiers.some : (callbackfn: (value: Type, index: number, array: Type[]) => boolean, thisArg?: any) => boolean +>matchingIdentifiers.some : (callbackfn: (value: Type, index: number, array: Type[]) => unknown, thisArg?: any) => boolean >matchingIdentifiers : Type[] ->some : (callbackfn: (value: Type, index: number, array: Type[]) => boolean, thisArg?: any) => boolean +>some : (callbackfn: (value: Type, index: number, array: Type[]) => unknown, thisArg?: any) => boolean >value => (value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type) : (value: Type) => boolean >value : Type >(value.identifier === foundValue.identifier) && (value.code === foundValue.code) && (value.type === foundValue.type) : boolean diff --git a/tests/baselines/reference/restInvalidArgumentType.types b/tests/baselines/reference/restInvalidArgumentType.types index 54af9099c311d..d88ee53796aac 100644 --- a/tests/baselines/reference/restInvalidArgumentType.types +++ b/tests/baselines/reference/restInvalidArgumentType.types @@ -71,7 +71,7 @@ function f(p1: T, p2: T[]) { >p1 : T var {...r2} = p2; // OK ->r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } >p2 : T[] var {...r3} = t; // Error, generic type paramter diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types index 1385bde0c3fae..b98f0cdd367d7 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.types +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -31,5 +31,5 @@ function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) >b : string >true : true >rest : any ->rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => any, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } +>rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } diff --git a/tests/baselines/reference/spreadInvalidArgumentType.types b/tests/baselines/reference/spreadInvalidArgumentType.types index 6828d557d0a85..8a833c966ff97 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.types +++ b/tests/baselines/reference/spreadInvalidArgumentType.types @@ -73,8 +73,8 @@ function f(p1: T, p2: T[]) { >p1 : T var o2 = { ...p2 }; // OK ->o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } ->{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } >p2 : T[] var o3 = { ...t }; // OK, generic type paramter diff --git a/tests/baselines/reference/strictNullEmptyDestructuring.errors.txt b/tests/baselines/reference/strictNullEmptyDestructuring.errors.txt index 2406ac27d98a1..cb50303d3500d 100644 --- a/tests/baselines/reference/strictNullEmptyDestructuring.errors.txt +++ b/tests/baselines/reference/strictNullEmptyDestructuring.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/strictNullEmptyDestructuring.ts(3,5): error TS2461: Type 'null' is not an array type. tests/cases/compiler/strictNullEmptyDestructuring.ts(3,5): error TS2531: Object is possibly 'null'. tests/cases/compiler/strictNullEmptyDestructuring.ts(5,5): error TS2531: Object is possibly 'null'. tests/cases/compiler/strictNullEmptyDestructuring.ts(7,2): error TS2531: Object is possibly 'null'. @@ -11,11 +12,13 @@ tests/cases/compiler/strictNullEmptyDestructuring.ts(21,5): error TS2533: Object tests/cases/compiler/strictNullEmptyDestructuring.ts(23,2): error TS2533: Object is possibly 'null' or 'undefined'. -==== tests/cases/compiler/strictNullEmptyDestructuring.ts (11 errors) ==== +==== tests/cases/compiler/strictNullEmptyDestructuring.ts (12 errors) ==== // Repro from #20873 let [] = null; ~~ +!!! error TS2461: Type 'null' is not an array type. + ~~ !!! error TS2531: Object is possibly 'null'. let { } = null; diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index 8983c26e153f0..0ec8951fe9391 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (1 errors) ==== @@ -14,6 +15,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } function f1(x: T, y: U) { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index 627a887d437ef..5fe0186e04a1b 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -1,38 +1,53 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'U'. - Type 'Date' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'C3'. Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2416: Property 'foo' in type 'D28' is not assignable to the same property in base type 'C3'. Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2416: Property 'foo' in type 'D29' is not assignable to the same property in base type 'C3'. Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (20 errors) ==== @@ -60,6 +75,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } class D4 extends C3 { @@ -96,7 +112,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. -!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } class D9 extends C3 { @@ -119,6 +137,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } class D12 extends C3 { @@ -129,6 +148,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'U'. +!!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } class D13 extends C3 { @@ -174,8 +194,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. -!!! error TS2416: Type 'V' is not assignable to type 'T'. -!!! error TS2416: Type 'Date' is not assignable to type 'T'. +!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2416: Type 'Date' is not assignable to type 'T'. +!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } class D20 extends C3 { @@ -203,7 +226,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'T'. -!!! error TS2416: Type 'Date' is not assignable to type 'T'. +!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2416: Type 'Date' is not assignable to type 'T'. +!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } class D24 extends C3 { @@ -214,7 +239,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'U'. -!!! error TS2416: Type 'Date' is not assignable to type 'U'. +!!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2416: Type 'Date' is not assignable to type 'U'. +!!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. } class D25 extends C3 { @@ -237,6 +264,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'Date' is not assignable to type 'T'. +!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } class D28 extends C3 { @@ -247,6 +275,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D28' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'Date' is not assignable to type 'U'. +!!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. } class D29 extends C3 { @@ -257,4 +286,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D29' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'Date' is not assignable to type 'V'. +!!! error TS2416: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index bdf0473df01a5..03656c08c4ef2 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -4,14 +4,18 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'T'. + 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'U'. + 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'U'. @@ -85,7 +89,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'U' is not assignable to type 'T'. -!!! error TS2416: Type 'Foo' is not assignable to type 'T'. +!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'T'. +!!! error TS2416: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. } class D6 extends B1 { @@ -106,7 +112,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'T' is not assignable to type 'U'. -!!! error TS2416: Type 'Foo' is not assignable to type 'U'. +!!! error TS2416: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'U'. +!!! error TS2416: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. } class D8 extends B1 { diff --git a/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt b/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt index b17196896067d..7dfb078170a6d 100644 --- a/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a2' are incompatible. Type '(x: T) => string' is not assignable to type '(x: T) => T'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithSpecializedSignatures.ts (2 errors) ==== @@ -95,6 +96,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type '(x: T) => string' is not assignable to type '(x: T) => T'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt b/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt index 34fa5ee287adc..2f314864f9886 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt @@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts(28,11): error TS2430: Interface 'I2' incorrectly extends interface 'A'. Types of property 'a2' are incompatible. Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts(32,11): error TS2430: Interface 'I3' incorrectly extends interface 'A'. Types of property 'a3' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x: T) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts(36,11): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a4' are incompatible. Type 'new (x: T, y: U) => string' is not assignable to type 'new (x: T, y: U) => string'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts(40,11): error TS2430: Interface 'I5' incorrectly extends interface 'A'. Types of property 'a5' are incompatible. Type 'new (x: (arg: T) => U) => T' is not assignable to type 'new (x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts(44,11): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a11' are incompatible. Type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base'. @@ -31,6 +36,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts(48,11): error TS2430: Interface 'I9' incorrectly extends interface 'A'. Types of property 'a16' are incompatible. Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. @@ -38,7 +44,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - Type 'Base' is not assignable to type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts (7 errors) ==== @@ -72,6 +80,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new (x: T) => T[]; } @@ -82,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => string[]; } @@ -92,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x: T) => void'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new (x: T) => T; } @@ -102,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T, y: U) => string' is not assignable to type 'new (x: T, y: U) => string'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new (x: T, y: U) => string; } @@ -113,6 +125,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new (x: (arg: T) => U) => T; } @@ -125,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'foo' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; } @@ -137,6 +151,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a16: new (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt b/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt index a862124666dc4..8f4a219407ab3 100644 --- a/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a2' are incompatible. Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts (2 errors) ==== @@ -95,6 +96,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: new (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt index 1447c4d3105f9..36380fc97f4f0 100644 --- a/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt @@ -8,10 +8,12 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a' are incompatible. Type '() => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(104,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type '(x?: T) => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(108,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type '(x: T) => T' is not assignable to type '() => T'. @@ -19,30 +21,36 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a2' are incompatible. Type '() => T' is not assignable to type '(x?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(117,15): error TS2430: Interface 'I5' incorrectly extends interface 'Base2'. Types of property 'a2' are incompatible. Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(121,15): error TS2430: Interface 'I6' incorrectly extends interface 'Base2'. Types of property 'a2' are incompatible. Type '(x: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(126,15): error TS2430: Interface 'I7' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type '() => T' is not assignable to type '(x: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(130,15): error TS2430: Interface 'I8' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type '(x?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(134,15): error TS2430: Interface 'I9' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type '(x: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(138,15): error TS2430: Interface 'I10' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type '(x: T, y: T) => T' is not assignable to type '(x: T) => T'. @@ -50,40 +58,48 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a4' are incompatible. Type '() => T' is not assignable to type '(x: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(147,15): error TS2430: Interface 'I12' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(151,15): error TS2430: Interface 'I13' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type '(x: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(155,15): error TS2430: Interface 'I14' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type '(x: T, y: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(160,15): error TS2430: Interface 'I15' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(164,15): error TS2430: Interface 'I16' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(168,15): error TS2430: Interface 'I17' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type '(x: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(172,15): error TS2430: Interface 'I18' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type '(x: T, y: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(196,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type '(x: T) => T' is not assignable to type '() => T'. @@ -206,6 +222,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type '() => T' is not assignable to type '() => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: () => T; } @@ -215,6 +232,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type '(x?: T) => T' is not assignable to type '() => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: (x?: T) => T; } @@ -233,6 +251,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type '() => T' is not assignable to type '(x?: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: () => T; } @@ -243,6 +262,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x?: T) => T } @@ -253,6 +273,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => T; } @@ -263,6 +284,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a3' are incompatible. !!! error TS2430: Type '() => T' is not assignable to type '(x: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: () => T; } @@ -273,6 +295,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: (x?: T) => T; } @@ -283,6 +306,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: (x: T) => T; } @@ -301,6 +325,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a4' are incompatible. !!! error TS2430: Type '() => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: () => T; } @@ -311,6 +336,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: (x?: T, y?: T) => T; } @@ -321,6 +347,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: (x: T) => T; } @@ -331,6 +358,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x: T, y: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: (x: T, y: T) => T; } @@ -341,6 +369,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a5' are incompatible. !!! error TS2430: Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: () => T; } @@ -351,6 +380,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: (x?: T, y?: T) => T; } @@ -361,6 +391,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: (x: T) => T; } @@ -371,6 +402,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type '(x: T, y: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: (x: T, y: T) => T; } } diff --git a/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt index 28682b99a6604..427c7c1f19e8f 100644 --- a/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt @@ -8,10 +8,12 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a' are incompatible. Type 'new () => T' is not assignable to type 'new () => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(104,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type 'new (x?: T) => T' is not assignable to type 'new () => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(108,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new () => T'. @@ -19,30 +21,36 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a2' are incompatible. Type 'new () => T' is not assignable to type 'new (x?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(117,15): error TS2430: Interface 'I5' incorrectly extends interface 'Base2'. Types of property 'a2' are incompatible. Type 'new (x?: T) => T' is not assignable to type 'new (x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(121,15): error TS2430: Interface 'I6' incorrectly extends interface 'Base2'. Types of property 'a2' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(126,15): error TS2430: Interface 'I7' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type 'new () => T' is not assignable to type 'new (x: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(130,15): error TS2430: Interface 'I8' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type 'new (x?: T) => T' is not assignable to type 'new (x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(134,15): error TS2430: Interface 'I9' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(138,15): error TS2430: Interface 'I10' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type 'new (x: T, y: T) => T' is not assignable to type 'new (x: T) => T'. @@ -50,40 +58,48 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a4' are incompatible. Type 'new () => T' is not assignable to type 'new (x: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(147,15): error TS2430: Interface 'I12' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type 'new (x?: T, y?: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(151,15): error TS2430: Interface 'I13' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(155,15): error TS2430: Interface 'I14' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type 'new (x: T, y: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(160,15): error TS2430: Interface 'I15' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type 'new () => T' is not assignable to type 'new (x?: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(164,15): error TS2430: Interface 'I16' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type 'new (x?: T, y?: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(168,15): error TS2430: Interface 'I17' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(172,15): error TS2430: Interface 'I18' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type 'new (x: T, y: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(196,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new () => T'. @@ -206,6 +222,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'new () => T' is not assignable to type 'new () => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new () => T; } @@ -215,6 +232,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'new (x?: T) => T' is not assignable to type 'new () => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new (x?: T) => T; } @@ -233,6 +251,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type 'new () => T' is not assignable to type 'new (x?: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new () => T; } @@ -243,6 +262,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x?: T) => T' is not assignable to type 'new (x?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x?: T) => T } @@ -253,6 +273,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => T; } @@ -263,6 +284,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a3' are incompatible. !!! error TS2430: Type 'new () => T' is not assignable to type 'new (x: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new () => T; } @@ -273,6 +295,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x?: T) => T' is not assignable to type 'new (x: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new (x?: T) => T; } @@ -283,6 +306,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new (x: T) => T; } @@ -301,6 +325,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a4' are incompatible. !!! error TS2430: Type 'new () => T' is not assignable to type 'new (x: T, y?: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new () => T; } @@ -311,6 +336,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x?: T, y?: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new (x?: T, y?: T) => T; } @@ -321,6 +347,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new (x: T) => T; } @@ -331,6 +358,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T, y: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new (x: T, y: T) => T; } @@ -341,6 +369,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a5' are incompatible. !!! error TS2430: Type 'new () => T' is not assignable to type 'new (x?: T, y?: T) => T'. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new () => T; } @@ -351,6 +380,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x?: T, y?: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new (x?: T, y?: T) => T; } @@ -361,6 +391,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new (x: T) => T; } @@ -371,6 +402,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Type 'new (x: T, y: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new (x: T, y: T) => T; } } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt index e5ff0d47ca305..0c79c352a4c85 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt @@ -1,9 +1,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts (2 errors) ==== @@ -43,6 +45,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. +!!! error TS2415: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. [x: number]: Derived; // error, BUG? } @@ -51,6 +54,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2415: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. [x: number]: Derived2; // error, BUG? } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt index a1e09eb270497..4915510dec768 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt @@ -8,9 +8,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(36,15): error TS2430: Interface 'B4' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(40,15): error TS2430: Interface 'B5' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts (5 errors) ==== @@ -65,6 +67,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Interface 'B4' incorrectly extends interface 'A'. !!! error TS2430: Index signatures are incompatible. !!! error TS2430: Type 'Derived' is not assignable to type 'T'. +!!! error TS2430: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. [x: number]: Derived; // error } @@ -73,6 +76,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Interface 'B5' incorrectly extends interface 'A'. !!! error TS2430: Index signatures are incompatible. !!! error TS2430: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2430: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. [x: number]: Derived2; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt index 6989d082ac8cf..ee132ac7483bb 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt @@ -8,9 +8,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(40,11): error TS2415: Class 'B5' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts (5 errors) ==== @@ -65,6 +67,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. +!!! error TS2415: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. [x: number]: Derived; // error } @@ -73,6 +76,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B5' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2415: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. [x: number]: Derived2; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt index 9dafcd925c38a..fb4d430a09a00 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt @@ -8,9 +8,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts(36,11): error TS2420: Class 'B4' incorrectly implements interface 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts(40,11): error TS2420: Class 'B5' incorrectly implements interface 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts (4 errors) ==== @@ -64,6 +66,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2420: Class 'B4' incorrectly implements interface 'A'. !!! error TS2420: Index signatures are incompatible. !!! error TS2420: Type 'Derived' is not assignable to type 'T'. +!!! error TS2420: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. [x: string]: Derived; // error } @@ -72,6 +75,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2420: Class 'B5' incorrectly implements interface 'A'. !!! error TS2420: Index signatures are incompatible. !!! error TS2420: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2420: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. [x: string]: Derived2; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithStringIndexer.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer.errors.txt index 4ad0f6654255b..80a1a6acfc043 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer.errors.txt @@ -1,9 +1,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts (2 errors) ==== @@ -43,6 +45,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. +!!! error TS2415: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. [x: string]: Derived; // error } @@ -51,6 +54,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2415: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. [x: string]: Derived2; // error } } diff --git a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt index 953364b5b1faa..214a17258c9dd 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt @@ -8,9 +8,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(36,15): error TS2430: Interface 'B4' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(40,15): error TS2430: Interface 'B5' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts (5 errors) ==== @@ -65,6 +67,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Interface 'B4' incorrectly extends interface 'A'. !!! error TS2430: Index signatures are incompatible. !!! error TS2430: Type 'Derived' is not assignable to type 'T'. +!!! error TS2430: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. [x: string]: Derived; // error } @@ -73,6 +76,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Interface 'B5' incorrectly extends interface 'A'. !!! error TS2430: Index signatures are incompatible. !!! error TS2430: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2430: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. [x: string]: Derived2; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt index 3309c1da26607..8016421c07f29 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt @@ -8,9 +8,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(40,11): error TS2415: Class 'B5' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts (5 errors) ==== @@ -65,6 +67,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. +!!! error TS2415: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. [x: string]: Derived; // error } @@ -73,6 +76,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B5' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2415: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived2'. [x: string]: Derived2; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/targetTypeArgs.types b/tests/baselines/reference/targetTypeArgs.types index 84985316aa2d6..980592d4d576c 100644 --- a/tests/baselines/reference/targetTypeArgs.types +++ b/tests/baselines/reference/targetTypeArgs.types @@ -31,11 +31,11 @@ foo(function(x) { x }); ["hello"].every(function(v,i,a) {return true;}); >["hello"].every(function(v,i,a) {return true;}) : boolean ->["hello"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>["hello"].every : (callbackfn: (value: string, index: number, array: string[]) => unknown, thisArg?: any) => boolean >["hello"] : string[] >"hello" : "hello" ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true +>every : (callbackfn: (value: string, index: number, array: string[]) => unknown, thisArg?: any) => boolean +>function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => boolean >v : string >i : number >a : string[] @@ -43,11 +43,11 @@ foo(function(x) { x }); [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean ->[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>[1].every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >[1] : number[] >1 : 1 ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true +>every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean +>function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => boolean >v : number >i : number >a : number[] @@ -55,11 +55,11 @@ foo(function(x) { x }); [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean ->[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>[1].every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >[1] : number[] >1 : 1 ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true +>every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean +>function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => boolean >v : number >i : number >a : number[] @@ -67,11 +67,11 @@ foo(function(x) { x }); ["s"].every(function(v,i,a) {return true;}); >["s"].every(function(v,i,a) {return true;}) : boolean ->["s"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>["s"].every : (callbackfn: (value: string, index: number, array: string[]) => unknown, thisArg?: any) => boolean >["s"] : string[] >"s" : "s" ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true +>every : (callbackfn: (value: string, index: number, array: string[]) => unknown, thisArg?: any) => boolean +>function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => boolean >v : string >i : number >a : string[] diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js new file mode 100644 index 0000000000000..53bd9b167fb6e --- /dev/null +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js @@ -0,0 +1,71 @@ +//// [/src/core/anotherModule.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.World = "hello"; + + +//// [/src/core/index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.someString = "HELLO WORLD"; +function leftPad(s, n) { return s + n; } +exports.leftPad = leftPad; +function multiply(a, b) { return a * b; } +exports.multiply = multiply; + + +//// [/src/core/tsconfig.json] +{ + "compilerOptions": { + "incremental": true, +"listFiles": true, +"listEmittedFiles": true, + "target": "es5", + } +} + +//// [/src/core/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "8926001564", + "signature": "8926001564" + }, + "/lib/lib.esnext.d.ts": { + "version": "-15964756381", + "signature": "-15964756381" + }, + "/src/core/anothermodule.ts": { + "version": "-2676574883", + "signature": "-8396256275" + }, + "/src/core/index.ts": { + "version": "-18749805970", + "signature": "1874987148" + }, + "/src/core/some_decl.d.ts": { + "version": "-9253692965", + "signature": "-9253692965" + } + }, + "options": { + "incremental": true, + "listFiles": true, + "listEmittedFiles": true, + "target": 1, + "configFilePath": "/src/core/tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/lib/lib.esnext.d.ts", + "/src/core/anothermodule.ts", + "/src/core/index.ts", + "/src/core/some_decl.d.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js new file mode 100644 index 0000000000000..fdf7cc3841291 --- /dev/null +++ b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js @@ -0,0 +1,88 @@ +//// [/lib/lib.d.ts] +/// +/// + +//// [/lib/lib.esnext.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array {} +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/lib/lib.esnext.full.d.ts] +/// +/// + +//// [/src/core/anotherModule.js] +export const World = "hello"; + + +//// [/src/core/index.js] +export const someString = "HELLO WORLD"; +export function leftPad(s, n) { return s + n; } +export function multiply(a, b) { return a * b; } + + +//// [/src/core/tsconfig.json] +{ + "compilerOptions": { + "incremental": true, +"listFiles": true, +"listEmittedFiles": true, + "target": "esnext", + } +} + +//// [/src/core/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "/lib/lib.esnext.d.ts": { + "version": "-15964756381", + "signature": "-15964756381" + }, + "/lib/lib.esnext.full.d.ts": { + "version": "8926001564", + "signature": "8926001564" + }, + "/src/core/anothermodule.ts": { + "version": "-2676574883", + "signature": "-8396256275" + }, + "/src/core/index.ts": { + "version": "-18749805970", + "signature": "1874987148" + }, + "/src/core/some_decl.d.ts": { + "version": "-9253692965", + "signature": "-9253692965" + } + }, + "options": { + "incremental": true, + "listFiles": true, + "listEmittedFiles": true, + "target": 8, + "configFilePath": "/src/core/tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "/lib/lib.esnext.d.ts", + "/lib/lib.esnext.full.d.ts", + "/src/core/anothermodule.ts", + "/src/core/index.ts", + "/src/core/some_decl.d.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt b/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt index ae3d01d5e880d..7fe6609cc9615 100644 --- a/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt +++ b/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(14,14): error TS2322: Type '{}' is not assignable to type 'P'. + '{}' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(15,14): error TS2322: Type '{}' is not assignable to type 'Readonly

'. @@ -19,6 +20,7 @@ tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(15,14): error TS2322: Type let x = ; // should error ~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'P'. +!!! error TS2322: '{}' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint '{}'. let y = ; // should error ~~~~~~~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'Readonly

'. diff --git a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt index a162b997c0f6d..2781d2fcee524 100644 --- a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt +++ b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(2,15): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(3,15): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): error TS2558: Expected 0 type arguments, but got 1. @@ -11,6 +12,7 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): erro var r2 = f(1); ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r3 = f(null); ~~~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/typeGuardBoolean.js b/tests/baselines/reference/typeGuardBoolean.js new file mode 100644 index 0000000000000..1bfe41983d83b --- /dev/null +++ b/tests/baselines/reference/typeGuardBoolean.js @@ -0,0 +1,30 @@ +//// [typeGuardBoolean.ts] +function test(strOrNull: string | null, strOrUndefined: string | undefined) { + var str: string = "original"; + var nil: null; + if (!Boolean(strOrNull)) { + nil = strOrNull; + } + else { + str = strOrNull; + } + if (Boolean(strOrUndefined)) { + str = strOrUndefined; + } +} + + +//// [typeGuardBoolean.js] +function test(strOrNull, strOrUndefined) { + var str = "original"; + var nil; + if (!Boolean(strOrNull)) { + nil = strOrNull; + } + else { + str = strOrNull; + } + if (Boolean(strOrUndefined)) { + str = strOrUndefined; + } +} diff --git a/tests/baselines/reference/typeGuardBoolean.symbols b/tests/baselines/reference/typeGuardBoolean.symbols new file mode 100644 index 0000000000000..6a08dcbda8a06 --- /dev/null +++ b/tests/baselines/reference/typeGuardBoolean.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts === +function test(strOrNull: string | null, strOrUndefined: string | undefined) { +>test : Symbol(test, Decl(typeGuardBoolean.ts, 0, 0)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) +>strOrUndefined : Symbol(strOrUndefined, Decl(typeGuardBoolean.ts, 0, 39)) + + var str: string = "original"; +>str : Symbol(str, Decl(typeGuardBoolean.ts, 1, 5)) + + var nil: null; +>nil : Symbol(nil, Decl(typeGuardBoolean.ts, 2, 5)) + + if (!Boolean(strOrNull)) { +>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) + + nil = strOrNull; +>nil : Symbol(nil, Decl(typeGuardBoolean.ts, 2, 5)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) + } + else { + str = strOrNull; +>str : Symbol(str, Decl(typeGuardBoolean.ts, 1, 5)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) + } + if (Boolean(strOrUndefined)) { +>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>strOrUndefined : Symbol(strOrUndefined, Decl(typeGuardBoolean.ts, 0, 39)) + + str = strOrUndefined; +>str : Symbol(str, Decl(typeGuardBoolean.ts, 1, 5)) +>strOrUndefined : Symbol(strOrUndefined, Decl(typeGuardBoolean.ts, 0, 39)) + } +} + diff --git a/tests/baselines/reference/typeGuardBoolean.types b/tests/baselines/reference/typeGuardBoolean.types new file mode 100644 index 0000000000000..db3d6f39cd841 --- /dev/null +++ b/tests/baselines/reference/typeGuardBoolean.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts === +function test(strOrNull: string | null, strOrUndefined: string | undefined) { +>test : (strOrNull: string | null, strOrUndefined: string | undefined) => void +>strOrNull : string | null +>null : null +>strOrUndefined : string | undefined + + var str: string = "original"; +>str : string +>"original" : "original" + + var nil: null; +>nil : null +>null : null + + if (!Boolean(strOrNull)) { +>!Boolean(strOrNull) : boolean +>Boolean(strOrNull) : boolean +>Boolean : BooleanConstructor +>strOrNull : string | null + + nil = strOrNull; +>nil = strOrNull : null +>nil : null +>strOrNull : null + } + else { + str = strOrNull; +>str = strOrNull : string +>str : string +>strOrNull : string + } + if (Boolean(strOrUndefined)) { +>Boolean(strOrUndefined) : boolean +>Boolean : BooleanConstructor +>strOrUndefined : string | undefined + + str = strOrUndefined; +>str = strOrUndefined : string +>str : string +>strOrUndefined : string + } +} + diff --git a/tests/baselines/reference/typeInferenceTypePredicate2.types b/tests/baselines/reference/typeInferenceTypePredicate2.types index d0f36101e1243..a0c05e4a4d0ee 100644 --- a/tests/baselines/reference/typeInferenceTypePredicate2.types +++ b/tests/baselines/reference/typeInferenceTypePredicate2.types @@ -3,7 +3,7 @@ >[true, true, false, null] .filter((thing): thing is boolean => thing !== null) .map(thing => thing.toString()) : string[] >[true, true, false, null] .filter((thing): thing is boolean => thing !== null) .map : (callbackfn: (value: boolean, index: number, array: boolean[]) => U, thisArg?: any) => U[] >[true, true, false, null] .filter((thing): thing is boolean => thing !== null) : boolean[] ->[true, true, false, null] .filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => any, thisArg?: any): boolean[]; } +>[true, true, false, null] .filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => unknown, thisArg?: any): boolean[]; } >[true, true, false, null] : boolean[] >true : true >true : true @@ -11,7 +11,7 @@ >null : null .filter((thing): thing is boolean => thing !== null) ->filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => any, thisArg?: any): boolean[]; } +>filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => unknown, thisArg?: any): boolean[]; } >(thing): thing is boolean => thing !== null : (thing: boolean) => thing is boolean >thing : boolean >thing !== null : boolean diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt index 39e6db64fbf3c..f0360609a575b 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/typeParameterArgumentEquivalence.ts(4,5): error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: number) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence.ts(5,5): error TS2322: Type '(item: number) => boolean' is not assignable to type '(item: T) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'T' is not assignable to type 'number'. @@ -15,6 +16,7 @@ tests/cases/compiler/typeParameterArgumentEquivalence.ts(5,5): error TS2322: Typ !!! error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: number) => boolean'. !!! error TS2322: Types of parameters 'item' and 'item' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: number) => boolean' is not assignable to type '(item: T) => boolean'. diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt index 17fce0384f780..d1727b53863ca 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt @@ -1,9 +1,11 @@ tests/cases/compiler/typeParameterArgumentEquivalence2.ts(4,5): error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: U) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence2.ts(5,5): error TS2322: Type '(item: U) => boolean' is not assignable to type '(item: T) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterArgumentEquivalence2.ts (2 errors) ==== @@ -15,10 +17,12 @@ tests/cases/compiler/typeParameterArgumentEquivalence2.ts(5,5): error TS2322: Ty !!! error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: U) => boolean'. !!! error TS2322: Types of parameters 'item' and 'item' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: U) => boolean' is not assignable to type '(item: T) => boolean'. !!! error TS2322: Types of parameters 'item' and 'item' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt index 1f126d7c00daa..c361a276b9622 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeParameterArgumentEquivalence3.ts(4,5): error TS2322: Type '(item: any) => boolean' is not assignable to type '(item: any) => T'. Type 'boolean' is not assignable to type 'T'. + 'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence3.ts(5,5): error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => boolean'. Type 'T' is not assignable to type 'boolean'. @@ -12,6 +13,7 @@ tests/cases/compiler/typeParameterArgumentEquivalence3.ts(5,5): error TS2322: Ty ~ !!! error TS2322: Type '(item: any) => boolean' is not assignable to type '(item: any) => T'. !!! error TS2322: Type 'boolean' is not assignable to type 'T'. +!!! error TS2322: 'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => boolean'. diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt index c7b19e8725c70..ce194146f6ca9 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt @@ -1,7 +1,9 @@ tests/cases/compiler/typeParameterArgumentEquivalence4.ts(4,5): error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence4.ts(5,5): error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterArgumentEquivalence4.ts (2 errors) ==== @@ -12,9 +14,11 @@ tests/cases/compiler/typeParameterArgumentEquivalence4.ts(5,5): error TS2322: Ty ~ !!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt index 82290733a9e0f..e5196d3d4a50d 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt @@ -1,9 +1,11 @@ tests/cases/compiler/typeParameterArgumentEquivalence5.ts(4,5): error TS2322: Type '() => (item: any) => T' is not assignable to type '() => (item: any) => U'. Type '(item: any) => T' is not assignable to type '(item: any) => U'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence5.ts(5,5): error TS2322: Type '() => (item: any) => U' is not assignable to type '() => (item: any) => T'. Type '(item: any) => U' is not assignable to type '(item: any) => T'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterArgumentEquivalence5.ts (2 errors) ==== @@ -15,10 +17,12 @@ tests/cases/compiler/typeParameterArgumentEquivalence5.ts(5,5): error TS2322: Ty !!! error TS2322: Type '() => (item: any) => T' is not assignable to type '() => (item: any) => U'. !!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '() => (item: any) => U' is not assignable to type '() => (item: any) => T'. !!! error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability.errors.txt b/tests/baselines/reference/typeParameterAssignability.errors.txt index 0e8546097d0c3..0bab4a4c74c69 100644 --- a/tests/baselines/reference/typeParameterAssignability.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability.errors.txt @@ -1,5 +1,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts(5,5): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts (2 errors) ==== @@ -9,7 +11,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index 9d32aed12328d..776649105b40e 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -1,33 +1,63 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(5,5): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(9,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(17,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(20,5): error TS2322: Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(25,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(26,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(27,5): error TS2322: Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(30,5): error TS2322: Type 'V' is not assignable to type 'U'. - Type 'Date' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(31,5): error TS2322: Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(35,5): error TS2322: Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(45,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(46,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(47,5): error TS2322: Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(50,5): error TS2322: Type 'V' is not assignable to type 'U'. - Type 'Date' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(51,5): error TS2322: Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(55,5): error TS2322: Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(64,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(65,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(68,5): error TS2322: Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(70,5): error TS2322: Type 'T' is not assignable to type 'V'. - Type 'U' is not assignable to type 'V'. + 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'U' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(71,5): error TS2322: Type 'U' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts (22 errors) ==== @@ -38,12 +68,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara u = t; // ok ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function foo2(t: T, u: U) { t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // ok } @@ -51,17 +83,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. v = t; // ok u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. v = u; // ok } @@ -69,29 +105,38 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. u = t; u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. -!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. v = t; v = u; v = new Date(); // ok ~ !!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. var d: Date; d = t; // ok @@ -104,29 +149,38 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. u = t; u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. -!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. v = t; v = u; v = new Date(); // ok ~ !!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. var d: Date; d = t; // ok @@ -138,20 +192,26 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // ok u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. v = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. -!!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. v = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability3.errors.txt b/tests/baselines/reference/typeParameterAssignability3.errors.txt index ca7850d747e40..52091c02b8f72 100644 --- a/tests/baselines/reference/typeParameterAssignability3.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability3.errors.txt @@ -1,11 +1,19 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'T'. + 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(15,5): error TS2322: Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'U'. + 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(22,9): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'T'. + 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'U'. + 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts (4 errors) ==== @@ -25,11 +33,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. } class C { @@ -39,10 +51,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara this.t = this.u; // error ~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. this.u = this.t; // error ~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt index 2ca4299c7f8d6..dfef4d192689c 100644 --- a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt +++ b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(8,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(16,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. @@ -17,6 +18,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type ~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. return x; ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. diff --git a/tests/baselines/reference/typeParameterDiamond2.errors.txt b/tests/baselines/reference/typeParameterDiamond2.errors.txt index f268724c6efaa..eecfac811275d 100644 --- a/tests/baselines/reference/typeParameterDiamond2.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond2.errors.txt @@ -1,8 +1,13 @@ tests/cases/compiler/typeParameterDiamond2.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'. - Type 'U' is not assignable to type 'Top'. -tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. - Type 'T | U' is not assignable to type 'Top'. + 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. Type 'U' is not assignable to type 'Top'. + 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. + 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T | U' is not assignable to type 'Top'. + 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'U' is not assignable to type 'Top'. + 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterDiamond2.ts (2 errors) ==== @@ -16,13 +21,18 @@ tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom top = middle; ~~~ !!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. middle = bottom; top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. -!!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T | U' is not assignable to type 'Top'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond3.errors.txt b/tests/baselines/reference/typeParameterDiamond3.errors.txt index 14d5e4a313aac..15abd9973d17e 100644 --- a/tests/baselines/reference/typeParameterDiamond3.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond3.errors.txt @@ -1,15 +1,24 @@ tests/cases/compiler/typeParameterDiamond3.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'. - Type 'T' is not assignable to type 'Top'. + 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterDiamond3.ts(9,13): error TS2322: Type 'Bottom' is not assignable to type 'T | U'. Type 'Top | T | U' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'U'. - Type 'Bottom' is not assignable to type 'U'. - Type 'Top | T | U' is not assignable to type 'U'. - Type 'Top' is not assignable to type 'U'. + 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'Bottom' is not assignable to type 'U'. + 'Bottom' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'Top | T | U' is not assignable to type 'U'. + 'Top | T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'Top' is not assignable to type 'U'. + 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. - Type 'Top | T | U' is not assignable to type 'Top'. - Type 'T' is not assignable to type 'Top'. + 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'Top | T | U' is not assignable to type 'Top'. + 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterDiamond3.ts (3 errors) ==== @@ -23,21 +32,30 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom top = middle; ~~~ !!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. middle = bottom; ~~~~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top | T | U' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'U'. -!!! error TS2322: Type 'Bottom' is not assignable to type 'U'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'. -!!! error TS2322: Type 'Top' is not assignable to type 'U'. +!!! error TS2322: 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Bottom' is not assignable to type 'U'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top' is not assignable to type 'U'. +!!! error TS2322: 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond4.errors.txt b/tests/baselines/reference/typeParameterDiamond4.errors.txt index 2a7fbdaf15c9f..e135515389232 100644 --- a/tests/baselines/reference/typeParameterDiamond4.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond4.errors.txt @@ -1,8 +1,13 @@ tests/cases/compiler/typeParameterDiamond4.ts(8,13): error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. - Type 'T' is not assignable to type 'Top'. -tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. - Type 'Top | T | U' is not assignable to type 'Top'. + 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. + 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'Top | T | U' is not assignable to type 'Top'. + 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterDiamond4.ts (2 errors) ==== @@ -16,13 +21,18 @@ tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom top = middle; ~~~ !!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. middle = bottom; top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt index b5c9fd60206fc..30f71cdfeba1b 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt @@ -1,6 +1,8 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? ==== tests/cases/compiler/typeParametersShouldNotBeEqual.ts (2 errors) ==== @@ -10,10 +12,12 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type x = y; // Error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. x = z; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? z = x; // Ok } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt index d452b99798094..5d04f500fd691 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -1,11 +1,17 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(5,5): error TS2322: Type 'V' is not assignable to type 'T'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(6,5): error TS2322: Type 'T' is not assignable to type 'V'. - Type 'Date' is not assignable to type 'V'. + 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(7,5): error TS2322: Type 'V' is not assignable to type 'U'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(8,5): error TS2322: Type 'U' is not assignable to type 'V'. - Type 'Date' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type 'Object' is not assignable to type 'T'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? @@ -17,21 +23,27 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type x = y; // Ok ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. x = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. z = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. -!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. y = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. z = y; // Error ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. -!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. x = zz; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt index 816db440a4c6d..fcc9c0d3c8786 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt @@ -1,8 +1,11 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Object' is not assignable to type 'T'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. + Type 'Object' is not assignable to type 'T'. + 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. + The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. + The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? ==== tests/cases/compiler/typeParametersShouldNotBeEqual3.ts (2 errors) ==== @@ -12,12 +15,15 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type x = y; // Ok ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. +!!! error TS2322: Type 'Object' is not assignable to type 'T'. +!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. +!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? x = z; // Ok ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. +!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? z = x; // Ok } \ No newline at end of file diff --git a/tests/baselines/reference/typeRelationships.errors.txt b/tests/baselines/reference/typeRelationships.errors.txt index 36f127224022d..6176fc84d2cfb 100644 --- a/tests/baselines/reference/typeRelationships.errors.txt +++ b/tests/baselines/reference/typeRelationships.errors.txt @@ -1,6 +1,8 @@ tests/cases/conformance/types/thisType/typeRelationships.ts(9,9): error TS2322: Type 'C' is not assignable to type 'this'. + 'C' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'C'. tests/cases/conformance/types/thisType/typeRelationships.ts(35,9): error TS2739: Type 'C' is missing the following properties from type 'D': self1, self2, self3, d, bar tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: Type 'D' is not assignable to type 'this'. + 'D' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'D'. ==== tests/cases/conformance/types/thisType/typeRelationships.ts (3 errors) ==== @@ -15,6 +17,7 @@ tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: this.self = this.c; // Error ~~~~~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'this'. +!!! error TS2322: 'C' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'C'. } f2() { var a: C[]; @@ -46,6 +49,7 @@ tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: this.self = this.d; // Error ~~~~~~~~~ !!! error TS2322: Type 'D' is not assignable to type 'this'. +!!! error TS2322: 'D' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'D'. this.c = this.d; } } diff --git a/tests/baselines/reference/unionTypesAssignability.errors.txt b/tests/baselines/reference/unionTypesAssignability.errors.txt index b74bbbd4e08ac..5affcf89ea57c 100644 --- a/tests/baselines/reference/unionTypesAssignability.errors.txt +++ b/tests/baselines/reference/unionTypesAssignability.errors.txt @@ -19,11 +19,17 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(41,1): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(43,1): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(64,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(65,5): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(70,5): error TS2322: Type 'T | U' is not assignable to type 'T'. - Type 'U' is not assignable to type 'T'. + 'T | U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(71,5): error TS2322: Type 'T | U' is not assignable to type 'U'. - Type 'T' is not assignable to type 'U'. + 'T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts (19 errors) ==== @@ -132,9 +138,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var x : T | U; x = t; // ok x = u; // ok @@ -142,10 +150,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp t = x; // error U not assignable to T ~ !!! error TS2322: Type 'T | U' is not assignable to type 'T'. -!!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = x; // error T not assignable to U ~ !!! error TS2322: Type 'T | U' is not assignable to type 'U'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/unknownSymbolOffContextualType1.types b/tests/baselines/reference/unknownSymbolOffContextualType1.types index 04321b94dadd8..8ad87586580ff 100644 --- a/tests/baselines/reference/unknownSymbolOffContextualType1.types +++ b/tests/baselines/reference/unknownSymbolOffContextualType1.types @@ -35,9 +35,9 @@ function getMaxWidth(elementNames: string[]) { var enabled = elements.filter(function (e) { >enabled : HTMLElement[] >elements.filter(function (e) { return !e.isDisabled; }) : HTMLElement[] ->elements.filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any): HTMLElement[]; } +>elements.filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => unknown, thisArg?: any): HTMLElement[]; } >elements : HTMLElement[] ->filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any): HTMLElement[]; } +>filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => unknown, thisArg?: any): HTMLElement[]; } >function (e) { return !e.isDisabled; } : (e: HTMLElement) => boolean >e : HTMLElement diff --git a/tests/baselines/reference/user/assert.log b/tests/baselines/reference/user/assert.log index 672c147428dee..60e693ae6f3ca 100644 --- a/tests/baselines/reference/user/assert.log +++ b/tests/baselines/reference/user/assert.log @@ -9,7 +9,7 @@ node_modules/assert/assert.js(130,10): error TS2339: Property 'generatedMessage' node_modules/assert/assert.js(132,10): error TS2339: Property 'message' does not exist on type 'typeof ok'. node_modules/assert/assert.js(133,10): error TS2339: Property 'generatedMessage' does not exist on type 'typeof ok'. node_modules/assert/assert.js(154,12): error TS2339: Property 'stack' does not exist on type 'typeof ok'. -node_modules/assert/test.js(25,5): error TS2367: This condition will always return 'false' since the types 'string | undefined' and 'boolean' have no overlap. +node_modules/assert/test.js(25,5): error TS2367: This condition will always return 'false' since the types 'string | undefined' and 'true' have no overlap. node_modules/assert/test.js(39,5): error TS2552: Cannot find name 'test'. Did you mean 'tests'? node_modules/assert/test.js(55,5): error TS2552: Cannot find name 'test'. Did you mean 'tests'? node_modules/assert/test.js(74,5): error TS2552: Cannot find name 'test'. Did you mean 'tests'? diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 45afc61657ed1..45ba3fc971a56 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -869,16 +869,6 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(24079,1): error TS2323: Cannot redeclare exported variable 'Buf16'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(24080,1): error TS2323: Cannot redeclare exported variable 'Buf32'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(26059,1): error TS2323: Cannot redeclare exported variable 'deflate'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(27915,27): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'. - Type 'number' is not assignable to type 'string'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(27918,30): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'. - Type 'number' is not assignable to type 'string'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(27921,30): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'. - Type 'number' is not assignable to type 'string'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(27928,27): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'. - Type 'number' is not assignable to type 'string'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(27929,20): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'. - Type 'number' is not assignable to type 'string'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(27956,16): error TS2323: Cannot redeclare exported variable 'parse'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28222,51): error TS2300: Duplicate identifier '_read'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28457,20): error TS2339: Property 'emit' does not exist on type 'Readable'. @@ -5027,9 +5017,9 @@ node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(42,20): node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(42,125): error TS2339: Property 'length1' does not exist on type 'number'. node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(42,138): error TS2339: Property 'length2' does not exist on type 'number'. node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(43,411): error TS2403: Subsequent variable declarations must have the same type. Variable 'g' must be of type 'string', but here has type 'any'. -node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(43,443): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. -node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(44,7): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. -node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(44,220): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(43,443): error TS2367: This condition will always return 'false' since the types '1' and 'string' have no overlap. +node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(44,7): error TS2367: This condition will always return 'false' since the types '-1' and 'string' have no overlap. +node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(44,220): error TS2367: This condition will always return 'false' since the types '0' and 'string' have no overlap. node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(47,403): error TS2339: Property 'diffs' does not exist on type 'typeof diff_match_patch'. node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(47,417): error TS2339: Property 'start2' does not exist on type 'typeof diff_match_patch'. node_modules/chrome-devtools-frontend/front_end/diff/diff_match_patch.js(47,429): error TS2339: Property 'start1' does not exist on type 'typeof diff_match_patch'. @@ -10912,7 +10902,7 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.j node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(822,79): error TS2339: Property 'charAt' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(823,41): error TS2339: Property 'length' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(823,88): error TS2339: Property 'charAt' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(839,9): error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(839,9): error TS2367: This condition will always return 'false' since the types 'void' and '0' have no overlap. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(854,9): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(862,12): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(862,13): error TS1345: An expression of type 'void' cannot be tested for truthiness diff --git a/tests/baselines/reference/user/prettier.log b/tests/baselines/reference/user/prettier.log index 22c00d2bd46bb..6ee6e91cb6bc2 100644 --- a/tests/baselines/reference/user/prettier.log +++ b/tests/baselines/reference/user/prettier.log @@ -1,6 +1,6 @@ Exit Code: 1 Standard output: -node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts(1,8): error TS1192: Module '"/prettier/prettier/node_modules/typescript/lib/typescript"' has no default export. +node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts(1,8): error TS1259: Module '"/prettier/prettier/node_modules/typescript/lib/typescript"' can only be default-imported using the 'esModuleInterop' flag src/cli/util.js(60,44): error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. src/cli/util.js(119,38): error TS2339: Property 'sync' does not exist on type '(...args: any[]) => any'. src/cli/util.js(372,29): error TS2532: Object is possibly 'undefined'. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index 8f4b868d5527a..c5feff00abc0d 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -10,58 +10,58 @@ node_modules/uglify-js/lib/ast.js(932,25): error TS2339: Property 'self' does no node_modules/uglify-js/lib/ast.js(933,37): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. node_modules/uglify-js/lib/compress.js(175,42): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(532,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(855,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1110,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1124,51): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'true | ((node: any) => any)' has no compatible call signatures. -node_modules/uglify-js/lib/compress.js(1188,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1229,112): error TS2454: Variable 'args' is used before being assigned. -node_modules/uglify-js/lib/compress.js(1230,29): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(1239,87): error TS2322: Type 'false' is not assignable to type 'number'. -node_modules/uglify-js/lib/compress.js(1247,29): error TS2322: Type 'false' is not assignable to type 'never'. -node_modules/uglify-js/lib/compress.js(1353,53): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1454,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1564,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1596,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1708,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(858,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1114,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1128,51): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'true | ((node: any) => any)' has no compatible call signatures. +node_modules/uglify-js/lib/compress.js(1192,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1233,112): error TS2454: Variable 'args' is used before being assigned. +node_modules/uglify-js/lib/compress.js(1234,29): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(1243,87): error TS2322: Type 'false' is not assignable to type 'number'. +node_modules/uglify-js/lib/compress.js(1251,29): error TS2322: Type 'false' is not assignable to type 'never'. +node_modules/uglify-js/lib/compress.js(1359,53): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1460,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1570,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1602,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1714,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'number[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2031,59): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2069,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(2037,59): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2075,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'any[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2217,34): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2883,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3328,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3341,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. -node_modules/uglify-js/lib/compress.js(3475,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3528,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3545,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3570,75): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3643,63): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3828,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3849,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3859,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4018,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4070,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. -node_modules/uglify-js/lib/compress.js(4126,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4238,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4537,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4621,37): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4829,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[RegExp, (string | undefined)?]'. +node_modules/uglify-js/lib/compress.js(2223,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2948,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3400,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3413,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. +node_modules/uglify-js/lib/compress.js(3547,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3600,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3617,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3642,75): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3715,63): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3900,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3921,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3931,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4090,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4142,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. +node_modules/uglify-js/lib/compress.js(4203,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4315,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4614,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4698,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4906,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[RegExp, (string | undefined)?]'. Property '0' is missing in type 'any[]' but required in type '[RegExp, (string | undefined)?]'. -node_modules/uglify-js/lib/compress.js(4987,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4994,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. -node_modules/uglify-js/lib/compress.js(4998,36): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(5003,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(5490,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(5922,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. -node_modules/uglify-js/lib/compress.js(5949,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6023,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6095,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6101,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6534,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6549,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6552,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(6558,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6586,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5070,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5077,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. +node_modules/uglify-js/lib/compress.js(5081,36): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(5086,41): error TS2339: Property 'get' does not exist on type 'string'. +node_modules/uglify-js/lib/compress.js(5589,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6084,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. +node_modules/uglify-js/lib/compress.js(6111,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6185,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6257,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6263,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6696,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6711,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6714,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(6720,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6748,34): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/minify.js(170,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. node_modules/uglify-js/lib/mozilla-ast.js(566,33): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/output.js(246,25): error TS2554: Expected 0 arguments, but got 2. diff --git a/tests/cases/compiler/genericFunctionInference1.ts b/tests/cases/compiler/genericFunctionInference1.ts index c6b864f82e518..c90c94cf5e874 100644 --- a/tests/cases/compiler/genericFunctionInference1.ts +++ b/tests/cases/compiler/genericFunctionInference1.ts @@ -65,6 +65,53 @@ declare function baz(t1: T, t2: T, u: U): [T, U]; let f60 = wrap3(baz); +declare const list2: { + (a: T): T[]; + foo: string; + bar(): number; +} + +let f70 = pipe(list2, box); +let f71 = pipe(box, list2); + +declare class Point { + constructor(x: number, y: number); + readonly x: number; + readonly y: number; +} + +declare class Bag { + constructor(...args: T[]); + contains(value: T): boolean; + static foo: string; +} + +function asFunction(cf: new (...args: A) => B) { + return (...args: A) => new cf(...args); +} + +const newPoint = asFunction(Point); +const newBag = asFunction(Bag); +const p1 = new Point(10, 20); +const p2 = newPoint(10, 20); +const bag1 = new Bag(1, 2, 3); +const bag2 = newBag('a', 'b', 'c'); + +declare class Comp

{ + props: P; + constructor(props: P); +} + +type CompClass

= new (props: P) => Comp

; + +declare function myHoc

(C: CompClass

): CompClass

; + +type GenericProps = { foo: number, stuff: T }; + +declare class GenericComp extends Comp> {} + +const GenericComp2 = myHoc(GenericComp); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } diff --git a/tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts b/tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts index 9a84cc328b286..1cd967c294fb5 100644 --- a/tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts +++ b/tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts @@ -1,4 +1,24 @@ // @noimplicitany: true -var x = {}["hello"]; -var y: string = { '': 'foo' }['']; \ No newline at end of file +var a = {}["hello"]; +var b: string = { '': 'foo' }['']; + +var c = { + get: (key: string) => 'foobar' +}; +c['hello']; +const foo = c['hello']; + +var d = { + set: (key: string) => 'foobar' +}; +const bar = d['hello']; + +var e = { + set: (key: string) => 'foobar', + get: (key: string) => 'foobar' +}; +e['hello'] = 'modified'; +e['hello'] += 1; +e['hello'] ++; + diff --git a/tests/cases/compiler/objectFromEntries.ts b/tests/cases/compiler/objectFromEntries.ts new file mode 100644 index 0000000000000..9993edbf344ec --- /dev/null +++ b/tests/cases/compiler/objectFromEntries.ts @@ -0,0 +1,11 @@ +// @target: es2019 + +const o = Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]); +const o2 = Object.fromEntries(new URLSearchParams()); +const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]])); + +const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +const o4 = Object.fromEntries(frozenArray); + +const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); +const o5 = Object.fromEntries(frozenArray2); diff --git a/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging1.ts b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging1.ts new file mode 100644 index 0000000000000..d9cd0802f417d --- /dev/null +++ b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging1.ts @@ -0,0 +1,14 @@ +// @filename: types.ts +declare module "*.foo" { + let everywhere: string; +} + + +// @filename: testA.ts +import { everywhere, onlyInA } from "a.foo"; +declare module "a.foo" { + let onlyInA: number; +} + +// @filename: testB.ts +import { everywhere, onlyInA } from "b.foo"; // Error diff --git a/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging2.ts b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging2.ts new file mode 100644 index 0000000000000..7b02846c242b7 --- /dev/null +++ b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging2.ts @@ -0,0 +1,17 @@ +// @filename: types.ts +declare module "*.foo" { + let everywhere: string; +} + + +// @filename: testA.ts +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +declare module "a.foo" { + let onlyInA: number; +} + +// @filename: testB.ts +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +declare module "a.foo" { + let alsoOnlyInA: number; +} \ No newline at end of file diff --git a/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging3.ts b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging3.ts new file mode 100644 index 0000000000000..85232eca2208b --- /dev/null +++ b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging3.ts @@ -0,0 +1,12 @@ +// @filename: types.ts +declare module "*.foo" { + export interface OhNo { star: string } +} + +// @filename: test.ts +declare module "a.foo" { + export interface OhNo { a: string } +} +import { OhNo } from "b.foo" +declare let ohno: OhNo; +ohno.a // oh no diff --git a/tests/cases/conformance/decorators/1.0lib-noErrors.ts b/tests/cases/conformance/decorators/1.0lib-noErrors.ts index 6966e3e70d07d..391c0926a82b7 100644 --- a/tests/cases/conformance/decorators/1.0lib-noErrors.ts +++ b/tests/cases/conformance/decorators/1.0lib-noErrors.ts @@ -78,7 +78,7 @@ declare function encodeURI(uri: string): string; * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ -declare function encodeURIComponent(uriComponent: string): string; +declare function encodeURIComponent(uriComponent: string | number | boolean): string; interface PropertyDescriptor { configurable?: boolean; @@ -1141,4 +1141,4 @@ declare var Array: { (...items: T[]): T[]; isArray(arg: any): boolean; prototype: Array; -} \ No newline at end of file +} \ No newline at end of file diff --git a/tests/cases/conformance/es2019/globalThisCollision.ts b/tests/cases/conformance/es2019/globalThisCollision.ts new file mode 100644 index 0000000000000..d73a7b6217e64 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisCollision.ts @@ -0,0 +1,5 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @filename: globalThisCollision.js +var globalThis; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts b/tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts new file mode 100644 index 0000000000000..af595c1621f96 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts @@ -0,0 +1,17 @@ +// @strict: true + +const [] = {}; // should be error +const {} = undefined; // error correctly +(([]) => 0)({}); // should be error +(({}) => 0)(undefined); // should be error + +function foo({}: undefined) { + return 0 +} +function bar([]: {}) { + return 0 +} + +const { }: undefined = 1 + +const []: {} = {} diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts new file mode 100644 index 0000000000000..3f2dde227ba8c --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts @@ -0,0 +1,14 @@ +// @strictNullChecks: true +function test(strOrNull: string | null, strOrUndefined: string | undefined) { + var str: string = "original"; + var nil: null; + if (!Boolean(strOrNull)) { + nil = strOrNull; + } + else { + str = strOrNull; + } + if (Boolean(strOrUndefined)) { + str = strOrUndefined; + } +} diff --git a/tests/cases/conformance/types/conditional/inferTypes2.ts b/tests/cases/conformance/types/conditional/inferTypes2.ts index fbf4ca808336e..77b910c511385 100644 --- a/tests/cases/conformance/types/conditional/inferTypes2.ts +++ b/tests/cases/conformance/types/conditional/inferTypes2.ts @@ -14,3 +14,11 @@ export declare function foo2(obj: T): T extends { [K in keyof BadNested(obj: T) { return foo2(obj); } + +// Repros from #31099 + +type Weird = any extends infer U ? U : never; +type AlsoWeird = unknown extends infer U ? U : never; + +const a: Weird = null; +const b: string = a; diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts index 356e0a42ae9b4..5251a83bb0611 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts @@ -127,3 +127,14 @@ function fn} | {elements: Array}>(par function fn2>(param: T, cb: (element: T[number]) => void) { cb(param[0]); } + +// Repro from #31149 + +function fn3>(param: T, cb: (element: T[number]) => void) { + cb(param[0]); +} + +function fn4() { + let x: Array[K] = 'abc'; + let y: ReadonlyArray[K] = 'abc'; +} diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts new file mode 100644 index 0000000000000..e264df259adee --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts @@ -0,0 +1,193 @@ +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { + type S = { done: boolean, value: number }; + type T = + | { done: true, value: number } // T0 + | { done: false, value: number }; // T1 + + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +} + +// Dropping constituents of T +namespace Example2 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +} + +// Unmatched discriminants +namespace Example3 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 | 4 } // T1 + | { a: 2, b: 3 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +} + +// Unmatched non-discriminants +namespace Example4 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4, c: string }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +} + +// Maximum discriminant combinations +namespace Example5 { + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; + type S = { a: N, b: N, c: N }; + type T = { a: 0, b: N, c: N } + | { a: 1, b: N, c: N } + | { a: 2, b: N, c: N } + | { a: N, b: 0, c: N } + | { a: N, b: 1, c: N } + | { a: N, b: 2, c: N } + | { a: N, b: N, c: 0 } + | { a: N, b: N, c: 1 } + | { a: N, b: N, c: 2 }; + declare let s: S; + declare let t: T; + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { + type Style1 = { + type: "A"; + data: string; + } | { + type: "B"; + data: string; + }; + + type Style2 = { + type: "A" | "B"; + data: string; + } + + const a: Style2 = { type: "A", data: "whatevs" }; + let b: Style1; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { + interface Blue { + color: 'blue' + } + interface Yellow { + color?: 'yellow', + } + function draw(val: Blue | Yellow) { } + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { + return draw({ color: currentColor }); + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { + interface ILinearAxis { type: "linear"; } + + interface ICategoricalAxis { type: "categorical"; } + + type IAxis = ILinearAxis | ICategoricalAxis; + type IAxisType = "linear" | "categorical"; + + function getAxisType(): IAxisType { + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; + const good: IAxis = { type: undefined }; + good.type = getAxisType(); +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { + interface ThingTypeOne { + type: 'one'; + } + + interface ThingTypeTwo { + type: 'two'; + } + + type ThingType = 'one' | 'two'; + + type Thing = ThingTypeOne | ThingTypeTwo; + + function makeNewThing(thingType: ThingType): Thing { + return { + type: thingType + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { + type Action = { type: 'activate' } | { type: 'disactivate' }; + + function dispatchAction(action: Action): void { + + } + + const active = true; + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { + interface A1 { + type: "A1"; + } + interface A2 { + type: "A2"; + } + type AU = A1 | A2; + + function foo(obj1: AU) { + const obj2: AU = { + type: obj1.type + }; + } +} \ No newline at end of file diff --git a/tests/lib/lib.d.ts b/tests/lib/lib.d.ts index ad17bec673e95..5f089bb3c82eb 100644 --- a/tests/lib/lib.d.ts +++ b/tests/lib/lib.d.ts @@ -77,7 +77,7 @@ declare function encodeURI(uri: string): string; * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ -declare function encodeURIComponent(uriComponent: string): string; +declare function encodeURIComponent(uriComponent: string | number | boolean): string; /** * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence.