Merge branch 'master' into builderAPI

This commit is contained in:
Sheetal Nandi
2019-04-30 12:36:07 -07:00
194 changed files with 5196 additions and 789 deletions
+326 -110
View File
@@ -498,6 +498,7 @@ namespace ts {
* This is only used if there is no exact match.
*/
let patternAmbientModules: PatternAmbientModule[];
let patternAmbientModuleAugmentations: Map<Symbol> | undefined;
let globalObjectType: ObjectType;
let globalFunctionType: ObjectType;
@@ -534,8 +535,7 @@ namespace ts {
let deferredGlobalTemplateStringsArrayType: ObjectType;
let deferredGlobalImportMetaType: ObjectType;
let deferredGlobalExtractSymbol: Symbol;
let deferredGlobalExcludeSymbol: Symbol;
let deferredGlobalPickSymbol: Symbol;
let deferredGlobalOmitSymbol: Symbol;
let deferredGlobalBigIntType: ObjectType;
const allPotentiallyUnusedIdentifiers = createMap<PotentiallyUnusedIdentifier[]>(); // key is file name
@@ -888,7 +888,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);
@@ -915,13 +915,16 @@ 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) {
// Do not report an error when merging `var globalThis` with the built-in `globalThis`,
@@ -993,10 +996,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);
});
}
@@ -1026,7 +1029,22 @@ namespace ts {
// obtain item referenced by 'export='
mainModule = resolveExternalModuleSymbol(mainModule);
if (mainModule.flags & SymbolFlags.Namespace) {
mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol);
// If were 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`.
@@ -2455,6 +2473,14 @@ namespace ts {
if (patternAmbientModules) {
const pattern = findBestPatternMatch(patternAmbientModules, _ => _.pattern, moduleReference);
if (pattern) {
// If the module reference matched a pattern ambient module ('*.foo') but theres 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);
}
}
@@ -4942,13 +4968,12 @@ namespace ts {
if (omitKeyType.flags & TypeFlags.Never) {
return source;
}
const pickTypeAlias = getGlobalPickSymbol();
const excludeTypeAlias = getGlobalExcludeSymbol();
if (!pickTypeAlias || !excludeTypeAlias) {
const omitTypeAlias = getGlobalOmitSymbol();
if (!omitTypeAlias) {
return errorType;
}
const pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]);
return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]);
return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
}
const members = createSymbolTable();
for (const prop of getPropertiesOfType(source)) {
@@ -8565,7 +8590,7 @@ namespace ts {
function getSignatureInstantiation(signature: Signature, typeArguments: Type[] | undefined, isJavascript: boolean, inferredTypeParameters?: ReadonlyArray<TypeParameter>): 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;
@@ -8641,7 +8666,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;
@@ -9277,12 +9303,8 @@ namespace ts {
return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
}
function getGlobalExcludeSymbol(): Symbol {
return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
}
function getGlobalPickSymbol(): Symbol {
return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
function getGlobalOmitSymbol(): Symbol {
return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
}
function getGlobalBigIntType(reportErrors: boolean) {
@@ -10083,7 +10105,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;
@@ -10117,7 +10139,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));
}
}
}
}
@@ -10386,11 +10414,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
@@ -10405,7 +10433,7 @@ namespace ts {
// type Foo<T extends { x: any }> = 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
@@ -12322,6 +12350,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;
@@ -12485,7 +12522,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;
}
}
@@ -12495,7 +12532,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;
}
}
@@ -13173,7 +13210,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) {
@@ -13193,6 +13230,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;
@@ -13256,9 +13306,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<Type[]>(sourcePropertiesFiltered.length);
const excludedProperties = createUnderscoreEscapedMap<true>();
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<true> | 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<true> | 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);
@@ -13288,7 +13514,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)) {
@@ -13331,89 +13557,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<true> | 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;
}
@@ -15952,6 +16119,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.
@@ -18436,7 +18607,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(<ParenthesizedExpression>parent, contextFlags);
return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(<ParenthesizedExpression>parent, contextFlags);
}
case SyntaxKind.JsxExpression:
return getContextualTypeForJsxExpression(<JsxExpression>parent);
@@ -20052,6 +20223,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.
@@ -20452,11 +20652,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(<ObjectType>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;
@@ -23798,16 +24011,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(<Expression>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
@@ -23815,7 +24030,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.
@@ -24009,7 +24225,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);
}
+76 -40
View File
@@ -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<ExtendedConfigCacheEntry>
): 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<FileExtensionInfo>): 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<FileExtensionInfo>, /*@internal*/ extendedConfigCache?: Map<ExtendedConfigCacheEntry>): 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<FileExtensionInfo> = [],
extendedConfigCache?: Map<ExtendedConfigCacheEntry>
): 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<Diagnostic>,
json: any,
sourceFile: TsConfigSourceFile | undefined,
host: ParseConfigHost,
basePath: string,
configFileName: string | undefined,
resolutionStack: string[],
errors: Push<Diagnostic>,
extendedConfigCache?: Map<ExtendedConfigCacheEntry>
): 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<Diagnostic>,
extendedConfigCache?: Map<ExtendedConfigCacheEntry>
): 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<Diagnostic>): boolean {
+25
View File
@@ -2284,4 +2284,29 @@ namespace ts {
}
return result;
}
export function cartesianProduct<T>(arrays: readonly T[][]) {
const result: T[][] = [];
cartesianProductWorker(arrays, result, /*outer*/ undefined, 0);
return result;
}
function cartesianProductWorker<T>(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);
}
}
}
}
+8 -1
View File
@@ -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
+1 -1
View File
@@ -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<JSDocTypeTag>(SyntaxKind.JSDocTypeTag, "type");
tag.typeExpression = typeExpression;
tag.comment = comment;
+3 -18
View File
@@ -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: <SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia>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);
}
+25 -11
View File
@@ -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) {
+60 -23
View File
@@ -349,12 +349,28 @@ namespace ts {
let projectCompilerOptions = baseCompilerOptions;
const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions);
setGetSourceFileAsHashVersioned(compilerHost, host);
compilerHost.getParsedCommandLine = fileName => parseConfigFile(fileName as ResolvedConfigFileName, toResolvedConfigFilePath(fileName as ResolvedConfigFileName));
compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
let moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
if (!compilerHost.resolveModuleNames) {
const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!;
compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) =>
loadWithLocalCache<ResolvedModuleFull>(Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader);
}
let cacheState: {
originalReadFile: CompilerHost["readFile"];
originalFileExists: CompilerHost["fileExists"];
originalDirectoryExists: CompilerHost["directoryExists"];
originalCreateDirectory: CompilerHost["createDirectory"];
originalWriteFile: CompilerHost["writeFile"] | undefined;
originalReadFileWithCache: CompilerHost["readFile"];
originalGetSourceFile: CompilerHost["getSourceFile"];
} | undefined;
const buildInfoChecked = createMap() as ConfigFileMap<true>;
const extendedConfigCache = createMap<ExtendedConfigCacheEntry>();
// Watch state
const builderPrograms = createMap() as ConfigFileMap<T>;
@@ -409,7 +425,7 @@ namespace ts {
let diagnostic: Diagnostic | undefined;
parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = d => diagnostic = d;
const parsed = getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost);
const parsed = getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache);
parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = noop;
configFileCache.set(configFilePath, parsed || diagnostic!);
return parsed;
@@ -786,6 +802,7 @@ namespace ts {
}
clearProjectStatus(resolved);
addProjToQueue(resolved, reloadLevel);
enableCache();
}
function clearProjectStatus(resolved: ResolvedConfigFilePath) {
@@ -847,6 +864,7 @@ namespace ts {
}
}
else {
disableCache();
reportErrorSummary();
}
}
@@ -1341,26 +1359,53 @@ namespace ts {
return configFileNames.map(resolveProjectName);
}
function buildAllProjects(): ExitStatus {
if (watch) { reportWatchStatus(Diagnostics.Starting_compilation_in_watch_mode); }
// TODO:: In watch mode as well to use caches for incremental build once we can invalidate caches correctly and have right api
// Override readFile for json files and output .d.ts to cache the text
const savedReadFileWithCache = readFileWithCache;
const savedGetSourceFile = compilerHost.getSourceFile;
function enableCache() {
if (cacheState) {
disableCache();
}
const originalReadFileWithCache = readFileWithCache;
const originalGetSourceFile = compilerHost.getSourceFile;
const { originalReadFile, originalFileExists, originalDirectoryExists,
originalCreateDirectory, originalWriteFile, getSourceFileWithCache,
readFileWithCache: newReadFileWithCache
} = changeCompilerHostLikeToUseCache(host, toPath, (...args) => savedGetSourceFile.call(compilerHost, ...args));
} = changeCompilerHostLikeToUseCache(host, toPath, (...args) => originalGetSourceFile.call(compilerHost, ...args));
readFileWithCache = newReadFileWithCache;
compilerHost.getSourceFile = getSourceFileWithCache!;
const originalResolveModuleNames = compilerHost.resolveModuleNames;
if (!compilerHost.resolveModuleNames) {
const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!;
compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) =>
loadWithLocalCache<ResolvedModuleFull>(Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader);
cacheState = {
originalReadFile,
originalFileExists,
originalDirectoryExists,
originalCreateDirectory,
originalWriteFile,
originalReadFileWithCache,
originalGetSourceFile,
};
}
function disableCache() {
if (!cacheState) return;
host.readFile = cacheState.originalReadFile;
host.fileExists = cacheState.originalFileExists;
host.directoryExists = cacheState.originalDirectoryExists;
host.createDirectory = cacheState.originalCreateDirectory;
host.writeFile = cacheState.originalWriteFile;
compilerHost.getSourceFile = cacheState.originalGetSourceFile;
readFileWithCache = cacheState.originalReadFileWithCache;
extendedConfigCache.clear();
if (moduleResolutionCache) {
moduleResolutionCache.directoryToModuleNameMap.clear();
moduleResolutionCache.moduleNameToDirectoryMap.clear();
}
cacheState = undefined;
}
function buildAllProjects(): ExitStatus {
if (options.watch) { reportWatchStatus(Diagnostics.Starting_compilation_in_watch_mode); }
enableCache();
const buildOrder = getBuildOrder();
reportBuildQueue(buildOrder);
@@ -1371,15 +1416,7 @@ namespace ts {
buildNextInvalidatedProject();
}
reportErrorSummary();
host.readFile = originalReadFile;
host.fileExists = originalFileExists;
host.directoryExists = originalDirectoryExists;
host.createDirectory = originalCreateDirectory;
host.writeFile = originalWriteFile;
compilerHost.getSourceFile = savedGetSourceFile;
readFileWithCache = savedReadFileWithCache;
compilerHost.resolveModuleNames = originalResolveModuleNames;
moduleResolutionCache = undefined;
disableCache();
return diagnostics.size ? ExitStatus.DiagnosticsPresent_OutputsSkipped : ExitStatus.Success;
}
+2 -1
View File
@@ -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;
+10
View File
@@ -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";
}
+4 -4
View File
@@ -9,7 +9,7 @@ interface Array<T> {
* predicate. If it is not provided, undefined is used instead.
*/
find<S extends T>(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<T> {
* @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<T> {
* predicate. If it is not provided, undefined is used instead.
*/
find<S extends T>(predicate: (this: void, value: T, index: number, obj: ReadonlyArray<T>) => value is S, thisArg?: any): S | undefined;
find(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg?: any): T | undefined;
find(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => 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<T> {
* @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<T>) => boolean, thisArg?: any): number;
findIndex(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => unknown, thisArg?: any): number;
}
interface RegExp {
+3 -67
View File
@@ -98,79 +98,15 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
race<T>(values: T[]): Promise<T extends PromiseLike<infer U> ? 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.
* @param values An iterable of Promises.
* @returns A new Promise.
*/
race<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
/**
* 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<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
/**
* 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<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
/**
* 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<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<T1 | T2 | T3 | T4 | T5 | T6>;
/**
* 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<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<T1 | T2 | T3 | T4 | T5>;
/**
* 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<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<T1 | T2 | T3 | T4>;
/**
* 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<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<T1 | T2 | T3>;
/**
* 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<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<T1 | T2>;
/**
* 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<T>(values: (T | PromiseLike<T>)[]): Promise<T>;
race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>;
/**
* Creates a new rejected promise for the provided reason.
+1
View File
@@ -1,4 +1,5 @@
/// <reference lib="es2018" />
/// <reference lib="es2019.array" />
/// <reference lib="es2019.object" />
/// <reference lib="es2019.string" />
/// <reference lib="es2019.symbol" />
+15
View File
@@ -0,0 +1,15 @@
/// <reference lib="es2015.iterable" />
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<T = any>(entries: Iterable<readonly [PropertyKey, T]>): { [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<readonly any[]>): any;
}
+4 -4
View File
@@ -513,7 +513,7 @@ interface Boolean {
interface BooleanConstructor {
new(value?: any): Boolean;
(value?: any): boolean;
<T>(value?: T): value is Exclude<T, false | null | undefined | '' | 0>;
readonly prototype: Boolean;
}
@@ -1273,13 +1273,13 @@ interface Array<T> {
* @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<T> {
* @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.
+1
View File
@@ -36,6 +36,7 @@
"es2018.promise",
"es2018.intl",
"es2019.array",
"es2019.object",
"es2019.string",
"es2019.symbol",
"es2020.string",
+1 -1
View File
@@ -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:
@@ -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,
+1 -1
View File
@@ -62,7 +62,7 @@ namespace ts {
}
}
const libContent = `${TestFSWithWatch.libFile.content}
export const libContent = `${TestFSWithWatch.libFile.content}
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };`;
+51 -3
View File
@@ -278,7 +278,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"]
);
});
@@ -308,8 +307,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"]
);
});
});
@@ -760,6 +758,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", `/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />`);
fs.writeFileSync("/lib/lib.esnext.d.ts", libContent);
fs.writeFileSync("/lib/lib.d.ts", `/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />`);
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
});
});
});
}
+2 -2
View File
@@ -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
@@ -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'.
@@ -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;
@@ -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))
@@ -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
@@ -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;
}
@@ -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;
@@ -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))
}
@@ -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
}
@@ -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'.
@@ -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
@@ -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))
@@ -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
+17 -3
View File
@@ -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<ExtendedConfigCacheEntry>): 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<FileExtensionInfo>): ParsedCommandLine;
function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray<FileExtensionInfo>, /*@internal*/ extendedConfigCache?: Map<ExtendedConfigCacheEntry>): 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[];
+17 -3
View File
@@ -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<ExtendedConfigCacheEntry>): 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<FileExtensionInfo>): ParsedCommandLine;
function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray<FileExtensionInfo>, /*@internal*/ extendedConfigCache?: Map<ExtendedConfigCacheEntry>): 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[];
+2 -2
View File
@@ -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 : { <S extends { name: string; }>(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 : { <S extends { name: string; }>(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 : { <S extends { name: string; }>(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 : { <S extends { name: string; }>(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
+4 -4
View File
@@ -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 : { <S extends string | number | boolean>(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 : { <S extends string | number | boolean>(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 : { <S extends string | number | boolean>(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 : { <S extends string | number | boolean>(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<string | number | boolean>;
@@ -37,8 +37,8 @@ const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBoolean
const readonlyFoundNumber: number | undefined = readonlyArrayOfStringsNumbersAndBooleans.find(isNumber);
>readonlyFoundNumber : number
>readonlyArrayOfStringsNumbersAndBooleans.find(isNumber) : number
>readonlyArrayOfStringsNumbersAndBooleans.find : { <S extends string | number | boolean>(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 : { <S extends string | number | boolean>(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 : { <S extends string | number | boolean>(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 : { <S extends string | number | boolean>(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
@@ -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 '<T extends Base, U extends Derived>(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 '<T extends Base, U extends Derived>(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 '<T extends Base, U extends Derived>(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 '<T extends Base, U extends Derived>(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 '<T extends Derived>(...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 '<T extends Base>(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 '<T extends Derived[]>(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 '<T>(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: <T extends Base, U extends Derived>(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: <T extends Base, U extends Derived>(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: <T extends Base, U extends Derived>(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: <T extends Base, U extends Derived>(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: <T extends Derived>(...x: T[]) => T;
a10 = b10; // ok
b10 = a10; // ok
~~~
!!! error TS2322: Type '(...x: Derived[]) => Derived' is not assignable to type '<T extends Derived>(...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: <T extends Base>(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 '<T extends Derived[]>(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: <T>(x: { a: T; b: T }) => T;
a14 = b14; // ok
~~~
@@ -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 '<T extends Base, U extends Derived>(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 '<T extends Derived>(...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 '<T extends Derived>(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 '<T>(x: T) => string[]' is not assignable to type '<T>(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 '<T>(x: T) => T[]' is not assignable to type '<T>(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 '<T>(x: T) => string[]' is not assignable to type '<T>(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: <T extends Base, U extends Derived>(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: <T extends Derived>(...x: T[]) => T;
@@ -205,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '<T>(x: T) => string[]' is not assignable to type '<T>(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 '<T>(x: T) => T[]' is not assignable to type '<T>(x: T) => string[]'.
@@ -224,5 +231,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '<T>(x: T) => string[]' is not assignable to type '<T>(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 '{}'.
}
}
@@ -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 '<T>(x: { a: T; b: T; }) => T[]' is not assignable to type '<U, V>(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 '<T extends Base>(x: { a: T; b: T; }) => T[]' is not assignable to type '<U, V>(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: <U, V>(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: <T>(x: { a: T; b: T }) => T[];
a15 = b16; // ok
b15 = a16; // ok
@@ -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 '<T extends Base>(x: { a: T; b: T; }) => T[]' is not assignable to type '<T>(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: <T>(x: { a: T; b: T }) => T[];
x.a16 = b16;
b16 = x.a16;
@@ -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 <T extends Base, U extends Derived>(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 <T extends Base, U extends Derived>(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 <T extends Base, U extends Derived>(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 <T extends Base, U extends Derived>(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 <T extends Derived>(...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 <T extends Base>(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 <T extends Derived[]>(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 <T>(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 <T extends Base, U extends Derived>(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 <T extends Base, U extends Derived>(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 <T extends Base, U extends Derived>(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 <T extends Base, U extends Derived>(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 <T extends Derived>(...x: T[]) => T;
a10 = b10; // ok
b10 = a10; // ok
~~~
!!! error TS2322: Type 'new (...x: Derived[]) => Derived' is not assignable to type 'new <T extends Derived>(...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 <T extends Base>(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 <T extends Derived[]>(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 <T>(x: { a: T; b: T }) => T;
a14 = b14; // ok
~~~
@@ -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 <T extends Base, U extends Derived>(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 <T extends Derived>(...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 <T extends Derived>(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 <T>(x: T) => string[]' is not assignable to type 'new <T>(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 <T>(x: T) => T[]' is not assignable to type 'new <T>(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 <T>(x: T) => string[]' is not assignable to type 'new <T>(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 <T extends Base, U extends Derived>(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 <T extends Derived>(...x: T[]) => T;
@@ -241,6 +247,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new <T>(x: T) => string[]' is not assignable to type 'new <T>(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 <T>(x: T) => T[]' is not assignable to type 'new <T>(x: T) => string[]'.
@@ -260,5 +267,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new <T>(x: T) => string[]' is not assignable to type 'new <T>(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 '{}'.
}
}
@@ -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 <T>(x: { a: T; b: T; }) => T[]' is not assignable to type 'new <U, V>(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 <T extends Base>(x: { a: T; b: T; }) => T[]' is not assignable to type 'new <U, V>(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 <U, V>(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 <T>(x: { a: T; b: T }) => T[];
a15 = b16; // ok
b15 = a16; // ok
@@ -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 <T extends Base>(x: { a: T; b: T; }) => T[]' is not assignable to type 'new <T>(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 <T>(x: { a: T; b: T }) => T[];
x.a16 = b16;
b16 = x.a16;
@@ -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
};
}
}
@@ -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 = {}));
@@ -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))
};
}
}
@@ -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"
};
}
}
@@ -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'.
@@ -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>() => 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>() => 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>() => 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>() => 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>() => 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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(x: T) => any' is not assignable to type '<T>() => T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(116,13): error TS2322: Type '<T>(x: T, y: T) => any' is not assignable to type '<T>(x: T) => T'.
@@ -139,10 +162,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
~~~
!!! error TS2322: Type '() => T' is not assignable to type '<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.a = t.a2;
~~~
!!! error TS2322: Type '(x?: T) => T' is not assignable to type '<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.a = t.a3;
~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>() => 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>() => 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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '<T>(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 '{}'.
}
}
@@ -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<T>'.
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<T>' 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<T>'.
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<T>' 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<T>'.
!!! 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<T>' 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<T>'.
!!! 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<T>' is not assignable to type '{ [x: number]: Derived2; }'.
@@ -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<T>'.
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<T>' 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<T>'.
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<T>' 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<T>'.
!!! 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<T>' 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<T>'.
!!! 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<T>' is not assignable to type '{ [x: number]: Derived2; }'.
@@ -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<T>'.
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<T>'.
!!! 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; };
@@ -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<T>'.
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<T>' 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<T>'.
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<T>' 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<T>'.
!!! 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<T>' 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<T>'.
!!! 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<T>' is not assignable to type '{ [x: string]: Derived2; }'.
@@ -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<T>'.
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<T>' 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<T>'.
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<T>' 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<T>'.
!!! 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<T>' 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<T>'.
!!! 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<T>' is not assignable to type '{ [x: string]: Derived2; }'.
@@ -1,6 +1,7 @@
tests/cases/compiler/assignmentStricterConstraints.ts(7,1): error TS2322: Type '<T, S extends T>(x: T, y: S) => void' is not assignable to type '<T, S>(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 '<T, S extends T>(x: T, y: S) => void' is not assignable to type '<T, S>(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, "")
@@ -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; }
@@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
Types of property 'a2' are incompatible.
Type '<T>(x: T) => string' is not assignable to type '<T>(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 '<T>(x: T) => string' is not assignable to type '<T>(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: <T>(x: T) => string; // error because base returns non-void;
}
@@ -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 '<T extends Base, U extends Derived>(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 '<T>(x: T) => string[]' is not assignable to type '<T>(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 '<T>(x: T) => T[]' is not assignable to type '<T>(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 '<T>(x: T) => string[]' is not assignable to type '<T>(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: <T>(x: T) => string[]; // error
}
@@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
Type '(x: T) => T[]' is not assignable to type '<T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a2' are incompatible.
Type '(x: T) => string[]' is not assignable to type '<T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a3' are incompatible.
Type '(x: T) => T' is not assignable to type '<T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a4' are incompatible.
Type '<U>(x: T, y: U) => string' is not assignable to type '<T, U>(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<T>' incorrectly extends interface 'A'.
Types of property 'a5' are incompatible.
Type '<U>(x: (arg: T) => U) => T' is not assignable to type '<T, U>(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<T>' incorrectly extends interface 'A'.
Types of property 'a11' are incompatible.
Type '<U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type '<T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a16' are incompatible.
Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '<T extends Base>(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 '<T>(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 '<T>(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 '<T>(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 '<U>(x: T, y: U) => string' is not assignable to type '<T, U>(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: <U>(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: <U>(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: <U>(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[];
}
@@ -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
@@ -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 '{}'.
}
@@ -2,14 +2,17 @@ tests/cases/compiler/immutable.ts(341,22): error TS2430: Interface 'Keyed<K, V>'
Types of property 'toSeq' are incompatible.
Type '() => Keyed<K, V>' is not assignable to type '() => this'.
Type 'Keyed<K, V>' is not assignable to type 'this'.
'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
tests/cases/compiler/immutable.ts(359,22): error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
Types of property 'toSeq' are incompatible.
Type '() => Indexed<T>' is not assignable to type '() => this'.
Type 'Indexed<T>' is not assignable to type 'this'.
'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
Types of property 'toSeq' are incompatible.
Type '() => Set<T>' is not assignable to type '() => this'.
Type 'Set<T>' is not assignable to type 'this'.
'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
==== tests/cases/compiler/complex.ts (0 errors) ====
@@ -380,6 +383,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
!!! error TS2430: Types of property 'toSeq' are incompatible.
!!! error TS2430: Type '() => Keyed<K, V>' is not assignable to type '() => this'.
!!! error TS2430: Type 'Keyed<K, V>' is not assignable to type 'this'.
!!! error TS2430: 'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
toJS(): Object;
toJSON(): { [key: string]: V };
toSeq(): Seq.Keyed<K, V>;
@@ -403,6 +407,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
!!! error TS2430: Types of property 'toSeq' are incompatible.
!!! error TS2430: Type '() => Indexed<T>' is not assignable to type '() => this'.
!!! error TS2430: Type 'Indexed<T>' is not assignable to type 'this'.
!!! error TS2430: 'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
toJS(): Array<any>;
toJSON(): Array<T>;
// Reading values
@@ -440,6 +445,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
!!! error TS2430: Types of property 'toSeq' are incompatible.
!!! error TS2430: Type '() => Set<T>' is not assignable to type '() => this'.
!!! error TS2430: Type 'Set<T>' is not assignable to type 'this'.
!!! error TS2430: 'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): Seq.Set<T>;
@@ -10,13 +10,15 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["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<T, TextChannel>["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');
@@ -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<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'T'.
'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' 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<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'T'.
'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' 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<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>'.
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<Part>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2322: Type 'ZeroOf<T>' 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<T>' 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<T>'.
Type 'string | number' is not assignable to type 'ZeroOf<T>'.
Type 'string' is not assignable to type 'ZeroOf<T>'.
@@ -179,9 +185,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
x = y; // Error
~
!!! error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'T'.
!!! error TS2322: 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' 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<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'T'.
!!! error TS2322: 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' 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<T>' 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<T>' 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<T>'.
@@ -1,7 +1,9 @@
tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant<A>' is not assignable to type 'Covariant<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(19,5): error TS2322: Type 'Contravariant<B>' is not assignable to type 'Contravariant<A>'.
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<B>' is not assignable to type 'Invariant<A>'.
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<Extract<T, Foo>, 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<T, Bar>' 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<A>' is not assignable to type 'Covariant<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 '{}'.
}
function f2<A, B extends A>(a: Contravariant<A>, b: Contravariant<B>) {
@@ -56,6 +60,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2
~
!!! error TS2322: Type 'Contravariant<B>' is not assignable to type 'Contravariant<A>'.
!!! 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<T, Function> is a T that is known to be a Function
@@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
Types of property 'a2' are incompatible.
Type 'new <T>(x: T) => string' is not assignable to type 'new <T>(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 <T>(x: T) => string' is not assignable to type 'new <T>(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 <T>(x: T) => string; // error because base returns non-void;
}
@@ -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 <T extends Base, U extends Derived>(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 <T>(x: T) => string[]' is not assignable to type 'new <T>(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 <T>(x: T) => T[]' is not assignable to type 'new <T>(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 <T>(x: T) => string[]' is not assignable to type 'new <T>(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 <T>(x: T) => string[]; // error
}
@@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
Type 'new (x: T) => T[]' is not assignable to type 'new <T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a2' are incompatible.
Type 'new (x: T) => string[]' is not assignable to type 'new <T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a3' are incompatible.
Type 'new (x: T) => T' is not assignable to type 'new <T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a4' are incompatible.
Type 'new <U>(x: T, y: U) => string' is not assignable to type 'new <T, U>(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<T>' incorrectly extends interface 'A'.
Types of property 'a5' are incompatible.
Type 'new <U>(x: (arg: T) => U) => T' is not assignable to type 'new <T, U>(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<T>' incorrectly extends interface 'A'.
Types of property 'a11' are incompatible.
Type 'new <U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type 'new <T>(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<T>' incorrectly extends interface 'A'.
Types of property 'a16' are incompatible.
Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new <T extends Base>(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 <T>(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 <T>(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 <T>(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 <U>(x: T, y: U) => string' is not assignable to type 'new <T, U>(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 <U>(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 <U>(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 <U>(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[];
}
@@ -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;
}
}
@@ -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<T>'
}
}
@@ -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
@@ -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
@@ -26,14 +26,14 @@ export async function runSampleWorks<A, B, C, D, E>(
>bluebird : typeof bluebird
>all : bluebird<any>[]
>[a, b, c, d, e].filter(el => !!el) : bluebird<A>[]
>[a, b, c, d, e].filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => any, thisArg?: any): bluebird<A>[]; }
>[a, b, c, d, e].filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => unknown, thisArg?: any): bluebird<A>[]; }
>[a, b, c, d, e] : bluebird<A>[]
>a : bluebird<A>
>b : bluebird<B>
>c : bluebird<C>
>d : bluebird<D>
>e : bluebird<E>
>filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => any, thisArg?: any): bluebird<A>[]; }
>filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => unknown, thisArg?: any): bluebird<A>[]; }
>el => !!el : (el: bluebird<A>) => boolean
>el : bluebird<A>
>!!el : boolean
@@ -88,14 +88,14 @@ export async function runSampleBreaks<A, B, C, D, E>(
>bluebird : typeof bluebird
>all : bluebird<any>[]
>[a, b, c, d, e].filter(el => !!el) : bluebird<A>[]
>[a, b, c, d, e].filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => any, thisArg?: any): bluebird<A>[]; }
>[a, b, c, d, e].filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => unknown, thisArg?: any): bluebird<A>[]; }
>[a, b, c, d, e] : bluebird<A>[]
>a : bluebird<A>
>b : bluebird<B>
>c : bluebird<C>
>d : bluebird<D>
>e : bluebird<E>
>filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => any, thisArg?: any): bluebird<A>[]; }
>filter : { <S extends bluebird<A>>(callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird<A>, index: number, array: bluebird<A>[]) => unknown, thisArg?: any): bluebird<A>[]; }
>el => !!el : (el: bluebird<A>) => boolean
>el : bluebird<A>
>!!el : boolean
@@ -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<string>' is not assignable to type 'C<number>'.
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'.
}
}
@@ -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
@@ -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 '<T>(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'.
}
}
@@ -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; }'.
}
@@ -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;
@@ -1,5 +1,6 @@
tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts(9,1): error TS2322: Type '<S>() => S[]' is not assignable to type '<T>(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>() => S[]' is not assignable to type '<T>(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);
@@ -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'.
@@ -78,15 +78,15 @@ var r4 = foo2(1, i2); // error
>i2 : I2<string>
var r4b = foo2(1, a); // any
>r4b : unknown
>foo2(1, a) : unknown
>r4b : number
>foo2(1, a) : number
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>1 : 1
>a : new <T>(x: T) => T
var r5 = foo2(1, i); // any
>r5 : unknown
>foo2(1, i) : unknown
>r5 : number
>foo2(1, i) : number
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>1 : 1
>i : I
@@ -112,16 +112,16 @@ function foo3<T, U>(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 : <T, U>(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 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>null : null
>a : new <T>(x: T) => T
@@ -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'.
@@ -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<T, U>(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 '{}'.
}
@@ -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<T, U>(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 '{}'.
}
@@ -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<T extends Number>(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<T, U extends T>(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<T, U extends T>(x: U, y: T = x) { } // ok
function foo6<T, U extends T, V extends U>(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<T, U extends T, V extends U>(x: V, y: U = x) { } // should be ok
@@ -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<any>(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<number>(y);
~~~~~~
!!! error TS2558: Expected 0 type arguments, but got 1.
@@ -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'.
@@ -155,9 +155,9 @@ const arrayFilter = <T>(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 : { <S extends T>(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 : { <S extends T>(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 : { <S extends T>(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 : { <S extends T>(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);
@@ -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<T, U, V>' requires between 2 and 3 type arguments.
tests/cases/compiler/genericDefaultsErrors.ts(33,15): error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
tests/cases/compiler/genericDefaultsErrors.ts(36,15): error TS2707: Generic type 'i09<T, U, V>' 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<T, U extends T = number>(): 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<T, U, V = number>(): void;
f11(); // ok
@@ -88,6 +91,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet
interface i08<T, U extends T = number> { } // 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<T, U, V = number> { }
type i09t00 = i09; // error
@@ -1,5 +1,6 @@
tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts(6,1): error TS2322: Type '<S>() => S[]' is not assignable to type '<T>(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>() => S[]' is not assignable to type '<T>(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();
@@ -1,4 +1,4 @@
tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument of type '<a>(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 '<a>(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: {
<T>(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<T> {
constructor(...args: T[]);
contains(value: T): boolean;
static foo: string;
}
function asFunction<A extends any[], B>(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<P> {
props: P;
constructor(props: P);
}
type CompClass<P> = new (props: P) => Comp<P>;
declare function myHoc<P>(C: CompClass<P>): CompClass<P>;
type GenericProps<T> = { foo: number, stuff: T };
declare class GenericComp<T> extends Comp<GenericProps<T>> {}
const GenericComp2 = myHoc(GenericComp);
// #417
function mirror<A, B>(f: (a: A) => B): (a: A) => B { return f; }
@@ -63,6 +63,53 @@ declare function baz<T, U extends T>(t1: T, t2: T, u: U): [T, U];
let f60 = wrap3(baz);
declare const list2: {
<T>(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<T> {
constructor(...args: T[]);
contains(value: T): boolean;
static foo: string;
}
function asFunction<A extends any[], B>(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<P> {
props: P;
constructor(props: P);
}
type CompClass<P> = new (props: P) => Comp<P>;
declare function myHoc<P>(C: CompClass<P>): CompClass<P>;
type GenericProps<T> = { foo: number, stuff: T };
declare class GenericComp<T> extends Comp<GenericProps<T>> {}
const GenericComp2 = myHoc(GenericComp);
// #417
function mirror<A, B>(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);
@@ -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))
<T>(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<T> {
>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<A extends any[], B>(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<P> {
>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<P> = new (props: P) => Comp<P>;
>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<P>(C: CompClass<P>): CompClass<P>;
>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<T> = { 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<T> extends Comp<GenericProps<T>> {}
>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<A, B>(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<a>(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<a>(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<a, b, c>(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<T, U>(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: <T, U>(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 = <T, U>(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<a, b>(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<P> = (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: <P>(C: Component<P>) => Component<P>;
>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: <P>(C: Component<P>) => Component<P>;
>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: <T>(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: <T>(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<T, U = T>(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<T>(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))
@@ -443,6 +443,150 @@ let f60 = wrap3(baz);
>wrap3 : <A, B, C>(f: (a: A, b1: B, b2: B) => C) => (a: A, b1: B, b2: B) => C
>baz : <T, U extends T>(t1: T, t2: T, u: U) => [T, U]
declare const list2: {
>list2 : { <T>(a: T): T[]; foo: string; bar(): number; }
<T>(a: T): T[];
>a : T
foo: string;
>foo : string
bar(): number;
>bar : () => number
}
let f70 = pipe(list2, box);
>f70 : <T>(a: T) => { value: T[]; }
>pipe(list2, box) : <T>(a: T) => { value: T[]; }
>pipe : { <A extends any[], B>(ab: (...args: A) => B): (...args: A) => B; <A extends any[], B, C>(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; <A extends any[], B, C, D>(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; }
>list2 : { <T>(a: T): T[]; foo: string; bar(): number; }
>box : <V>(x: V) => { value: V; }
let f71 = pipe(box, list2);
>f71 : <V>(x: V) => { value: V; }[]
>pipe(box, list2) : <V>(x: V) => { value: V; }[]
>pipe : { <A extends any[], B>(ab: (...args: A) => B): (...args: A) => B; <A extends any[], B, C>(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; <A extends any[], B, C, D>(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; }
>box : <V>(x: V) => { value: V; }
>list2 : { <T>(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<T> {
>Bag : Bag<T>
constructor(...args: T[]);
>args : T[]
contains(value: T): boolean;
>contains : (value: T) => boolean
>value : T
static foo: string;
>foo : string
}
function asFunction<A extends any[], B>(cf: new (...args: A) => B) {
>asFunction : <A extends any[], B>(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 : <A extends any[], B>(cf: new (...args: A) => B) => (...args: A) => B
>Point : typeof Point
const newBag = asFunction(Bag);
>newBag : <T>(...args: T[]) => Bag<T>
>asFunction(Bag) : <T>(...args: T[]) => Bag<T>
>asFunction : <A extends any[], B>(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<number>
>new Bag(1, 2, 3) : Bag<number>
>Bag : typeof Bag
>1 : 1
>2 : 2
>3 : 3
const bag2 = newBag('a', 'b', 'c');
>bag2 : Bag<string>
>newBag('a', 'b', 'c') : Bag<string>
>newBag : <T>(...args: T[]) => Bag<T>
>'a' : "a"
>'b' : "b"
>'c' : "c"
declare class Comp<P> {
>Comp : Comp<P>
props: P;
>props : P
constructor(props: P);
>props : P
}
type CompClass<P> = new (props: P) => Comp<P>;
>CompClass : CompClass<P>
>props : P
declare function myHoc<P>(C: CompClass<P>): CompClass<P>;
>myHoc : <P>(C: CompClass<P>) => CompClass<P>
>C : CompClass<P>
type GenericProps<T> = { foo: number, stuff: T };
>GenericProps : GenericProps<T>
>foo : number
>stuff : T
declare class GenericComp<T> extends Comp<GenericProps<T>> {}
>GenericComp : GenericComp<T>
>Comp : Comp<GenericProps<T>>
const GenericComp2 = myHoc(GenericComp);
>GenericComp2 : new <T>(props: GenericProps<T>) => Comp<GenericProps<T>>
>myHoc(GenericComp) : new <T>(props: GenericProps<T>) => Comp<GenericProps<T>>
>myHoc : <P>(C: CompClass<P>) => CompClass<P>
>GenericComp : typeof GenericComp
// #417
function mirror<A, B>(f: (a: A) => B): (a: A) => B { return f; }
@@ -835,7 +979,7 @@ foo2(() => {});
>() => {} : () => void
foo2(identity);
>foo2(identity) : [<T>(value: T) => T, unknown]
>foo2(identity) : [<T>(value: T) => T, <T>(value: T) => T]
>foo2 : <T, U = T>(fn: T, a?: U | undefined, b?: U | undefined) => [T, U]
>identity : <T>(value: T) => T
@@ -2,18 +2,18 @@
// Repro from #29067
function test<T extends { a: string }>(obj: T) {
>test : <T extends { a: string; }>(obj: T) => Pick<T, Exclude<keyof T, "a">> & { b: string; }
>test : <T extends { a: string; }>(obj: T) => Omit<T, "a"> & { b: string; }
>a : string
>obj : T
let { a, ...rest } = obj;
>a : string
>rest : Pick<T, Exclude<keyof T, "a">>
>rest : Omit<T, "a">
>obj : T
return { ...rest, b: a };
>{ ...rest, b: a } : Pick<T, Exclude<keyof T, "a">> & { b: string; }
>rest : Pick<T, Exclude<keyof T, "a">>
>{ ...rest, b: a } : Omit<T, "a"> & { b: string; }
>rest : Omit<T, "a">
>b : string
>a : string
}
@@ -30,7 +30,7 @@ let o2: { b: string, x: number } = test(o1);
>o2 : { b: string; x: number; }
>b : string
>x : number
>test(o1) : Pick<{ a: string; x: number; }, "x"> & { b: string; }
>test : <T extends { a: string; }>(obj: T) => Pick<T, Exclude<keyof T, "a">> & { b: string; }
>test(o1) : Omit<{ a: string; x: number; }, "a"> & { b: string; }
>test : <T extends { a: string; }>(obj: T) => Omit<T, "a"> & { b: string; }
>o1 : { a: string; x: number; }
@@ -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 : { <S extends HTMLElement>(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 : { <S extends HTMLElement>(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 : { <S extends HTMLElement>(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 : { <S extends HTMLElement>(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
@@ -16,7 +16,7 @@ function f1<T extends { a: string, b: number }>(obj: T) {
let { a: a1, ...r1 } = obj;
>a : any
>a1 : string
>r1 : Pick<T, Exclude<keyof T, "a">>
>r1 : Omit<T, "a">
>obj : T
let { a: a2, b: b2, ...r2 } = obj;
@@ -24,24 +24,24 @@ function f1<T extends { a: string, b: number }>(obj: T) {
>a2 : string
>b : any
>b2 : number
>r2 : Pick<T, Exclude<keyof T, "a" | "b">>
>r2 : Omit<T, "a" | "b">
>obj : T
let { 'a': a3, ...r3 } = obj;
>a3 : string
>r3 : Pick<T, Exclude<keyof T, "a">>
>r3 : Omit<T, "a">
>obj : T
let { ['a']: a4, ...r4 } = obj;
>'a' : "a"
>a4 : string
>r4 : Pick<T, Exclude<keyof T, "a">>
>r4 : Omit<T, "a">
>obj : T
let { [a]: a5, ...r5 } = obj;
>a : "a"
>a5 : string
>r5 : Pick<T, Exclude<keyof T, "a">>
>r5 : Omit<T, "a">
>obj : T
}
@@ -68,7 +68,7 @@ function f2<T extends { [sa]: string, [sb]: number }>(obj: T) {
>a1 : string
>sb : unique symbol
>b1 : number
>r1 : Pick<T, Exclude<keyof T, unique symbol | unique symbol>>
>r1 : Omit<T, unique symbol | unique symbol>
>obj : T
}
@@ -83,7 +83,7 @@ function f3<T, K1 extends keyof T, K2 extends keyof T>(obj: T, k1: K1, k2: K2) {
>a1 : T[K1]
>k2 : K2
>a2 : T[K2]
>r1 : Pick<T, Exclude<keyof T, K1 | K2>>
>r1 : Omit<T, K1 | K2>
>obj : T
}
@@ -104,7 +104,7 @@ function f4<K1 extends keyof Item, K2 extends keyof Item>(obj: Item, k1: K1, k2:
>a1 : Item[K1]
>k2 : K2
>a2 : Item[K2]
>r1 : Pick<Item, Exclude<"a", K1 | K2> | Exclude<"b", K1 | K2> | Exclude<"c", K1 | K2>>
>r1 : Omit<Item, K1 | K2>
>obj : Item
}
@@ -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 = <T>a;
y = <T>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 = <T>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'.
}

Some files were not shown because too many files have changed in this diff Show More