diff --git a/README.md b/README.md index ad43c9abefa67..db157f74b2cd2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). +[TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescript). ## Installing diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c28d63dec766f..aac6a74ac2aa7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -94,8 +94,6 @@ namespace ts { const globalThisSymbol = createSymbol(SymbolFlags.Module, "globalThis" as __String, CheckFlags.Readonly); globalThisSymbol.exports = globals; - globalThisSymbol.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; - (globalThisSymbol.valueDeclaration as Identifier).escapedText = "globalThis" as __String; globals.set(globalThisSymbol.escapedName, globalThisSymbol); const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); @@ -500,6 +498,7 @@ namespace ts { * This is only used if there is no exact match. */ let patternAmbientModules: PatternAmbientModule[]; + let patternAmbientModuleAugmentations: Map | undefined; let globalObjectType: ObjectType; let globalFunctionType: ObjectType; @@ -536,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(); // key is file name @@ -891,7 +889,7 @@ namespace ts { * Note: if target is transient, then it is mutable, and mergeSymbol with both mutate and return it. * If target is not transient, mergeSymbol will produce a transient clone, mutate that and return it. */ - function mergeSymbol(target: Symbol, source: Symbol): Symbol { + function mergeSymbol(target: Symbol, source: Symbol, unidirectional = false): Symbol { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & SymbolFlags.Assignment) { Debug.assert(source !== target); @@ -918,16 +916,24 @@ namespace ts { addRange(target.declarations, source.declarations); if (source.members) { if (!target.members) target.members = createSymbolTable(); - mergeSymbolTable(target.members, source.members); + mergeSymbolTable(target.members, source.members, unidirectional); } if (source.exports) { if (!target.exports) target.exports = createSymbolTable(); - mergeSymbolTable(target.exports, source.exports); + mergeSymbolTable(target.exports, source.exports, unidirectional + ); + } + if (!unidirectional) { + recordMergedSymbol(target, source); } - recordMergedSymbol(target, source); } else if (target.flags & SymbolFlags.NamespaceModule) { - error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + // Do not report an error when merging `var globalThis` with the built-in `globalThis`, + // as we will already report a "Declaration name conflicts..." error, and this error + // won't make much sense. + if (target !== globalThisSymbol) { + error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } } else { // error const isEitherEnum = !!(target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum); @@ -991,10 +997,10 @@ namespace ts { return combined; } - function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { + function mergeSymbolTable(target: SymbolTable, source: SymbolTable, unidirectional = false) { source.forEach((sourceSymbol, id) => { const targetSymbol = target.get(id); - target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol); }); } @@ -1024,7 +1030,22 @@ namespace ts { // obtain item referenced by 'export=' mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & SymbolFlags.Namespace) { - mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); + // If we’re merging an augmentation to a pattern ambient module, we want to + // perform the merge unidirectionally from the augmentation ('a.foo') to + // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you + // all the exports both from the pattern and from the augmentation, but + // 'getMergedSymbol()' on *.foo only gives you exports from *.foo. + if (some(patternAmbientModules, module => mainModule === module.symbol)) { + const merged = mergeSymbol(moduleAugmentation.symbol, mainModule, /*unidirectional*/ true); + if (!patternAmbientModuleAugmentations) { + patternAmbientModuleAugmentations = createMap(); + } + // moduleName will be a StringLiteral since this is not `declare global`. + patternAmbientModuleAugmentations.set((moduleName as StringLiteral).text, merged); + } + else { + mergeSymbol(mainModule, moduleAugmentation.symbol); + } } else { // moduleName will be a StringLiteral since this is not `declare global`. @@ -2453,6 +2474,14 @@ namespace ts { if (patternAmbientModules) { const pattern = findBestPatternMatch(patternAmbientModules, _ => _.pattern, moduleReference); if (pattern) { + // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // module augmentation by the specific name requested ('a.foo'), we store the merged symbol + // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports + // from a.foo. + const augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference); + if (augmentation) { + return getMergedSymbol(augmentation); + } return getMergedSymbol(pattern.symbol); } } @@ -4940,13 +4969,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)) { @@ -8563,7 +8591,7 @@ namespace ts { function getSignatureInstantiation(signature: Signature, typeArguments: Type[] | undefined, isJavascript: boolean, inferredTypeParameters?: ReadonlyArray): Signature { const instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); if (inferredTypeParameters) { - const returnSignature = getSingleCallSignature(getReturnTypeOfSignature(instantiatedSignature)); + const returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature)); if (returnSignature) { const newReturnSignature = cloneSignature(returnSignature); newReturnSignature.typeParameters = inferredTypeParameters; @@ -8639,7 +8667,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; @@ -9275,12 +9304,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) { @@ -10081,7 +10106,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; @@ -10115,7 +10140,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)); + } } } } @@ -10319,8 +10350,16 @@ namespace ts { return links.resolvedType; } - function getActualTypeVariable(type: Type) { - return type.flags & TypeFlags.Substitution ? (type).typeVariable : type; + function getActualTypeVariable(type: Type): Type { + if (type.flags & TypeFlags.Substitution) { + return (type).typeVariable; + } + if (type.flags & TypeFlags.IndexedAccess && ( + (type).objectType.flags & TypeFlags.Substitution || + (type).indexType.flags & TypeFlags.Substitution)) { + return getIndexedAccessType(getActualTypeVariable((type).objectType), getActualTypeVariable((type).indexType)); + } + return type; } /** @@ -10384,11 +10423,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 @@ -10403,7 +10442,7 @@ namespace ts { // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. if (isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { - return instantiateType(root.trueType, combinedMapper || mapper); + return combinedMapper ? instantiateType(root.trueType, combinedMapper) : trueType; } } // Return a deferred type for a check that is neither definitely true nor definitely false @@ -12320,6 +12359,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; @@ -12483,7 +12531,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; } } @@ -12493,7 +12541,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; } } @@ -13178,7 +13226,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) { @@ -13198,6 +13246,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; @@ -13276,9 +13337,185 @@ namespace ts { return Ternary.False; } - function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { + function typeRelatedToDiscriminatedType(source: Type, target: UnionType) { + // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. + // a. If the number of combinations is above a set limit, the comparison is too complex. + // 2. Filter 'target' to the subset of types whose discriminants exist in the matrix. + // a. If 'target' does not satisfy all discriminants in the matrix, 'source' is not related. + // 3. For each type in the filtered 'target', determine if all non-discriminant properties of + // 'target' are related to a property in 'source'. + // + // NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts + // for examples. + + const sourceProperties = getPropertiesOfObjectType(source); + const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (!sourcePropertiesFiltered) return Ternary.False; + + // Though we could compute the number of combinations as we generate + // the matrix, this would incur additional memory overhead due to + // array allocations. To reduce this overhead, we first compute + // the number of combinations to ensure we will not surpass our + // fixed limit before incurring the cost of any allocations: + let numCombinations = 1; + for (const sourceProperty of sourcePropertiesFiltered) { + numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + if (numCombinations > 25) { + // We've reached the complexity limit. + return Ternary.False; + } + } + + // Compute the set of types for each discriminant property. + const sourceDiscriminantTypes: Type[][] = new Array(sourcePropertiesFiltered.length); + const excludedProperties = createUnderscoreEscapedMap(); + for (let i = 0; i < sourcePropertiesFiltered.length; i++) { + const sourceProperty = sourcePropertiesFiltered[i]; + const sourcePropertyType = getTypeOfSymbol(sourceProperty); + sourceDiscriminantTypes[i] = sourcePropertyType.flags & TypeFlags.Union + ? (sourcePropertyType as UnionType).types + : [sourcePropertyType]; + excludedProperties.set(sourceProperty.escapedName, true); + } + + // Match each combination of the cartesian product of discriminant properties to one or more + // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. + const discriminantCombinations = cartesianProduct(sourceDiscriminantTypes); + const matchingTypes: Type[] = []; + for (const combination of discriminantCombinations) { + let hasMatch = false; + outer: for (const type of target.types) { + for (let i = 0; i < sourcePropertiesFiltered.length; i++) { + const sourceProperty = sourcePropertiesFiltered[i]; + const targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); + if (!targetProperty) continue outer; + if (sourceProperty === targetProperty) continue; + // We compare the source property to the target in the context of a single discriminant type. + const related = propertyRelatedTo(source, target, sourceProperty, targetProperty, _ => combination[i], /*reportErrors*/ false); + // If the target property could not be found, or if the properties were not related, + // then this constituent is not a match. + if (!related) { + continue outer; + } + } + pushIfUnique(matchingTypes, type, equateValues); + hasMatch = true; + } + if (!hasMatch) { + // We failed to match any type for this combination. + return Ternary.False; + } + } + + // Compare the remaining non-discriminant properties of each match. + let result = Ternary.True; + for (const type of matchingTypes) { + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + if (result) { + result &= signaturesRelatedTo(source, type, SignatureKind.Call, /*reportStructuralErrors*/ false); + if (result) { + result &= signaturesRelatedTo(source, type, SignatureKind.Construct, /*reportStructuralErrors*/ false); + if (result) { + result &= indexTypesRelatedTo(source, type, IndexKind.String, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false); + if (result) { + result &= indexTypesRelatedTo(source, type, IndexKind.Number, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false); + } + } + } + } + if (!result) { + return result; + } + } + return result; + } + + function excludeProperties(properties: Symbol[], excludedProperties: UnderscoreEscapedMap | undefined) { + if (!excludedProperties || properties.length === 0) return properties; + let result: Symbol[] | undefined; + for (let i = 0; i < properties.length; i++) { + if (!excludedProperties.has(properties[i].escapedName)) { + if (result) { + result.push(properties[i]); + } + } + else if (!result) { + result = properties.slice(0, i); + } + } + return result || properties; + } + + function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean): Ternary { + const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); + const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); + if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { + const hasDifferingDeclarations = sourceProp.valueDeclaration !== targetProp.valueDeclaration; + if (getCheckFlags(sourceProp) & CheckFlags.ContainsPrivate && hasDifferingDeclarations) { + if (reportErrors) { + reportError(Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return Ternary.False; + } + if (hasDifferingDeclarations) { + if (reportErrors) { + if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) { + reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); + } + else { + reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), + typeToString(sourcePropFlags & ModifierFlags.Private ? source : target), + typeToString(sourcePropFlags & ModifierFlags.Private ? target : source)); + } + } + return Ternary.False; + } + } + else if (targetPropFlags & ModifierFlags.Protected) { + if (!isValidOverrideOf(sourceProp, targetProp)) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), + typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); + } + return Ternary.False; + } + } + else if (sourcePropFlags & ModifierFlags.Protected) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, + symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return Ternary.False; + } + // If the target comes from a partial union prop, allow `undefined` in the target type + const related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(getCheckFlags(targetProp) & CheckFlags.Partial)), reportErrors); + if (!related) { + if (reportErrors) { + reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + } + return Ternary.False; + } + // When checking for comparability, be more lenient with optional properties. + if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) { + // TypeScript 1.0 spec (April 2014): 3.8.3 + // S is a subtype of a type T, and T is a supertype of S if ... + // S' and T are object types and, for each member M in T.. + // M is a property and S' contains a property N where + // if M is a required property, N is also a required property + // (M - property in T) + // (N - property in S) + if (reportErrors) { + reportError(Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, + symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return Ternary.False; + } + return related; + } + + function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean, excludedProperties: UnderscoreEscapedMap | undefined): Ternary { if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); + return propertiesIdenticalTo(source, target, excludedProperties); } const requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); const unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false); @@ -13308,7 +13545,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)) { @@ -13351,89 +13588,30 @@ namespace ts { // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members const properties = target.flags & TypeFlags.Union ? getPossiblePropertiesOfUnionType(target as UnionType) : getPropertiesOfType(target); - for (const targetProp of properties) { + for (const targetProp of excludeProperties(properties, excludedProperties)) { if (!(targetProp.flags & SymbolFlags.Prototype)) { const sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { continue; } - const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); - const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { - const hasDifferingDeclarations = sourceProp.valueDeclaration !== targetProp.valueDeclaration; - if (getCheckFlags(sourceProp) & CheckFlags.ContainsPrivate && hasDifferingDeclarations) { - if (reportErrors) { - reportError(Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); - } - return Ternary.False; - } - if (hasDifferingDeclarations) { - if (reportErrors) { - if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) { - reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), - typeToString(sourcePropFlags & ModifierFlags.Private ? source : target), - typeToString(sourcePropFlags & ModifierFlags.Private ? target : source)); - } - } - return Ternary.False; - } - } - else if (targetPropFlags & ModifierFlags.Protected) { - if (!isValidOverrideOf(sourceProp, targetProp)) { - if (reportErrors) { - reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), - typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); - } - return Ternary.False; - } - } - else if (sourcePropFlags & ModifierFlags.Protected) { - if (reportErrors) { - reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, - symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return Ternary.False; - } - // If the target comes from a partial union prop, allow `undefined` in the target type - const related = isRelatedTo(getTypeOfSymbol(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(getCheckFlags(targetProp) & CheckFlags.Partial)), reportErrors); + const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { - if (reportErrors) { - reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } return Ternary.False; } result &= related; - // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) { - // TypeScript 1.0 spec (April 2014): 3.8.3 - // S is a subtype of a type T, and T is a supertype of S if ... - // S' and T are object types and, for each member M in T.. - // M is a property and S' contains a property N where - // if M is a required property, N is also a required property - // (M - property in T) - // (N - property in S) - if (reportErrors) { - reportError(Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, - symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return Ternary.False; - } } } } return result; } - function propertiesIdenticalTo(source: Type, target: Type): Ternary { + function propertiesIdenticalTo(source: Type, target: Type, excludedProperties: UnderscoreEscapedMap | undefined): Ternary { if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) { return Ternary.False; } - const sourceProperties = getPropertiesOfObjectType(source); - const targetProperties = getPropertiesOfObjectType(target); + const sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); + const targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { return Ternary.False; } @@ -14902,6 +15080,9 @@ namespace ts { target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } + else if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) { + target = getActualTypeVariable(target); + } if (target.flags & TypeFlags.TypeVariable) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). @@ -14963,9 +15144,6 @@ namespace ts { } } } - else if (target.flags & TypeFlags.Substitution) { - inferFromTypes(source, (target as SubstitutionType).typeVariable); - } if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // If source and target are references to the same generic type, infer from type arguments const sourceTypes = (source).typeArguments || emptyArray; @@ -15991,6 +16169,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. @@ -18475,7 +18657,7 @@ namespace ts { case SyntaxKind.ParenthesizedExpression: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : undefined; - return tag ? getTypeFromTypeNode(tag.typeExpression!.type) : getContextualType(parent, contextFlags); + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } case SyntaxKind.JsxExpression: return getContextualTypeForJsxExpression(parent); @@ -20091,6 +20273,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. @@ -20491,11 +20702,24 @@ namespace ts { // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type: Type): Signature | undefined { + return getSingleSignature(type, SignatureKind.Call, /*allowMembers*/ false); + } + + function getSingleCallOrConstructSignature(type: Type): Signature | undefined { + return getSingleSignature(type, SignatureKind.Call, /*allowMembers*/ false) || + getSingleSignature(type, SignatureKind.Construct, /*allowMembers*/ false); + } + + function getSingleSignature(type: Type, kind: SignatureKind, allowMembers: boolean): Signature | undefined { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { - return resolved.callSignatures[0]; + if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (kind === SignatureKind.Call && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + return resolved.callSignatures[0]; + } + if (kind === SignatureKind.Construct && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + return resolved.constructSignatures[0]; + } } } return undefined; @@ -22905,7 +23129,19 @@ namespace ts { // Grammar checking if (produceDiagnostics) { if (!(node.flags & NodeFlags.AwaitContext)) { - grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); + // use of 'await' in non-async function + const sourceFile = getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + const span = getSpanOfTokenAtPosition(sourceFile, node.pos); + const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.await_expression_is_only_allowed_within_an_async_function); + const func = getContainingFunction(node); + if (func && func.kind !== SyntaxKind.Constructor) { + Debug.assert((getFunctionFlags(func) & FunctionFlags.Async) === 0, "Enclosing function should never be an async function."); + const relatedInfo = createDiagnosticForNode(func, Diagnostics.Did_you_mean_to_mark_this_function_as_async); + addRelatedInfo(diagnostic, relatedInfo); + } + diagnostics.add(diagnostic); + } } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -23837,16 +24073,18 @@ namespace ts { function instantiateTypeWithSingleGenericCallSignature(node: Expression | MethodDeclaration | QualifiedName, type: Type, checkMode?: CheckMode) { if (checkMode && checkMode & (CheckMode.Inferential | CheckMode.SkipGenericFunctions)) { - const signature = getSingleCallSignature(type); + const callSignature = getSingleSignature(type, SignatureKind.Call, /*allowMembers*/ true); + const constructSignature = getSingleSignature(type, SignatureKind.Construct, /*allowMembers*/ true); + const signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - if (checkMode & CheckMode.SkipGenericFunctions) { - skippedGenericFunction(node, checkMode); - return anyFunctionType; - } const contextualType = getApparentTypeOfContextualType(node); - if (contextualType) { - const contextualSignature = getSingleCallSignature(getNonNullableType(contextualType)); + if (contextualType && !isMixinConstructorType(contextualType)) { + const contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? SignatureKind.Call : SignatureKind.Construct, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { + if (checkMode & CheckMode.SkipGenericFunctions) { + skippedGenericFunction(node, checkMode); + return anyFunctionType; + } const context = getInferenceContext(node)!; // We have an expression that is an argument of a generic function for which we are performing // type argument inference. The expression is of a function type with a single generic call @@ -23854,7 +24092,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. @@ -24048,7 +24287,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); } @@ -30498,6 +30737,14 @@ namespace ts { continue; } if (!isExternalOrCommonJsModule(file)) { + // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. + // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. + const fileGlobalThisSymbol = file.locals!.get("globalThis" as __String); + if (fileGlobalThisSymbol) { + for (const declaration of fileGlobalThisSymbol.declarations) { + diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); + } + } mergeSymbolTable(globals, file.locals!); } if (file.jsGlobalAugmentations) { @@ -30543,6 +30790,7 @@ namespace ts { getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments" as __String, /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; + getSymbolLinks(globalThisSymbol).type = createObjectType(ObjectFlags.Anonymous, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array" as __String, /*arity*/ 1, /*reportErrors*/ true); @@ -31391,7 +31639,20 @@ namespace ts { if (forInOrOfStatement.kind === SyntaxKind.ForOfStatement && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & NodeFlags.AwaitContext) === NodeFlags.None) { - return grammarErrorOnNode(forInOrOfStatement.awaitModifier, Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + // use of 'for-await-of' in non-async function + const sourceFile = getSourceFileOfNode(forInOrOfStatement); + if (!hasParseDiagnostics(sourceFile)) { + const diagnostic = createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + const func = getContainingFunction(forInOrOfStatement); + if (func && func.kind !== SyntaxKind.Constructor) { + Debug.assert((getFunctionFlags(func) & FunctionFlags.Async) === 0, "Enclosing function should never be an async function."); + const relatedInfo = createDiagnosticForNode(func, Diagnostics.Did_you_mean_to_mark_this_function_as_async); + addRelatedInfo(diagnostic, relatedInfo); + } + diagnostics.add(diagnostic); + return true; + } + return false; } } @@ -31566,6 +31827,9 @@ namespace ts { return grammarErrorAtPos(node, node.end - 1, ";".length, Diagnostics._0_expected, "{"); } } + else if (isClassLike(node.parent) && isStringLiteral(node.name) && node.name.text === "constructor" && (!compilerOptions.target || compilerOptions.target < ScriptTarget.ES5)) { + return grammarErrorOnNode(node.name, Diagnostics.Quoted_constructors_have_previously_been_interpreted_as_methods_which_is_incorrect_In_TypeScript_3_6_they_will_be_correctly_parsed_as_constructors_In_the_meantime_consider_using_constructor_to_write_a_constructor_or_constructor_to_write_a_method); + } if (checkGrammarForGenerator(node)) { return true; } @@ -31884,6 +32148,9 @@ namespace ts { function checkGrammarProperty(node: PropertyDeclaration | PropertySignature) { if (isClassLike(node.parent)) { + if (isStringLiteral(node.name) && node.name.text === "constructor") { + return grammarErrorOnNode(node.name, Diagnostics.Classes_may_not_have_a_field_named_constructor); + } if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 527217e860e6f..fbc6d8d6fea1d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -45,6 +45,7 @@ namespace ts { ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], ["es2019.array", "lib.es2019.array.d.ts"], + ["es2019.object", "lib.es2019.object.d.ts"], ["es2019.string", "lib.es2019.string.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["es2020.string", "lib.es2020.string.d.ts"], @@ -218,6 +219,7 @@ namespace ts { }), affectsSourceFile: true, affectsModuleResolution: true, + affectsEmit: true, paramType: Diagnostics.VERSION, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, @@ -1345,7 +1347,12 @@ namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined { + export function getParsedCommandLineOfConfigFile( + configFileName: string, + optionsToExtend: CompilerOptions, + host: ParseConfigFileHost, + extendedConfigCache?: Map + ): ParsedCommandLine | undefined { let configFileText: string | undefined; try { configFileText = host.readFile(configFileName); @@ -1366,7 +1373,16 @@ namespace ts { result.path = toPath(configFileName, cwd, createGetCanonicalFileName(host.useCaseSensitiveFileNames)); result.resolvedPath = result.path; result.originalFileName = result.fileName; - return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd)); + return parseJsonSourceFileConfigFileContent( + result, + host, + getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), + optionsToExtend, + getNormalizedAbsolutePath(configFileName, cwd), + /*resolutionStack*/ undefined, + /*extraFileExtension*/ undefined, + extendedConfigCache + ); } /** @@ -1969,8 +1985,8 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { - return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions); + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine { + return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); } /** @@ -1980,8 +1996,8 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { - return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions); + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine { + return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); } /*@internal*/ @@ -2020,11 +2036,12 @@ namespace ts { configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: ReadonlyArray = [], + extendedConfigCache?: Map ): ParsedCommandLine { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; - const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors); + const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache); const { raw } = parsedConfig; const options = extend(existingOptions, parsedConfig.options || {}); options.configFilePath = configFileName && normalizeSlashes(configFileName); @@ -2172,7 +2189,7 @@ namespace ts { return existingErrors !== configParseDiagnostics.length; } - interface ParsedTsconfig { + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -2191,13 +2208,14 @@ namespace ts { * It does *not* resolve the included files. */ function parseConfig( - json: any, - sourceFile: TsConfigSourceFile | undefined, - host: ParseConfigHost, - basePath: string, - configFileName: string | undefined, - resolutionStack: string[], - errors: Push, + json: any, + sourceFile: TsConfigSourceFile | undefined, + host: ParseConfigHost, + basePath: string, + configFileName: string | undefined, + resolutionStack: string[], + errors: Push, + extendedConfigCache?: Map ): ParsedTsconfig { basePath = normalizeSlashes(basePath); const resolvedPath = getNormalizedAbsolutePath(configFileName || "", basePath); @@ -2214,7 +2232,7 @@ namespace ts { if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors); + const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { const baseRaw = extendedConfig.raw; const raw = ownConfig.raw; @@ -2358,6 +2376,11 @@ namespace ts { return undefined; } + export interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } + function getExtendedConfig( sourceFile: TsConfigSourceFile | undefined, extendedConfigPath: string, @@ -2365,40 +2388,53 @@ namespace ts { basePath: string, resolutionStack: string[], errors: Push, + extendedConfigCache?: Map ): ParsedTsconfig | undefined { - const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path)); + const path = host.useCaseSensitiveFileNames ? extendedConfigPath : toLowerCase(extendedConfigPath); + let value: ExtendedConfigCacheEntry | undefined; + let extendedResult: TsConfigSourceFile; + let extendedConfig: ParsedTsconfig | undefined; + if (extendedConfigCache && (value = extendedConfigCache.get(path))) { + ({ extendedResult, extendedConfig } = value); + } + else { + extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path)); + if (!extendedResult.parseDiagnostics.length) { + const extendedDirname = getDirectoryPath(extendedConfigPath); + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, + getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); + + if (isSuccessfulParsedTsconfig(extendedConfig)) { + // Update the paths to reflect base path + const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity); + const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); + const mapPropertiesInRawIfNotUndefined = (propertyName: string) => { + if (raw[propertyName]) { + raw[propertyName] = map(raw[propertyName], updatePath); + } + }; + + const { raw } = extendedConfig; + mapPropertiesInRawIfNotUndefined("include"); + mapPropertiesInRawIfNotUndefined("exclude"); + mapPropertiesInRawIfNotUndefined("files"); + } + } + if (extendedConfigCache) { + extendedConfigCache.set(path, { extendedResult, extendedConfig }); + } + } if (sourceFile) { sourceFile.extendedSourceFiles = [extendedResult.fileName]; + if (extendedResult.extendedSourceFiles) { + sourceFile.extendedSourceFiles.push(...extendedResult.extendedSourceFiles); + } } if (extendedResult.parseDiagnostics.length) { errors.push(...extendedResult.parseDiagnostics); return undefined; } - - const extendedDirname = getDirectoryPath(extendedConfigPath); - const extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, - getBaseFileName(extendedConfigPath), resolutionStack, errors); - if (sourceFile && extendedResult.extendedSourceFiles) { - sourceFile.extendedSourceFiles!.push(...extendedResult.extendedSourceFiles); - } - - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity); - const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); - const mapPropertiesInRawIfNotUndefined = (propertyName: string) => { - if (raw[propertyName]) { - raw[propertyName] = map(raw[propertyName], updatePath); - } - }; - - const { raw } = extendedConfig; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } - - return extendedConfig; + return extendedConfig!; } function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Push): boolean { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b3839842d3e60..8d2f01f3de27a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2284,4 +2284,29 @@ namespace ts { } return result; } + + export function cartesianProduct(arrays: readonly T[][]) { + const result: T[][] = []; + cartesianProductWorker(arrays, result, /*outer*/ undefined, 0); + return result; + } + + function cartesianProductWorker(arrays: readonly (readonly T[])[], result: (readonly T[])[], outer: readonly T[] | undefined, index: number) { + for (const element of arrays[index]) { + let inner: T[]; + if (outer) { + inner = outer.slice(); + inner.push(element); + } + else { + inner = [element]; + } + if (index === arrays.length - 1) { + result.push(inner); + } + else { + cartesianProductWorker(arrays, result, inner, index + 1); + } + } + } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 45ec2a9ad427a..af3ecad79a669 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1035,6 +1035,10 @@ "category": "Error", "code": 1355 }, + "Did you mean to mark this function as 'async'?": { + "category": "Error", + "code": 1356 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -2959,7 +2963,7 @@ "category": "Error", "code": 4104 }, - + "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 @@ -3096,6 +3100,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 +4280,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 @@ -4954,5 +4965,13 @@ "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer." :{ "category": "Error", "code": 18004 + }, + "Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '[\"constructor\"]()' to write a method.": { + "category": "Error", + "code": 18005 + }, + "Classes may not have a field named 'constructor'.": { + "category": "Error", + "code": 18006 } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3742f2d5fdf11..f562a6b5d12be 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2189,7 +2189,7 @@ namespace ts { } /* @internal */ - export function createJSDocTypeTag(typeExpression?: JSDocTypeExpression, comment?: string): JSDocTypeTag { + export function createJSDocTypeTag(typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag { const tag = createJSDocTag(SyntaxKind.JSDocTypeTag, "type"); tag.typeExpression = typeExpression; tag.comment = comment; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 481a601118edb..a86dba52c87af 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6855,7 +6855,7 @@ namespace ts { } function parseReturnTag(start: number, tagName: Identifier): JSDocReturnTag { - if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) { + if (some(tags, isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText); } @@ -6866,7 +6866,7 @@ namespace ts { } function parseTypeTag(start: number, tagName: Identifier): JSDocTypeTag { - if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) { + if (some(tags, isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText); } @@ -7782,24 +7782,9 @@ namespace ts { /*@internal*/ export function processCommentPragmas(context: PragmaContext, sourceText: string): void { - const triviaScanner = createScanner(context.languageVersion, /*skipTrivia*/ false, LanguageVariant.Standard, sourceText); const pragmas: PragmaPseudoMapEntry[] = []; - // Keep scanning all the leading trivia in the file until we get to something that - // isn't trivia. Any single line comment will be analyzed to see if it is a - // reference comment. - while (true) { - const kind = triviaScanner.scan(); - if (!isTrivia(kind)) { - break; - } - - const range = { - kind: triviaScanner.getToken(), - pos: triviaScanner.getTokenPos(), - end: triviaScanner.getTextPos(), - }; - + for (const range of getLeadingCommentRanges(sourceText, 0) || emptyArray) { const comment = sourceText.substring(range.pos, range.end); extractPragmas(pragmas, range, comment); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 358cabcecb1c5..6f7ffc2c3a972 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2678,18 +2678,32 @@ namespace ts { return fromCache || undefined; } - // An absolute path pointing to the containing directory of the config file - const basePath = getNormalizedAbsolutePath(getDirectoryPath(refPath), host.getCurrentDirectory()); - const sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile | undefined; - addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); - if (sourceFile === undefined) { - projectReferenceRedirects.set(sourceFilePath, false); - return undefined; + let commandLine: ParsedCommandLine | undefined; + let sourceFile: JsonSourceFile | undefined; + if (host.getParsedCommandLine) { + commandLine = host.getParsedCommandLine(refPath); + if (!commandLine) { + addFileToFilesByName(/*sourceFile*/ undefined, sourceFilePath, /*redirectedPath*/ undefined); + projectReferenceRedirects.set(sourceFilePath, false); + return undefined; + } + sourceFile = Debug.assertDefined(commandLine.options.configFile); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); + } + else { + // An absolute path pointing to the containing directory of the config file + const basePath = getNormalizedAbsolutePath(getDirectoryPath(refPath), host.getCurrentDirectory()); + sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile | undefined; + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); + if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); + return undefined; + } + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; + commandLine = parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); } - sourceFile.path = sourceFilePath; - sourceFile.resolvedPath = sourceFilePath; - sourceFile.originalFileName = refPath; - const commandLine = parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); const resolvedRef: ResolvedProjectReference = { commandLine, sourceFile }; projectReferenceRedirects.set(sourceFilePath, resolvedRef); if (commandLine.projectReferences) { @@ -2754,10 +2768,8 @@ namespace ts { if (options.composite) { const rootPaths = rootNames.map(toPath); for (const file of files) { - // Ignore declaration files - if (file.isDeclarationFile) continue; - // Ignore json file thats from project reference - if (isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) continue; + // Ignore file that is not emitted + if (!sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; if (rootPaths.indexOf(file.path) === -1) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 8bc66e95edc45..a5eae8922da30 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -399,12 +399,24 @@ namespace ts { let projectCompilerOptions = baseCompilerOptions; const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions); setGetSourceFileAsHashVersioned(compilerHost, host); + compilerHost.getParsedCommandLine = parseConfigFile; compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); - let moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; + const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; + let cacheState: { + originalReadFile: CompilerHost["readFile"]; + originalFileExists: CompilerHost["fileExists"]; + originalDirectoryExists: CompilerHost["directoryExists"]; + originalCreateDirectory: CompilerHost["createDirectory"]; + originalWriteFile: CompilerHost["writeFile"] | undefined; + originalReadFileWithCache: CompilerHost["readFile"]; + originalGetSourceFile: CompilerHost["getSourceFile"]; + originalResolveModuleNames: CompilerHost["resolveModuleNames"]; + } | undefined; const buildInfoChecked = createFileMap(toPath); + const extendedConfigCache = createMap(); // Watch state const builderPrograms = createFileMap(toPath); @@ -481,7 +493,7 @@ namespace ts { let diagnostic: Diagnostic | undefined; parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = d => diagnostic = d; - const parsed = getParsedCommandLineOfConfigFile(configFilePath, baseCompilerOptions, parseConfigFileHost); + const parsed = getParsedCommandLineOfConfigFile(configFilePath, baseCompilerOptions, parseConfigFileHost, extendedConfigCache); parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = noop; configFileCache.setValue(configFilePath, parsed || diagnostic!); return parsed; @@ -867,6 +879,7 @@ namespace ts { diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); + enableCache(); } /** @@ -927,6 +940,7 @@ namespace ts { } } else { + disableCache(); reportErrorSummary(); } } @@ -1382,17 +1396,18 @@ namespace ts { return configFileNames.map(resolveProjectName); } - function buildAllProjects(): ExitStatus { - if (options.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!; @@ -1403,6 +1418,41 @@ namespace ts { loadWithLocalCache(Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader); } + cacheState = { + originalReadFile, + originalFileExists, + originalDirectoryExists, + originalCreateDirectory, + originalWriteFile, + originalReadFileWithCache, + originalGetSourceFile, + originalResolveModuleNames + }; + } + + 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; + compilerHost.resolveModuleNames = cacheState.originalResolveModuleNames; + 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 graph = getGlobalDependencyGraph(); reportBuildQueue(graph); let anyFailed = false; @@ -1456,15 +1506,7 @@ namespace ts { anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } 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 anyFailed ? ExitStatus.DiagnosticsPresent_OutputsSkipped : ExitStatus.Success; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ba9d1a2016c1a..af4194a9c6949 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2482,7 +2482,7 @@ namespace ts { export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression?: JSDocTypeExpression; + typeExpression: JSDocTypeExpression; } export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { @@ -5135,6 +5135,7 @@ namespace ts { /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution; /* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; // TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesnt use compilerHost as base /*@internal*/createDirectory?(directory: string): void; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 188f2f8630209..45dc980296be7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3960,6 +3960,16 @@ namespace ts { return isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } + export function tryGetPropertyAccessOrIdentifierToString(expr: Expression): string | undefined { + if (isPropertyAccessExpression(expr)) { + return tryGetPropertyAccessOrIdentifierToString(expr.expression) + "." + expr.name; + } + if (isIdentifier(expr)) { + return unescapeLeadingUnderscores(expr.escapedText); + } + return undefined; + } + export function isPrototypeAccess(node: Node): node is PropertyAccessExpression { return isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; } diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index ccada2e0069c9..4d48d5cf40aaf 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -9,7 +9,7 @@ interface Array { * predicate. If it is not provided, undefined is used instead. */ find(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -20,7 +20,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -330,7 +330,7 @@ interface ReadonlyArray { * predicate. If it is not provided, undefined is used instead. */ find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -341,7 +341,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): number; } interface RegExp { diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index 2a98f215193a0..83776137c33c1 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -98,79 +98,15 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + race(values: T[]): Promise ? U : T>; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. + * @param values An iterable of Promises. * @returns A new Promise. */ - race(values: (T | PromiseLike)[]): Promise; + race(values: Iterable): Promise ? U : T>; /** * Creates a new rejected promise for the provided reason. diff --git a/src/lib/es2019.d.ts b/src/lib/es2019.d.ts index b25f9e1d76af9..29212ecfe0f1b 100644 --- a/src/lib/es2019.d.ts +++ b/src/lib/es2019.d.ts @@ -1,4 +1,5 @@ /// /// +/// /// /// diff --git a/src/lib/es2019.object.d.ts b/src/lib/es2019.object.d.ts new file mode 100644 index 0000000000000..69b185d7ca91c --- /dev/null +++ b/src/lib/es2019.object.d.ts @@ -0,0 +1,15 @@ +/// + +interface ObjectConstructor { + /** + * Returns an object created by key-value entries for properties and methods + * @param entries An iterable object that contains key-value entries for properties and methods. + */ + fromEntries(entries: Iterable): { [k in PropertyKey]: T }; + + /** + * Returns an object created by key-value entries for properties and methods + * @param entries An iterable object that contains key-value entries for properties and methods. + */ + fromEntries(entries: Iterable): any; +} diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index d39613e515194..827c2aaddd50c 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -513,7 +513,7 @@ interface Boolean { interface BooleanConstructor { new(value?: any): Boolean; - (value?: any): boolean; + (value?: T): value is Exclude; readonly prototype: Boolean; } @@ -1273,13 +1273,13 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. @@ -1303,7 +1303,7 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; + filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. diff --git a/src/lib/libs.json b/src/lib/libs.json index 74611a938609c..ac2f2db5b6bb0 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -36,6 +36,7 @@ "es2018.promise", "es2018.intl", "es2019.array", + "es2019.object", "es2019.string", "es2019.symbol", "es2020.string", diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 8016b0e9ff655..f14a3a1e5d528 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -134,7 +134,7 @@ namespace ts.JsDoc { case SyntaxKind.JSDocTemplateTag: return withList((tag as JSDocTemplateTag).typeParameters); case SyntaxKind.JSDocTypeTag: - return withNode((tag as JSDocTypeTag).typeExpression!); + return withNode((tag as JSDocTypeTag).typeExpression); case SyntaxKind.JSDocTypedefTag: case SyntaxKind.JSDocCallbackTag: case SyntaxKind.JSDocPropertyTag: diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 1c710b8cd7838..0bdfde9fad070 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -171,8 +171,7 @@ namespace ts.SymbolDisplay { } if (callExpressionLike) { - const candidateSignatures: Signature[] = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures)!; // TODO: GH#18217 + signature = typeChecker.getResolvedSignature(callExpressionLike)!; // TODO: GH#18217 const useConstructSignatures = callExpressionLike.kind === SyntaxKind.NewExpression || (isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === SyntaxKind.SuperKeyword); diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 450b27e01ed4f..3c033d658ef6c 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, diff --git a/src/testRunner/unittests/tsbuild/helpers.ts b/src/testRunner/unittests/tsbuild/helpers.ts index 88eb61cd422c4..579573a876e6e 100644 --- a/src/testRunner/unittests/tsbuild/helpers.ts +++ b/src/testRunner/unittests/tsbuild/helpers.ts @@ -62,7 +62,7 @@ namespace ts { } } - const libContent = `${TestFSWithWatch.libFile.content} + export const libContent = `${TestFSWithWatch.libFile.content} interface ReadonlyArray {} declare const console: { log(msg: any): void; };`; diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index 6e31ada9ee575..5ad63d76dc7ee 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -279,7 +279,6 @@ namespace ts { [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.json"], [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] ); }); @@ -309,8 +308,7 @@ namespace ts { [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"], [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.base.json"], - [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"] ); }); }); @@ -761,6 +759,56 @@ class someClass { }`), baselineOnly: true, verifyDiagnostics: true }); + + verifyTsbuildOutput({ + scenario: "when target option changes", + projFs: () => projFs, + time, + tick, + proj: "sample1", + rootNames: ["/src/core"], + expectedMapFileNames: emptyArray, + lastProjectOutputJs: "/src/core/index.js", + initialBuild: { + modifyFs: fs => { + fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// +/// `); + fs.writeFileSync("/lib/lib.esnext.d.ts", libContent); + fs.writeFileSync("/lib/lib.d.ts", `/// +/// `); + fs.writeFileSync("/src/core/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, +"listFiles": true, +"listEmittedFiles": true, + "target": "esnext", + } +}`); + }, + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], + ] + }, + incrementalDtsChangedBuild: { + modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"), + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/tsconfig.json"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"] + ] + }, + outputFiles: [ + "/src/core/anotherModule.js", + "/src/core/anotherModule.d.ts", + "/src/core/index.js", + "/src/core/index.d.ts", + "/src/core/tsconfig.tsbuildinfo", + ], + baselineOnly: true, + verifyDiagnostics: true + }); }); }); } diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index f9f0e726dde3f..77fab3209e193 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -24,11 +24,11 @@ class Board { return this.ships.every(function (val) { return val.isSunk; }); >this.ships.every(function (val) { return val.isSunk; }) : boolean ->this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any) => boolean >this.ships : Ship[] >this : this >ships : Ship[] ->every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any) => boolean >function (val) { return val.isSunk; } : (val: Ship) => boolean >val : Ship >val.isSunk : boolean diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.errors.txt new file mode 100644 index 0000000000000..7cc9f3617c034 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/ambient/testB.ts(1,22): error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. + + +==== tests/cases/conformance/ambient/types.ts (0 errors) ==== + declare module "*.foo" { + let everywhere: string; + } + + +==== tests/cases/conformance/ambient/testA.ts (0 errors) ==== + import { everywhere, onlyInA } from "a.foo"; + declare module "a.foo" { + let onlyInA: number; + } + +==== tests/cases/conformance/ambient/testB.ts (1 errors) ==== + import { everywhere, onlyInA } from "b.foo"; // Error + ~~~~~~~ +!!! error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. + \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js new file mode 100644 index 0000000000000..56abd8298cdf2 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging1.ts] //// + +//// [types.ts] +declare module "*.foo" { + let everywhere: string; +} + + +//// [testA.ts] +import { everywhere, onlyInA } from "a.foo"; +declare module "a.foo" { + let onlyInA: number; +} + +//// [testB.ts] +import { everywhere, onlyInA } from "b.foo"; // Error + + +//// [types.js] +//// [testA.js] +"use strict"; +exports.__esModule = true; +//// [testB.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.symbols new file mode 100644 index 0000000000000..aba5c7e23f142 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0)) + + let everywhere: string; +>everywhere : Symbol(everywhere, Decl(types.ts, 1, 5)) +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA } from "a.foo"; +>everywhere : Symbol(everywhere, Decl(testA.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 0, 20)) + +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(testA.ts, 0, 44), Decl(types.ts, 0, 0)) + + let onlyInA: number; +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 2, 5)) +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA } from "b.foo"; // Error +>everywhere : Symbol(everywhere, Decl(testB.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testB.ts, 0, 20)) + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.types b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.types new file mode 100644 index 0000000000000..4e3f190f16261 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : typeof import("*.foo") + + let everywhere: string; +>everywhere : string +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA } from "a.foo"; +>everywhere : string +>onlyInA : number + +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + let onlyInA: number; +>onlyInA : number +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA } from "b.foo"; // Error +>everywhere : string +>onlyInA : any + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.errors.txt new file mode 100644 index 0000000000000..67c44a528b534 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/ambient/testB.ts(1,22): error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. +tests/cases/conformance/ambient/testB.ts(1,31): error TS2305: Module '"*.foo"' has no exported member 'alsoOnlyInA'. + + +==== tests/cases/conformance/ambient/types.ts (0 errors) ==== + declare module "*.foo" { + let everywhere: string; + } + + +==== tests/cases/conformance/ambient/testA.ts (0 errors) ==== + import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; + declare module "a.foo" { + let onlyInA: number; + } + +==== tests/cases/conformance/ambient/testB.ts (2 errors) ==== + import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error + ~~~~~~~ +!!! error TS2305: Module '"*.foo"' has no exported member 'onlyInA'. + ~~~~~~~~~~~ +!!! error TS2305: Module '"*.foo"' has no exported member 'alsoOnlyInA'. + declare module "a.foo" { + let alsoOnlyInA: number; + } \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js new file mode 100644 index 0000000000000..65726bba7225e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js @@ -0,0 +1,27 @@ +//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging2.ts] //// + +//// [types.ts] +declare module "*.foo" { + let everywhere: string; +} + + +//// [testA.ts] +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +declare module "a.foo" { + let onlyInA: number; +} + +//// [testB.ts] +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +declare module "a.foo" { + let alsoOnlyInA: number; +} + +//// [types.js] +//// [testA.js] +"use strict"; +exports.__esModule = true; +//// [testB.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.symbols new file mode 100644 index 0000000000000..447cd999c981e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0)) + + let everywhere: string; +>everywhere : Symbol(everywhere, Decl(types.ts, 1, 5)) +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +>everywhere : Symbol(everywhere, Decl(testA.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 0, 20)) +>alsoOnlyInA : Symbol(alsoOnlyInA, Decl(testA.ts, 0, 29)) + +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(testA.ts, 0, 57), Decl(types.ts, 0, 0), Decl(testB.ts, 0, 57)) + + let onlyInA: number; +>onlyInA : Symbol(onlyInA, Decl(testA.ts, 2, 5)) +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +>everywhere : Symbol(everywhere, Decl(testB.ts, 0, 8)) +>onlyInA : Symbol(onlyInA, Decl(testB.ts, 0, 20)) +>alsoOnlyInA : Symbol(alsoOnlyInA, Decl(testB.ts, 0, 29)) + +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(testA.ts, 0, 57), Decl(types.ts, 0, 0), Decl(testB.ts, 0, 57)) + + let alsoOnlyInA: number; +>alsoOnlyInA : Symbol(alsoOnlyInA, Decl(testB.ts, 2, 5)) +} diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.types b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.types new file mode 100644 index 0000000000000..b4f0d50db1989 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : typeof import("*.foo") + + let everywhere: string; +>everywhere : string +} + + +=== tests/cases/conformance/ambient/testA.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; +>everywhere : string +>onlyInA : number +>alsoOnlyInA : number + +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + let onlyInA: number; +>onlyInA : number +} + +=== tests/cases/conformance/ambient/testB.ts === +import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error +>everywhere : string +>onlyInA : any +>alsoOnlyInA : any + +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + let alsoOnlyInA: number; +>alsoOnlyInA : number +} diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.errors.txt new file mode 100644 index 0000000000000..ce32367fd3cf3 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/ambient/test.ts(6,6): error TS2339: Property 'a' does not exist on type 'OhNo'. + + +==== tests/cases/conformance/ambient/types.ts (0 errors) ==== + declare module "*.foo" { + export interface OhNo { star: string } + } + +==== tests/cases/conformance/ambient/test.ts (1 errors) ==== + declare module "a.foo" { + export interface OhNo { a: string } + } + import { OhNo } from "b.foo" + declare let ohno: OhNo; + ohno.a // oh no + ~ +!!! error TS2339: Property 'a' does not exist on type 'OhNo'. + \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.js new file mode 100644 index 0000000000000..763f0e94bdb56 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging3.ts] //// + +//// [types.ts] +declare module "*.foo" { + export interface OhNo { star: string } +} + +//// [test.ts] +declare module "a.foo" { + export interface OhNo { a: string } +} +import { OhNo } from "b.foo" +declare let ohno: OhNo; +ohno.a // oh no + + +//// [types.js] +//// [test.js] +"use strict"; +exports.__esModule = true; +ohno.a; // oh no diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.symbols new file mode 100644 index 0000000000000..141a17b698909 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0)) + + export interface OhNo { star: string } +>OhNo : Symbol(OhNo, Decl(types.ts, 0, 24)) +>star : Symbol(OhNo.star, Decl(types.ts, 1, 25)) +} + +=== tests/cases/conformance/ambient/test.ts === +declare module "a.foo" { +>"a.foo" : Symbol("a.foo", Decl(test.ts, 0, 0), Decl(types.ts, 0, 0)) + + export interface OhNo { a: string } +>OhNo : Symbol(OhNo, Decl(test.ts, 0, 24), Decl(types.ts, 0, 24)) +>a : Symbol(OhNo.a, Decl(test.ts, 1, 25)) +} +import { OhNo } from "b.foo" +>OhNo : Symbol(OhNo, Decl(test.ts, 3, 8)) + +declare let ohno: OhNo; +>ohno : Symbol(ohno, Decl(test.ts, 4, 11)) +>OhNo : Symbol(OhNo, Decl(test.ts, 3, 8)) + +ohno.a // oh no +>ohno : Symbol(ohno, Decl(test.ts, 4, 11)) + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging3.types b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.types new file mode 100644 index 0000000000000..df731d94fc96a --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging3.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/ambient/types.ts === +declare module "*.foo" { +>"*.foo" : typeof import("*.foo") + + export interface OhNo { star: string } +>star : string +} + +=== tests/cases/conformance/ambient/test.ts === +declare module "a.foo" { +>"a.foo" : typeof import("a.foo") + + export interface OhNo { a: string } +>a : string +} +import { OhNo } from "b.foo" +>OhNo : any + +declare let ohno: OhNo; +>ohno : OhNo + +ohno.a // oh no +>ohno.a : any +>ohno : OhNo +>a : any + diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 66b2839b89baf..a0bbf92fcaf0f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1603,7 +1603,7 @@ declare namespace ts { } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression?: JSDocTypeExpression; + typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -2761,6 +2761,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } interface SourceMapRange extends TextRange { source?: SourceMapSource; @@ -3632,7 +3633,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -3666,7 +3667,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3674,7 +3675,20 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + interface ParsedTsconfig { + raw: any; + options?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; + } + interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index bf3ad5a7e35ec..add726bd09285 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1603,7 +1603,7 @@ declare namespace ts { } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression?: JSDocTypeExpression; + typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -2761,6 +2761,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } interface SourceMapRange extends TextRange { source?: SourceMapSource; @@ -3632,7 +3633,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -3666,7 +3667,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3674,7 +3675,20 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + interface ParsedTsconfig { + raw: any; + options?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; + } + interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index 7d91ef4ed322b..97c94995e5d5f 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -22,9 +22,9 @@ var foo = [ foo.filter(x => x.name); //should accepted all possible types not only boolean! >foo.filter(x => x.name) : { name: string; }[] ->foo.filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any): { name: string; }[]; } +>foo.filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => unknown, thisArg?: any): { name: string; }[]; } >foo : { name: string; }[] ->filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any): { name: string; }[]; } +>filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => unknown, thisArg?: any): { name: string; }[]; } >x => x.name : (x: { name: string; }) => string >x : { name: string; } >x.name : string diff --git a/tests/baselines/reference/arrayFind.types b/tests/baselines/reference/arrayFind.types index 530f07be3f829..12eead1630cb8 100644 --- a/tests/baselines/reference/arrayFind.types +++ b/tests/baselines/reference/arrayFind.types @@ -24,9 +24,9 @@ const arrayOfStringsNumbersAndBooleans = ["string", false, 0, "strung", 1, true] const foundNumber: number | undefined = arrayOfStringsNumbersAndBooleans.find(isNumber); >foundNumber : number >arrayOfStringsNumbersAndBooleans.find(isNumber) : number ->arrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>arrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >arrayOfStringsNumbersAndBooleans : (string | number | boolean)[] ->find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >isNumber : (x: any) => x is number const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBooleans as ReadonlyArray; @@ -37,8 +37,8 @@ const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBoolean const readonlyFoundNumber: number | undefined = readonlyArrayOfStringsNumbersAndBooleans.find(isNumber); >readonlyFoundNumber : number >readonlyArrayOfStringsNumbersAndBooleans.find(isNumber) : number ->readonlyArrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>readonlyArrayOfStringsNumbersAndBooleans.find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >readonlyArrayOfStringsNumbersAndBooleans : readonly (string | number | boolean)[] ->find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; } +>find : { (predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => unknown, thisArg?: any): string | number | boolean; } >isNumber : (x: any) => x is number diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt index aeab178743988..a0c856cae96f7 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt @@ -14,24 +14,30 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(62,1): error TS2322: Type '(x: (arg: Base) => Derived) => Base' is not assignable to type '(x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(65,1): error TS2322: Type '(x: (arg: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(68,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(71,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(74,1): error TS2322: Type '(...x: Derived[]) => Derived' is not assignable to type '(...x: T[]) => T'. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(77,1): error TS2322: Type '(x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type '(x: T, y: T) => T'. Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type '{ foo: string; bar: string; }'. @@ -43,6 +49,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'Base' is missing the following properties from type 'Derived2': baz, bar tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. + 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(85,1): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. @@ -136,6 +143,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b6: (x: (arg: T) => U) => T; a6 = b6; // ok b6 = a6; // ok @@ -144,6 +152,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b7: (x: (arg: T) => U) => (r: T) => U; a7 = b7; // ok b7 = a7; // ok @@ -152,6 +161,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; a8 = b8; // ok b8 = a8; // ok @@ -160,6 +170,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b9: (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; a9 = b9; // ok b9 = a9; // ok @@ -168,12 +179,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: (...x: T[]) => T; a10 = b10; // ok b10 = a10; // ok ~~~ !!! error TS2322: Type '(...x: Derived[]) => Derived' is not assignable to type '(...x: T[]) => T'. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. var b11: (x: T, y: T) => T; a11 = b11; // ok b11 = a11; // ok @@ -198,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. +!!! error TS2322: 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. var b14: (x: { a: T; b: T }) => T; a14 = b14; // ok ~~~ diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 0a2ae4789895f..ecc1dbd848f99 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. Types of parameters 'arg2' and 'arg2' are incompatible. @@ -15,6 +16,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(58,9): error TS2322: Type '(...x: Base[]) => Base' is not assignable to type '(...x: T[]) => T'. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(62,9): error TS2322: Type '(x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type '(x: T, y: T) => T'. @@ -45,6 +47,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(89,9): error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(90,9): error TS2322: Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. Type 'T[]' is not assignable to type 'string[]'. Type 'T' is not assignable to type 'string'. @@ -54,6 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(96,9): error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (15 errors) ==== @@ -115,6 +119,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; a8 = b8; // error, { foo: number } and Base are incompatible @@ -131,6 +136,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: (...x: T[]) => T; @@ -205,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b2 = a2; ~~ !!! error TS2322: Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. @@ -224,5 +231,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt index 57944ae986389..d3bb6e0b2e262 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt @@ -5,11 +5,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(55,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. Types of property 'b' are incompatible. Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(58,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -79,6 +81,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b15: (x: { a: U; b: V; }) => U[]; a15 = b15; // ok, T = U, T = V b15 = a15; // ok @@ -88,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. !!! error TS2322: Types of property 'b' are incompatible. !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var b16: (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt index e3d7fda7ba35f..c26a01c3a5127 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(42,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -61,6 +62,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b16: (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt index 1db469b6a4fa7..52b7a9280a537 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt @@ -14,24 +14,30 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(62,1): error TS2322: Type 'new (x: (arg: Base) => Derived) => Base' is not assignable to type 'new (x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(65,1): error TS2322: Type 'new (x: (arg: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(68,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(71,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(74,1): error TS2322: Type 'new (...x: Derived[]) => Derived' is not assignable to type 'new (...x: T[]) => T'. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(77,1): error TS2322: Type 'new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type 'new (x: T, y: T) => T'. Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type '{ foo: string; bar: string; }'. @@ -43,6 +49,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'Base' is missing the following properties from type 'Derived2': baz, bar tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. + 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(85,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. @@ -136,6 +143,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b6: new (x: (arg: T) => U) => T; a6 = b6; // ok b6 = a6; // ok @@ -144,6 +152,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b7: new (x: (arg: T) => U) => (r: T) => U; a7 = b7; // ok b7 = a7; // ok @@ -152,6 +161,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: new (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; a8 = b8; // ok b8 = a8; // ok @@ -160,6 +170,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b9: new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; a9 = b9; // ok b9 = a9; // ok @@ -168,12 +179,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: new (...x: T[]) => T; a10 = b10; // ok b10 = a10; // ok ~~~ !!! error TS2322: Type 'new (...x: Derived[]) => Derived' is not assignable to type 'new (...x: T[]) => T'. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. var b11: new (x: T, y: T) => T; a11 = b11; // ok b11 = a11; // ok @@ -198,6 +211,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. +!!! error TS2322: 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. var b14: new (x: { a: T; b: T }) => T; a14 = b14; // ok ~~~ diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 620e83e1603b8..fb9ba55b5efcb 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(52,9): error TS2322: Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. Types of parameters 'arg2' and 'arg2' are incompatible. @@ -15,6 +16,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(58,9): error TS2322: Type 'new (...x: Base[]) => Base' is not assignable to type 'new (...x: T[]) => T'. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(62,9): error TS2322: Type 'new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type 'new (x: T, y: T) => T'. @@ -61,6 +63,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(89,9): error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(90,9): error TS2322: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. Type 'T[]' is not assignable to type 'string[]'. Type 'T' is not assignable to type 'string'. @@ -70,6 +73,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(96,9): error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts (19 errors) ==== @@ -131,6 +135,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b8: new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; a8 = b8; // error, type mismatch @@ -147,6 +152,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'T'. +!!! error TS2322: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. var b10: new (...x: T[]) => T; @@ -241,6 +247,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b2 = a2; // ok ~~ !!! error TS2322: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. @@ -260,5 +267,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2322: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2322: Type 'string' is not assignable to type 'T'. +!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt index 5445d9ee35a14..bfd92f7e93004 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt @@ -5,11 +5,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(55,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. Types of property 'b' are incompatible. Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(58,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -79,6 +81,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b15: new (x: { a: U; b: V; }) => U[]; a15 = b15; // ok b15 = a15; // ok @@ -88,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. !!! error TS2322: Types of property 'b' are incompatible. !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var b16: new (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt index 399a56e413659..1397dfe528b1f 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(42,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -61,6 +62,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var b16: new (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt new file mode 100644 index 0000000000000..e5e3ee8b49992 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt @@ -0,0 +1,224 @@ +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts(44,5): error TS2322: Type 'S' is not assignable to type 'T'. + Type 'S' is not assignable to type '{ a: 2; b: 3; }'. + Types of property 'a' are incompatible. + Type '0 | 2' is not assignable to type '2'. + Type '0' is not assignable to type '2'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts(58,5): error TS2322: Type 'S' is not assignable to type 'T'. + Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 4 | 3; c: string; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts(82,5): error TS2322: Type 'S' is not assignable to type 'T'. + Type 'S' is not assignable to type '{ a: 0 | 2 | 1; b: 0 | 2 | 1; c: 2; }'. + Types of property 'c' are incompatible. + Type '0 | 2 | 1' is not assignable to type '2'. + Type '0' is not assignable to type '2'. + + +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts (3 errors) ==== + // see 'typeRelatedToDiscriminatedType' in checker.ts: + + // IteratorResult + namespace Example1 { + type S = { done: boolean, value: number }; + type T = + | { done: true, value: number } // T0 + | { done: false, value: number }; // T1 + + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; + } + + // Dropping constituents of T + namespace Example2 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; + } + + // Unmatched discriminants + namespace Example3 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 | 4 } // T1 + | { a: 2, b: 3 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: Type 'S' is not assignable to type '{ a: 2; b: 3; }'. +!!! error TS2322: Types of property 'a' are incompatible. +!!! error TS2322: Type '0 | 2' is not assignable to type '2'. +!!! error TS2322: Type '0' is not assignable to type '2'. + } + + // Unmatched non-discriminants + namespace Example4 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4, c: string }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 4 | 3; c: string; }'. +!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts:52:36: 'c' is declared here. + } + + // Maximum discriminant combinations + namespace Example5 { + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; + type S = { a: N, b: N, c: N }; + type T = { a: 0, b: N, c: N } + | { a: 1, b: N, c: N } + | { a: 2, b: N, c: N } + | { a: N, b: 0, c: N } + | { a: N, b: 1, c: N } + | { a: N, b: 2, c: N } + | { a: N, b: N, c: 0 } + | { a: N, b: N, c: 1 } + | { a: N, b: N, c: 2 }; + declare let s: S; + declare let t: T; + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; + ~ +!!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: Type 'S' is not assignable to type '{ a: 0 | 2 | 1; b: 0 | 2 | 1; c: 2; }'. +!!! error TS2322: Types of property 'c' are incompatible. +!!! error TS2322: Type '0 | 2 | 1' is not assignable to type '2'. +!!! error TS2322: Type '0' is not assignable to type '2'. + } + + // https://github.com/Microsoft/TypeScript/issues/14865 + namespace GH14865 { + type Style1 = { + type: "A"; + data: string; + } | { + type: "B"; + data: string; + }; + + type Style2 = { + type: "A" | "B"; + data: string; + } + + const a: Style2 = { type: "A", data: "whatevs" }; + let b: Style1; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable + } + + // https://github.com/Microsoft/TypeScript/issues/30170 + namespace GH30170 { + interface Blue { + color: 'blue' + } + interface Yellow { + color?: 'yellow', + } + function draw(val: Blue | Yellow) { } + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { + return draw({ color: currentColor }); + } + } + + // https://github.com/Microsoft/TypeScript/issues/12052 + namespace GH12052 { + interface ILinearAxis { type: "linear"; } + + interface ICategoricalAxis { type: "categorical"; } + + type IAxis = ILinearAxis | ICategoricalAxis; + type IAxisType = "linear" | "categorical"; + + function getAxisType(): IAxisType { + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; + const good: IAxis = { type: undefined }; + good.type = getAxisType(); + } + + // https://github.com/Microsoft/TypeScript/issues/18421 + namespace GH18421 { + interface ThingTypeOne { + type: 'one'; + } + + interface ThingTypeTwo { + type: 'two'; + } + + type ThingType = 'one' | 'two'; + + type Thing = ThingTypeOne | ThingTypeTwo; + + function makeNewThing(thingType: ThingType): Thing { + return { + type: thingType + }; + } + } + + // https://github.com/Microsoft/TypeScript/issues/15907 + namespace GH15907 { + type Action = { type: 'activate' } | { type: 'disactivate' }; + + function dispatchAction(action: Action): void { + + } + + const active = true; + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); + } + + // https://github.com/Microsoft/TypeScript/issues/20889 + namespace GH20889 { + interface A1 { + type: "A1"; + } + interface A2 { + type: "A2"; + } + type AU = A1 | A2; + + function foo(obj1: AU) { + const obj2: AU = { + type: obj1.type + }; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js new file mode 100644 index 0000000000000..2719a525ba7a5 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js @@ -0,0 +1,291 @@ +//// [assignmentCompatWithDiscriminatedUnion.ts] +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { + type S = { done: boolean, value: number }; + type T = + | { done: true, value: number } // T0 + | { done: false, value: number }; // T1 + + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +} + +// Dropping constituents of T +namespace Example2 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +} + +// Unmatched discriminants +namespace Example3 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 | 4 } // T1 + | { a: 2, b: 3 }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +} + +// Unmatched non-discriminants +namespace Example4 { + type S = { a: 0 | 2, b: 4 }; + type T = { a: 0, b: 1 | 4 } // T0 + | { a: 1, b: 2 } // T1 + | { a: 2, b: 3 | 4, c: string }; // T2 + declare let s: S; + declare let t: T; + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +} + +// Maximum discriminant combinations +namespace Example5 { + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; + type S = { a: N, b: N, c: N }; + type T = { a: 0, b: N, c: N } + | { a: 1, b: N, c: N } + | { a: 2, b: N, c: N } + | { a: N, b: 0, c: N } + | { a: N, b: 1, c: N } + | { a: N, b: 2, c: N } + | { a: N, b: N, c: 0 } + | { a: N, b: N, c: 1 } + | { a: N, b: N, c: 2 }; + declare let s: S; + declare let t: T; + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { + type Style1 = { + type: "A"; + data: string; + } | { + type: "B"; + data: string; + }; + + type Style2 = { + type: "A" | "B"; + data: string; + } + + const a: Style2 = { type: "A", data: "whatevs" }; + let b: Style1; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { + interface Blue { + color: 'blue' + } + interface Yellow { + color?: 'yellow', + } + function draw(val: Blue | Yellow) { } + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { + return draw({ color: currentColor }); + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { + interface ILinearAxis { type: "linear"; } + + interface ICategoricalAxis { type: "categorical"; } + + type IAxis = ILinearAxis | ICategoricalAxis; + type IAxisType = "linear" | "categorical"; + + function getAxisType(): IAxisType { + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; + const good: IAxis = { type: undefined }; + good.type = getAxisType(); +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { + interface ThingTypeOne { + type: 'one'; + } + + interface ThingTypeTwo { + type: 'two'; + } + + type ThingType = 'one' | 'two'; + + type Thing = ThingTypeOne | ThingTypeTwo; + + function makeNewThing(thingType: ThingType): Thing { + return { + type: thingType + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { + type Action = { type: 'activate' } | { type: 'disactivate' }; + + function dispatchAction(action: Action): void { + + } + + const active = true; + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { + interface A1 { + type: "A1"; + } + interface A2 { + type: "A2"; + } + type AU = A1 | A2; + + function foo(obj1: AU) { + const obj2: AU = { + type: obj1.type + }; + } +} + +//// [assignmentCompatWithDiscriminatedUnion.js] +// see 'typeRelatedToDiscriminatedType' in checker.ts: +// IteratorResult +var Example1; +(function (Example1) { + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +})(Example1 || (Example1 = {})); +// Dropping constituents of T +var Example2; +(function (Example2) { + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +})(Example2 || (Example2 = {})); +// Unmatched discriminants +var Example3; +(function (Example3) { + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +})(Example3 || (Example3 = {})); +// Unmatched non-discriminants +var Example4; +(function (Example4) { + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +})(Example4 || (Example4 = {})); +// Maximum discriminant combinations +var Example5; +(function (Example5) { + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +})(Example5 || (Example5 = {})); +// https://github.com/Microsoft/TypeScript/issues/14865 +var GH14865; +(function (GH14865) { + var a = { type: "A", data: "whatevs" }; + var b; + a.type; // "A" | "B" + b.type; // "A" | "B" + b = a; // should be assignable +})(GH14865 || (GH14865 = {})); +// https://github.com/Microsoft/TypeScript/issues/30170 +var GH30170; +(function (GH30170) { + function draw(val) { } + function drawWithColor(currentColor) { + return draw({ color: currentColor }); + } +})(GH30170 || (GH30170 = {})); +// https://github.com/Microsoft/TypeScript/issues/12052 +var GH12052; +(function (GH12052) { + function getAxisType() { + if (1 == 1) { + return "categorical"; + } + else { + return "linear"; + } + } + var bad = { type: getAxisType() }; + var good = { type: undefined }; + good.type = getAxisType(); +})(GH12052 || (GH12052 = {})); +// https://github.com/Microsoft/TypeScript/issues/18421 +var GH18421; +(function (GH18421) { + function makeNewThing(thingType) { + return { + type: thingType + }; + } +})(GH18421 || (GH18421 = {})); +// https://github.com/Microsoft/TypeScript/issues/15907 +var GH15907; +(function (GH15907) { + function dispatchAction(action) { + } + var active = true; + dispatchAction({ type: (active ? 'disactivate' : 'activate') }); +})(GH15907 || (GH15907 = {})); +// https://github.com/Microsoft/TypeScript/issues/20889 +var GH20889; +(function (GH20889) { + function foo(obj1) { + var obj2 = { + type: obj1.type + }; + } +})(GH20889 || (GH20889 = {})); diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols new file mode 100644 index 0000000000000..1d0afd3fd91dc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols @@ -0,0 +1,494 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts === +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { +>Example1 : Symbol(Example1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 0, 0)) + + type S = { done: boolean, value: number }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 3, 20)) +>done : Symbol(done, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 14)) +>value : Symbol(value, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 29)) + + type T = +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 46)) + + | { done: true, value: number } // T0 +>done : Symbol(done, Decl(assignmentCompatWithDiscriminatedUnion.ts, 6, 11)) +>value : Symbol(value, Decl(assignmentCompatWithDiscriminatedUnion.ts, 6, 23)) + + | { done: false, value: number }; // T1 +>done : Symbol(done, Decl(assignmentCompatWithDiscriminatedUnion.ts, 7, 11)) +>value : Symbol(value, Decl(assignmentCompatWithDiscriminatedUnion.ts, 7, 24)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 9, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 3, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 10, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 4, 46)) + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 10, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 9, 15)) +} + +// Dropping constituents of T +namespace Example2 { +>Example2 : Symbol(Example2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 15, 1)) + + type S = { a: 0 | 2, b: 4 }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 18, 20)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 24)) + + type T = { a: 0, b: 1 | 4 } // T0 +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 32)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 20, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 20, 20)) + + | { a: 1, b: 2 } // T1 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 21, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 21, 20)) + + | { a: 2, b: 3 | 4 }; // T2 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 22, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 22, 20)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 23, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 18, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 24, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 19, 32)) + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 24, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 23, 15)) +} + +// Unmatched discriminants +namespace Example3 { +>Example3 : Symbol(Example3, Decl(assignmentCompatWithDiscriminatedUnion.ts, 29, 1)) + + type S = { a: 0 | 2, b: 4 }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 32, 20)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 24)) + + type T = { a: 0, b: 1 | 4 } // T0 +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 32)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 34, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 34, 20)) + + | { a: 1, b: 2 | 4 } // T1 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 35, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 35, 20)) + + | { a: 2, b: 3 }; // T2 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 36, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 36, 20)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 37, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 32, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 38, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 33, 32)) + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 38, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 37, 15)) +} + +// Unmatched non-discriminants +namespace Example4 { +>Example4 : Symbol(Example4, Decl(assignmentCompatWithDiscriminatedUnion.ts, 44, 1)) + + type S = { a: 0 | 2, b: 4 }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 47, 20)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 24)) + + type T = { a: 0, b: 1 | 4 } // T0 +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 32)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 49, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 49, 20)) + + | { a: 1, b: 2 } // T1 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 50, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 50, 20)) + + | { a: 2, b: 3 | 4, c: string }; // T2 +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 51, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 51, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 51, 34)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 52, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 47, 20)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 53, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 48, 32)) + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 53, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 52, 15)) +} + +// Maximum discriminant combinations +namespace Example5 { +>Example5 : Symbol(Example5, Decl(assignmentCompatWithDiscriminatedUnion.ts, 58, 1)) + + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + type S = { a: N, b: N, c: N }; +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 65, 23)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + type T = { a: 0, b: N, c: N } +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 34)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 67, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 67, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 67, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: 1, b: N, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 68, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 68, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 68, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: 2, b: N, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 69, 14)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 69, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 69, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: 0, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 70, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 70, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 70, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: 1, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 71, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 71, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 71, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: 2, c: N } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 72, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 72, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 72, 26)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) + + | { a: N, b: N, c: 0 } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 73, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 73, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 73, 26)) + + | { a: N, b: N, c: 1 } +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 74, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 74, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 74, 26)) + + | { a: N, b: N, c: 2 }; +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 75, 14)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 75, 20)) +>N : Symbol(N, Decl(assignmentCompatWithDiscriminatedUnion.ts, 61, 20)) +>c : Symbol(c, Decl(assignmentCompatWithDiscriminatedUnion.ts, 75, 26)) + + declare let s: S; +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 76, 15)) +>S : Symbol(S, Decl(assignmentCompatWithDiscriminatedUnion.ts, 65, 23)) + + declare let t: T; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 77, 15)) +>T : Symbol(T, Decl(assignmentCompatWithDiscriminatedUnion.ts, 66, 34)) + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +>t : Symbol(t, Decl(assignmentCompatWithDiscriminatedUnion.ts, 77, 15)) +>s : Symbol(s, Decl(assignmentCompatWithDiscriminatedUnion.ts, 76, 15)) +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { +>GH14865 : Symbol(GH14865, Decl(assignmentCompatWithDiscriminatedUnion.ts, 82, 1)) + + type Style1 = { +>Style1 : Symbol(Style1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 85, 19)) + + type: "A"; +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 86, 19)) + + data: string; +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 87, 18)) + + } | { + type: "B"; +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 89, 9)) + + data: string; +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 90, 18)) + + }; + + type Style2 = { +>Style2 : Symbol(Style2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 92, 6)) + + type: "A" | "B"; +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 94, 19)) + + data: string; +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 95, 24)) + } + + const a: Style2 = { type: "A", data: "whatevs" }; +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 9)) +>Style2 : Symbol(Style2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 92, 6)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 23)) +>data : Symbol(data, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 34)) + + let b: Style1; +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 100, 7)) +>Style1 : Symbol(Style1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 85, 19)) + + a.type; // "A" | "B" +>a.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 94, 19)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 9)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 94, 19)) + + b.type; // "A" | "B" +>b.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 86, 19), Decl(assignmentCompatWithDiscriminatedUnion.ts, 89, 9)) +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 100, 7)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 86, 19), Decl(assignmentCompatWithDiscriminatedUnion.ts, 89, 9)) + + b = a; // should be assignable +>b : Symbol(b, Decl(assignmentCompatWithDiscriminatedUnion.ts, 100, 7)) +>a : Symbol(a, Decl(assignmentCompatWithDiscriminatedUnion.ts, 99, 9)) +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { +>GH30170 : Symbol(GH30170, Decl(assignmentCompatWithDiscriminatedUnion.ts, 104, 1)) + + interface Blue { +>Blue : Symbol(Blue, Decl(assignmentCompatWithDiscriminatedUnion.ts, 107, 19)) + + color: 'blue' +>color : Symbol(Blue.color, Decl(assignmentCompatWithDiscriminatedUnion.ts, 108, 20)) + } + interface Yellow { +>Yellow : Symbol(Yellow, Decl(assignmentCompatWithDiscriminatedUnion.ts, 110, 5)) + + color?: 'yellow', +>color : Symbol(Yellow.color, Decl(assignmentCompatWithDiscriminatedUnion.ts, 111, 22)) + } + function draw(val: Blue | Yellow) { } +>draw : Symbol(draw, Decl(assignmentCompatWithDiscriminatedUnion.ts, 113, 5)) +>val : Symbol(val, Decl(assignmentCompatWithDiscriminatedUnion.ts, 114, 18)) +>Blue : Symbol(Blue, Decl(assignmentCompatWithDiscriminatedUnion.ts, 107, 19)) +>Yellow : Symbol(Yellow, Decl(assignmentCompatWithDiscriminatedUnion.ts, 110, 5)) + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { +>drawWithColor : Symbol(drawWithColor, Decl(assignmentCompatWithDiscriminatedUnion.ts, 114, 41)) +>currentColor : Symbol(currentColor, Decl(assignmentCompatWithDiscriminatedUnion.ts, 116, 27)) + + return draw({ color: currentColor }); +>draw : Symbol(draw, Decl(assignmentCompatWithDiscriminatedUnion.ts, 113, 5)) +>color : Symbol(color, Decl(assignmentCompatWithDiscriminatedUnion.ts, 117, 21)) +>currentColor : Symbol(currentColor, Decl(assignmentCompatWithDiscriminatedUnion.ts, 116, 27)) + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { +>GH12052 : Symbol(GH12052, Decl(assignmentCompatWithDiscriminatedUnion.ts, 119, 1)) + + interface ILinearAxis { type: "linear"; } +>ILinearAxis : Symbol(ILinearAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 122, 19)) +>type : Symbol(ILinearAxis.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27)) + + interface ICategoricalAxis { type: "categorical"; } +>ICategoricalAxis : Symbol(ICategoricalAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 45)) +>type : Symbol(ICategoricalAxis.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) + + type IAxis = ILinearAxis | ICategoricalAxis; +>IAxis : Symbol(IAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 55)) +>ILinearAxis : Symbol(ILinearAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 122, 19)) +>ICategoricalAxis : Symbol(ICategoricalAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 45)) + + type IAxisType = "linear" | "categorical"; +>IAxisType : Symbol(IAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 127, 48)) + + function getAxisType(): IAxisType { +>getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) +>IAxisType : Symbol(IAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 127, 48)) + + if (1 == 1) { + return "categorical"; + } else { + return "linear"; + } + } + + const bad: IAxis = { type: getAxisType() }; +>bad : Symbol(bad, Decl(assignmentCompatWithDiscriminatedUnion.ts, 138, 9)) +>IAxis : Symbol(IAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 55)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 138, 24)) +>getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) + + const good: IAxis = { type: undefined }; +>good : Symbol(good, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 9)) +>IAxis : Symbol(IAxis, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 55)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 25)) +>undefined : Symbol(undefined) + + good.type = getAxisType(); +>good.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27), Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) +>good : Symbol(good, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 9)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27), Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) +>getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { +>GH18421 : Symbol(GH18421, Decl(assignmentCompatWithDiscriminatedUnion.ts, 141, 1)) + + interface ThingTypeOne { +>ThingTypeOne : Symbol(ThingTypeOne, Decl(assignmentCompatWithDiscriminatedUnion.ts, 144, 19)) + + type: 'one'; +>type : Symbol(ThingTypeOne.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 145, 28)) + } + + interface ThingTypeTwo { +>ThingTypeTwo : Symbol(ThingTypeTwo, Decl(assignmentCompatWithDiscriminatedUnion.ts, 147, 5)) + + type: 'two'; +>type : Symbol(ThingTypeTwo.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 149, 28)) + } + + type ThingType = 'one' | 'two'; +>ThingType : Symbol(ThingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 151, 5)) + + type Thing = ThingTypeOne | ThingTypeTwo; +>Thing : Symbol(Thing, Decl(assignmentCompatWithDiscriminatedUnion.ts, 153, 35)) +>ThingTypeOne : Symbol(ThingTypeOne, Decl(assignmentCompatWithDiscriminatedUnion.ts, 144, 19)) +>ThingTypeTwo : Symbol(ThingTypeTwo, Decl(assignmentCompatWithDiscriminatedUnion.ts, 147, 5)) + + function makeNewThing(thingType: ThingType): Thing { +>makeNewThing : Symbol(makeNewThing, Decl(assignmentCompatWithDiscriminatedUnion.ts, 155, 45)) +>thingType : Symbol(thingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 157, 26)) +>ThingType : Symbol(ThingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 151, 5)) +>Thing : Symbol(Thing, Decl(assignmentCompatWithDiscriminatedUnion.ts, 153, 35)) + + return { + type: thingType +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 158, 16)) +>thingType : Symbol(thingType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 157, 26)) + + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { +>GH15907 : Symbol(GH15907, Decl(assignmentCompatWithDiscriminatedUnion.ts, 162, 1)) + + type Action = { type: 'activate' } | { type: 'disactivate' }; +>Action : Symbol(Action, Decl(assignmentCompatWithDiscriminatedUnion.ts, 165, 19)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 19)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 42)) + + function dispatchAction(action: Action): void { +>dispatchAction : Symbol(dispatchAction, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 65)) +>action : Symbol(action, Decl(assignmentCompatWithDiscriminatedUnion.ts, 168, 28)) +>Action : Symbol(Action, Decl(assignmentCompatWithDiscriminatedUnion.ts, 165, 19)) + + } + + const active = true; +>active : Symbol(active, Decl(assignmentCompatWithDiscriminatedUnion.ts, 172, 9)) + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +>dispatchAction : Symbol(dispatchAction, Decl(assignmentCompatWithDiscriminatedUnion.ts, 166, 65)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 174, 20)) +>active : Symbol(active, Decl(assignmentCompatWithDiscriminatedUnion.ts, 172, 9)) +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { +>GH20889 : Symbol(GH20889, Decl(assignmentCompatWithDiscriminatedUnion.ts, 175, 1)) + + interface A1 { +>A1 : Symbol(A1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 178, 19)) + + type: "A1"; +>type : Symbol(A1.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 179, 18)) + } + interface A2 { +>A2 : Symbol(A2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 181, 5)) + + type: "A2"; +>type : Symbol(A2.type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 182, 18)) + } + type AU = A1 | A2; +>AU : Symbol(AU, Decl(assignmentCompatWithDiscriminatedUnion.ts, 184, 5)) +>A1 : Symbol(A1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 178, 19)) +>A2 : Symbol(A2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 181, 5)) + + function foo(obj1: AU) { +>foo : Symbol(foo, Decl(assignmentCompatWithDiscriminatedUnion.ts, 185, 22)) +>obj1 : Symbol(obj1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 187, 17)) +>AU : Symbol(AU, Decl(assignmentCompatWithDiscriminatedUnion.ts, 184, 5)) + + const obj2: AU = { +>obj2 : Symbol(obj2, Decl(assignmentCompatWithDiscriminatedUnion.ts, 188, 13)) +>AU : Symbol(AU, Decl(assignmentCompatWithDiscriminatedUnion.ts, 184, 5)) + + type: obj1.type +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 188, 26)) +>obj1.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 179, 18), Decl(assignmentCompatWithDiscriminatedUnion.ts, 182, 18)) +>obj1 : Symbol(obj1, Decl(assignmentCompatWithDiscriminatedUnion.ts, 187, 17)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 179, 18), Decl(assignmentCompatWithDiscriminatedUnion.ts, 182, 18)) + + }; + } +} diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types new file mode 100644 index 0000000000000..76bdb2716d20e --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types @@ -0,0 +1,466 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts === +// see 'typeRelatedToDiscriminatedType' in checker.ts: + +// IteratorResult +namespace Example1 { +>Example1 : typeof Example1 + + type S = { done: boolean, value: number }; +>S : S +>done : boolean +>value : number + + type T = +>T : T + + | { done: true, value: number } // T0 +>done : true +>true : true +>value : number + + | { done: false, value: number }; // T1 +>done : false +>false : false +>value : number + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["done"] is true + // S is assignable to T1 when S["done"] is false + t = s; +>t = s : S +>t : T +>s : S +} + +// Dropping constituents of T +namespace Example2 { +>Example2 : typeof Example2 + + type S = { a: 0 | 2, b: 4 }; +>S : S +>a : 0 | 2 +>b : 4 + + type T = { a: 0, b: 1 | 4 } // T0 +>T : T +>a : 0 +>b : 4 | 1 + + | { a: 1, b: 2 } // T1 +>a : 1 +>b : 2 + + | { a: 2, b: 3 | 4 }; // T2 +>a : 2 +>b : 4 | 3 + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["a"] is 0 + // S is assignable to T2 when S["a"] is 2 + t = s; +>t = s : S +>t : T +>s : S +} + +// Unmatched discriminants +namespace Example3 { +>Example3 : typeof Example3 + + type S = { a: 0 | 2, b: 4 }; +>S : S +>a : 0 | 2 +>b : 4 + + type T = { a: 0, b: 1 | 4 } // T0 +>T : T +>a : 0 +>b : 4 | 1 + + | { a: 1, b: 2 | 4 } // T1 +>a : 1 +>b : 2 | 4 + + | { a: 2, b: 3 }; // T2 +>a : 2 +>b : 3 + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T1 when S["b"] is 4 + // S is *not* assignable to T2 when S["a"] is 2 + t = s; +>t = s : S +>t : T +>s : S +} + +// Unmatched non-discriminants +namespace Example4 { +>Example4 : typeof Example4 + + type S = { a: 0 | 2, b: 4 }; +>S : S +>a : 0 | 2 +>b : 4 + + type T = { a: 0, b: 1 | 4 } // T0 +>T : T +>a : 0 +>b : 4 | 1 + + | { a: 1, b: 2 } // T1 +>a : 1 +>b : 2 + + | { a: 2, b: 3 | 4, c: string }; // T2 +>a : 2 +>b : 4 | 3 +>c : string + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S is assignable to T0 when S["a"] is 0 + // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" + t = s; +>t = s : S +>t : T +>s : S +} + +// Maximum discriminant combinations +namespace Example5 { +>Example5 : typeof Example5 + + // NOTE: The maximum number of discriminant type combinations is currently 25. + // 3 discriminant properties with 3 types a piece + // is 27 possible combinations. + type N = 0 | 1 | 2; +>N : 0 | 2 | 1 + + type S = { a: N, b: N, c: N }; +>S : S +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + type T = { a: 0, b: N, c: N } +>T : T +>a : 0 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + | { a: 1, b: N, c: N } +>a : 1 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + | { a: 2, b: N, c: N } +>a : 2 +>b : 0 | 2 | 1 +>c : 0 | 2 | 1 + + | { a: N, b: 0, c: N } +>a : 0 | 2 | 1 +>b : 0 +>c : 0 | 2 | 1 + + | { a: N, b: 1, c: N } +>a : 0 | 2 | 1 +>b : 1 +>c : 0 | 2 | 1 + + | { a: N, b: 2, c: N } +>a : 0 | 2 | 1 +>b : 2 +>c : 0 | 2 | 1 + + | { a: N, b: N, c: 0 } +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 0 + + | { a: N, b: N, c: 1 } +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 1 + + | { a: N, b: N, c: 2 }; +>a : 0 | 2 | 1 +>b : 0 | 2 | 1 +>c : 2 + + declare let s: S; +>s : S + + declare let t: T; +>t : T + + // S *should* be assignable but the number of + // combinations is too complex. + t = s; +>t = s : S +>t : T +>s : S +} + +// https://github.com/Microsoft/TypeScript/issues/14865 +namespace GH14865 { +>GH14865 : typeof GH14865 + + type Style1 = { +>Style1 : Style1 + + type: "A"; +>type : "A" + + data: string; +>data : string + + } | { + type: "B"; +>type : "B" + + data: string; +>data : string + + }; + + type Style2 = { +>Style2 : Style2 + + type: "A" | "B"; +>type : "A" | "B" + + data: string; +>data : string + } + + const a: Style2 = { type: "A", data: "whatevs" }; +>a : Style2 +>{ type: "A", data: "whatevs" } : { type: "A"; data: string; } +>type : "A" +>"A" : "A" +>data : string +>"whatevs" : "whatevs" + + let b: Style1; +>b : Style1 + + a.type; // "A" | "B" +>a.type : "A" | "B" +>a : Style2 +>type : "A" | "B" + + b.type; // "A" | "B" +>b.type : "A" | "B" +>b : Style1 +>type : "A" | "B" + + b = a; // should be assignable +>b = a : Style2 +>b : Style1 +>a : Style2 +} + +// https://github.com/Microsoft/TypeScript/issues/30170 +namespace GH30170 { +>GH30170 : typeof GH30170 + + interface Blue { + color: 'blue' +>color : "blue" + } + interface Yellow { + color?: 'yellow', +>color : "yellow" + } + function draw(val: Blue | Yellow) { } +>draw : (val: Blue | Yellow) => void +>val : Blue | Yellow + + function drawWithColor(currentColor: 'blue' | 'yellow' | undefined) { +>drawWithColor : (currentColor: "blue" | "yellow") => void +>currentColor : "blue" | "yellow" + + return draw({ color: currentColor }); +>draw({ color: currentColor }) : void +>draw : (val: Blue | Yellow) => void +>{ color: currentColor } : { color: "blue" | "yellow"; } +>color : "blue" | "yellow" +>currentColor : "blue" | "yellow" + } +} + +// https://github.com/Microsoft/TypeScript/issues/12052 +namespace GH12052 { +>GH12052 : typeof GH12052 + + interface ILinearAxis { type: "linear"; } +>type : "linear" + + interface ICategoricalAxis { type: "categorical"; } +>type : "categorical" + + type IAxis = ILinearAxis | ICategoricalAxis; +>IAxis : IAxis + + type IAxisType = "linear" | "categorical"; +>IAxisType : IAxisType + + function getAxisType(): IAxisType { +>getAxisType : () => IAxisType + + if (1 == 1) { +>1 == 1 : boolean +>1 : 1 +>1 : 1 + + return "categorical"; +>"categorical" : "categorical" + + } else { + return "linear"; +>"linear" : "linear" + } + } + + const bad: IAxis = { type: getAxisType() }; +>bad : IAxis +>{ type: getAxisType() } : { type: IAxisType; } +>type : IAxisType +>getAxisType() : IAxisType +>getAxisType : () => IAxisType + + const good: IAxis = { type: undefined }; +>good : IAxis +>{ type: undefined } : { type: undefined; } +>type : undefined +>undefined : undefined + + good.type = getAxisType(); +>good.type = getAxisType() : IAxisType +>good.type : IAxisType +>good : IAxis +>type : IAxisType +>getAxisType() : IAxisType +>getAxisType : () => IAxisType +} + +// https://github.com/Microsoft/TypeScript/issues/18421 +namespace GH18421 { +>GH18421 : typeof GH18421 + + interface ThingTypeOne { + type: 'one'; +>type : "one" + } + + interface ThingTypeTwo { + type: 'two'; +>type : "two" + } + + type ThingType = 'one' | 'two'; +>ThingType : ThingType + + type Thing = ThingTypeOne | ThingTypeTwo; +>Thing : Thing + + function makeNewThing(thingType: ThingType): Thing { +>makeNewThing : (thingType: ThingType) => Thing +>thingType : ThingType + + return { +>{ type: thingType } : { type: ThingType; } + + type: thingType +>type : ThingType +>thingType : ThingType + + }; + } +} + +// https://github.com/Microsoft/TypeScript/issues/15907 +namespace GH15907 { +>GH15907 : typeof GH15907 + + type Action = { type: 'activate' } | { type: 'disactivate' }; +>Action : Action +>type : "activate" +>type : "disactivate" + + function dispatchAction(action: Action): void { +>dispatchAction : (action: Action) => void +>action : Action + + } + + const active = true; +>active : true +>true : true + + dispatchAction({ type : (active? 'disactivate' : 'activate') }); +>dispatchAction({ type : (active? 'disactivate' : 'activate') }) : void +>dispatchAction : (action: Action) => void +>{ type : (active? 'disactivate' : 'activate') } : { type: "activate" | "disactivate"; } +>type : "activate" | "disactivate" +>(active? 'disactivate' : 'activate') : "activate" | "disactivate" +>active? 'disactivate' : 'activate' : "activate" | "disactivate" +>active : true +>'disactivate' : "disactivate" +>'activate' : "activate" +} + +// https://github.com/Microsoft/TypeScript/issues/20889 +namespace GH20889 { +>GH20889 : typeof GH20889 + + interface A1 { + type: "A1"; +>type : "A1" + } + interface A2 { + type: "A2"; +>type : "A2" + } + type AU = A1 | A2; +>AU : AU + + function foo(obj1: AU) { +>foo : (obj1: AU) => void +>obj1 : AU + + const obj2: AU = { +>obj2 : AU +>{ type: obj1.type } : { type: "A1" | "A2"; } + + type: obj1.type +>type : "A1" | "A2" +>obj1.type : "A1" | "A2" +>obj1 : AU +>type : "A1" | "A2" + + }; + } +} diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt index 38f03ca68c441..adf305d868d19 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(15,1): error TS2322: Type 'B' is not assignable to type 'A'. Types of parameters 'y' and 'y' are incompatible. Type 'T[]' is not assignable to type 'T'. + 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(16,1): error TS2322: Type 'A' is not assignable to type 'B'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'S[]'. @@ -26,6 +27,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'B' is not assignable to type 'A'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'T[]' is not assignable to type 'T'. +!!! error TS2322: 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b = a; ~ !!! error TS2322: Type 'A' is not assignable to type 'B'. diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt index dbad415c5f83d..d5b212a414a9c 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt @@ -2,68 +2,91 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(23,13): error TS2322: Type '(x: T, y: T) => any' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(63,9): error TS2322: Type '() => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(64,9): error TS2322: Type '(x?: T) => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(65,9): error TS2322: Type '(x: T) => T' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(66,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(67,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '() => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(69,9): error TS2322: Type '() => T' is not assignable to type '(x?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(70,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(71,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(72,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(73,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(75,9): error TS2322: Type '() => T' is not assignable to type '(x: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(76,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(77,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(78,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(79,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(81,9): error TS2322: Type '() => T' is not assignable to type '(x: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(82,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(83,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(84,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(85,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(87,9): error TS2322: Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(88,9): error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(89,9): error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(90,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(91,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(107,13): error TS2322: Type '(x: T) => any' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(116,13): error TS2322: Type '(x: T, y: T) => any' is not assignable to type '(x: T) => T'. @@ -139,10 +162,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type '() => T' is not assignable to type '() => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a = t.a2; ~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '() => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a = t.a3; ~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '() => T'. @@ -153,106 +178,127 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '() => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a2 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a3 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a4 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a; ~~~~ !!! error TS2322: Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a2; ~~~~ !!! error TS2322: Type '(x?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a3; ~~~~ !!! error TS2322: Type '(x: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a4; ~~~~ !!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. b.a5 = t.a5; ~~~~ !!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2322: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } } diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt index 9f60ca5500221..7358455430c80 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -14,6 +15,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -66,6 +68,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. @@ -79,6 +82,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt index e063a16fd3f4c..f4b2e46f44f96 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -14,6 +15,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -66,6 +68,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. @@ -79,6 +82,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt index 845edafd82ca8..1f279ba2858f7 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts(33,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts (3 errors) ==== @@ -57,6 +58,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived'. b = a; // ok var b2: { [x: number]: T; }; diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt index 523c6b9733774..b3970325dc298 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt @@ -13,6 +13,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -20,6 +21,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -94,6 +96,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b3 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. @@ -107,6 +110,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b4 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt index 180012decc2dd..f90f8a41feb05 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt @@ -13,6 +13,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. + 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. @@ -20,6 +21,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. + 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -94,6 +96,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. +!!! error TS2322: 'Derived' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b3 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. @@ -107,6 +110,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2322: 'Derived2' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. b4 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. diff --git a/tests/baselines/reference/assignmentStricterConstraints.errors.txt b/tests/baselines/reference/assignmentStricterConstraints.errors.txt index c83e2fa3440d0..f00b8313eac8d 100644 --- a/tests/baselines/reference/assignmentStricterConstraints.errors.txt +++ b/tests/baselines/reference/assignmentStricterConstraints.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/assignmentStricterConstraints.ts(7,1): error TS2322: Type '(x: T, y: S) => void' is not assignable to type '(x: T, y: S) => void'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'T'. + 'S' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/assignmentStricterConstraints.ts (1 errors) ==== @@ -15,5 +16,6 @@ tests/cases/compiler/assignmentStricterConstraints.ts(7,1): error TS2322: Type ' !!! error TS2322: Type '(x: T, y: S) => void' is not assignable to type '(x: T, y: S) => void'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'S' is not assignable to type 'T'. +!!! error TS2322: 'S' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. g(1, "") \ No newline at end of file diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt new file mode 100644 index 0000000000000..5cd8468ac3eb6 --- /dev/null +++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt @@ -0,0 +1,103 @@ +tests/cases/compiler/awaitInNonAsyncFunction.ts(4,7): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(5,10): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(9,7): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(10,10): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(14,7): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(15,3): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(19,7): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(20,10): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(24,7): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(25,9): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(30,9): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(34,7): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expression is only allowed within an async function. +tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1308: 'await' expression is only allowed within an async function. + + +==== tests/cases/compiler/awaitInNonAsyncFunction.ts (16 errors) ==== + // https://github.com/Microsoft/TypeScript/issues/26586 + + function normalFunc(p: Promise) { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:3:10: Did you mean to mark this function as 'async'? + return await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:3:10: Did you mean to mark this function as 'async'? + } + + export function exportedFunc(p: Promise) { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:8:17: Did you mean to mark this function as 'async'? + return await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:8:17: Did you mean to mark this function as 'async'? + } + + const functionExpression = function(p: Promise) { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:13:28: Did you mean to mark this function as 'async'? + await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:13:28: Did you mean to mark this function as 'async'? + } + + const arrowFunc = (p: Promise) => { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:18:19: Did you mean to mark this function as 'async'? + return await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:18:19: Did you mean to mark this function as 'async'? + }; + + function* generatorFunc(p: Promise) { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:23:11: Did you mean to mark this function as 'async'? + yield await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:23:11: Did you mean to mark this function as 'async'? + } + + class clazz { + constructor(p: Promise) { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. + } + method(p: Promise) { + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:33:3: Did you mean to mark this function as 'async'? + await p; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitInNonAsyncFunction.ts:33:3: Did you mean to mark this function as 'async'? + } + } + + for await (const _ of []); + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + await null; + ~~~~~ +!!! error TS1308: 'await' expression is only allowed within an async function. \ No newline at end of file diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.js b/tests/baselines/reference/awaitInNonAsyncFunction.js new file mode 100644 index 0000000000000..83f75aa5633eb --- /dev/null +++ b/tests/baselines/reference/awaitInNonAsyncFunction.js @@ -0,0 +1,84 @@ +//// [awaitInNonAsyncFunction.ts] +// https://github.com/Microsoft/TypeScript/issues/26586 + +function normalFunc(p: Promise) { + for await (const _ of []); + return await p; +} + +export function exportedFunc(p: Promise) { + for await (const _ of []); + return await p; +} + +const functionExpression = function(p: Promise) { + for await (const _ of []); + await p; +} + +const arrowFunc = (p: Promise) => { + for await (const _ of []); + return await p; +}; + +function* generatorFunc(p: Promise) { + for await (const _ of []); + yield await p; +} + +class clazz { + constructor(p: Promise) { + for await (const _ of []); + await p; + } + method(p: Promise) { + for await (const _ of []); + await p; + } +} + +for await (const _ of []); +await null; + +//// [awaitInNonAsyncFunction.js] +// https://github.com/Microsoft/TypeScript/issues/26586 +function normalFunc(p) { + for await (const _ of []) + ; + return await p; +} +export function exportedFunc(p) { + for await (const _ of []) + ; + return await p; +} +const functionExpression = function (p) { + for await (const _ of []) + ; + await p; +}; +const arrowFunc = (p) => { + for await (const _ of []) + ; + return await p; +}; +function* generatorFunc(p) { + for await (const _ of []) + ; + yield await p; +} +class clazz { + constructor(p) { + for await (const _ of []) + ; + await p; + } + method(p) { + for await (const _ of []) + ; + await p; + } +} +for await (const _ of []) + ; +await null; diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.symbols b/tests/baselines/reference/awaitInNonAsyncFunction.symbols new file mode 100644 index 0000000000000..cf184637e6f06 --- /dev/null +++ b/tests/baselines/reference/awaitInNonAsyncFunction.symbols @@ -0,0 +1,94 @@ +=== tests/cases/compiler/awaitInNonAsyncFunction.ts === +// https://github.com/Microsoft/TypeScript/issues/26586 + +function normalFunc(p: Promise) { +>normalFunc : Symbol(normalFunc, Decl(awaitInNonAsyncFunction.ts, 0, 0)) +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 2, 20)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 3, 18)) + + return await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 2, 20)) +} + +export function exportedFunc(p: Promise) { +>exportedFunc : Symbol(exportedFunc, Decl(awaitInNonAsyncFunction.ts, 5, 1)) +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 7, 29)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 8, 18)) + + return await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 7, 29)) +} + +const functionExpression = function(p: Promise) { +>functionExpression : Symbol(functionExpression, Decl(awaitInNonAsyncFunction.ts, 12, 5)) +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 12, 36)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 13, 18)) + + await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 12, 36)) +} + +const arrowFunc = (p: Promise) => { +>arrowFunc : Symbol(arrowFunc, Decl(awaitInNonAsyncFunction.ts, 17, 5)) +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 17, 19)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 18, 18)) + + return await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 17, 19)) + +}; + +function* generatorFunc(p: Promise) { +>generatorFunc : Symbol(generatorFunc, Decl(awaitInNonAsyncFunction.ts, 20, 2)) +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 22, 24)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 23, 18)) + + yield await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 22, 24)) +} + +class clazz { +>clazz : Symbol(clazz, Decl(awaitInNonAsyncFunction.ts, 25, 1)) + + constructor(p: Promise) { +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 28, 14)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 29, 20)) + + await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 28, 14)) + } + method(p: Promise) { +>method : Symbol(clazz.method, Decl(awaitInNonAsyncFunction.ts, 31, 3)) +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 32, 9)) +>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, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + + for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 33, 18)) + + await p; +>p : Symbol(p, Decl(awaitInNonAsyncFunction.ts, 32, 9)) + } +} + +for await (const _ of []); +>_ : Symbol(_, Decl(awaitInNonAsyncFunction.ts, 38, 16)) + +await null; diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.types b/tests/baselines/reference/awaitInNonAsyncFunction.types new file mode 100644 index 0000000000000..78b9a6c5a9027 --- /dev/null +++ b/tests/baselines/reference/awaitInNonAsyncFunction.types @@ -0,0 +1,108 @@ +=== tests/cases/compiler/awaitInNonAsyncFunction.ts === +// https://github.com/Microsoft/TypeScript/issues/26586 + +function normalFunc(p: Promise) { +>normalFunc : (p: Promise) => number +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + return await p; +>await p : number +>p : Promise +} + +export function exportedFunc(p: Promise) { +>exportedFunc : (p: Promise) => number +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + return await p; +>await p : number +>p : Promise +} + +const functionExpression = function(p: Promise) { +>functionExpression : (p: Promise) => void +>function(p: Promise) { for await (const _ of []); await p;} : (p: Promise) => void +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + await p; +>await p : number +>p : Promise +} + +const arrowFunc = (p: Promise) => { +>arrowFunc : (p: Promise) => number +>(p: Promise) => { for await (const _ of []); return await p;} : (p: Promise) => number +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + return await p; +>await p : number +>p : Promise + +}; + +function* generatorFunc(p: Promise) { +>generatorFunc : (p: Promise) => IterableIterator +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + yield await p; +>yield await p : any +>await p : number +>p : Promise +} + +class clazz { +>clazz : clazz + + constructor(p: Promise) { +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + await p; +>await p : number +>p : Promise + } + method(p: Promise) { +>method : (p: Promise) => void +>p : Promise + + for await (const _ of []); +>_ : any +>[] : undefined[] + + await p; +>await p : number +>p : Promise + } +} + +for await (const _ of []); +>_ : any +>[] : undefined[] + +await null; +>await null : null +>null : null + diff --git a/tests/baselines/reference/awaitLiteralValues.errors.txt b/tests/baselines/reference/awaitLiteralValues.errors.txt index cf3e155c2809f..eb3237186e37f 100644 --- a/tests/baselines/reference/awaitLiteralValues.errors.txt +++ b/tests/baselines/reference/awaitLiteralValues.errors.txt @@ -11,35 +11,41 @@ tests/cases/compiler/awaitLiteralValues.ts(22,5): error TS1308: 'await' expressi await 'literal'; ~~~~~ !!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitLiteralValues.ts:1:10: Did you mean to mark this function as 'async'? } function awaitNumber() { await 1; ~~~~~ !!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitLiteralValues.ts:5:10: Did you mean to mark this function as 'async'? } function awaitTrue() { await true; ~~~~~ !!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitLiteralValues.ts:9:10: Did you mean to mark this function as 'async'? } function awaitFalse() { await false; ~~~~~ !!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitLiteralValues.ts:13:10: Did you mean to mark this function as 'async'? } function awaitNull() { await null; ~~~~~ !!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitLiteralValues.ts:17:10: Did you mean to mark this function as 'async'? } function awaitUndefined() { await undefined; ~~~~~ !!! error TS1308: 'await' expression is only allowed within an async function. +!!! related TS1356 tests/cases/compiler/awaitLiteralValues.ts:21:10: Did you mean to mark this function as 'async'? } \ No newline at end of file diff --git a/tests/baselines/reference/baseConstraintOfDecorator.errors.txt b/tests/baselines/reference/baseConstraintOfDecorator.errors.txt index 3af8756fac29a..8317e5c55c660 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.errors.txt +++ b/tests/baselines/reference/baseConstraintOfDecorator.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(2,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. + 'typeof decoratorFunc' is assignable to the constraint of type 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/baseConstraintOfDecorator.ts(2,40): error TS2507: Type 'TFunction' is not a constructor function type. tests/cases/compiler/baseConstraintOfDecorator.ts(12,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TFunction' is not a constructor function type. @@ -22,6 +23,7 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TF }; ~~~~~~ !!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. +!!! error TS2322: 'typeof decoratorFunc' is assignable to the constraint of type 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint '{}'. } class MyClass { private x; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt index 3d9ecd65e3d89..2ca3bb1aaf00a 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Types of property 'a2' are incompatible. Type '(x: T) => string' is not assignable to type '(x: T) => T'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts (2 errors) ==== @@ -82,6 +83,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type '(x: T) => string' is not assignable to type '(x: T) => T'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 33af0d9f4bf0f..671c09b3d7906 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '(x: T) => U[]' is not assignable to type '(x: number) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(60,19): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a8' are incompatible. Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. @@ -30,6 +31,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(109,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'. Types of property 'a2' are incompatible. Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. @@ -95,6 +97,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => U[]' is not assignable to type '(x: number) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'T'. +!!! error TS2430: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic } @@ -175,6 +178,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. !!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => string[]; // error } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt index 602e40dfcfb57..f6526347975c7 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt @@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '(x: T) => T[]' is not assignable to type '(x: T) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(28,11): error TS2430: Interface 'I2' incorrectly extends interface 'A'. Types of property 'a2' are incompatible. Type '(x: T) => string[]' is not assignable to type '(x: T) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(32,11): error TS2430: Interface 'I3' incorrectly extends interface 'A'. Types of property 'a3' are incompatible. Type '(x: T) => T' is not assignable to type '(x: T) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(36,11): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a4' are incompatible. Type '(x: T, y: U) => string' is not assignable to type '(x: T, y: U) => string'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(40,11): error TS2430: Interface 'I5' incorrectly extends interface 'A'. Types of property 'a5' are incompatible. Type '(x: (arg: T) => U) => T' is not assignable to type '(x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(44,11): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a11' are incompatible. Type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base'. @@ -31,6 +36,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts(48,11): error TS2430: Interface 'I9' incorrectly extends interface 'A'. Types of property 'a16' are incompatible. Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. @@ -38,7 +44,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - Type 'Base' is not assignable to type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts (7 errors) ==== @@ -72,6 +80,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => T[]' is not assignable to type '(x: T) => T[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: (x: T) => T[]; } @@ -82,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => string[]' is not assignable to type '(x: T) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => string[]; } @@ -92,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T) => T' is not assignable to type '(x: T) => void'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: (x: T) => T; } @@ -102,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '(x: T, y: U) => string' is not assignable to type '(x: T, y: U) => string'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: (x: T, y: U) => string; } @@ -113,6 +125,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: (x: (arg: T) => U) => T; } @@ -125,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'foo' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; } @@ -137,6 +151,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a16: (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt index 6f03e711886ba..e0091e407dfc5 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt @@ -1,5 +1,7 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(7,49): error TS2322: Type 'T' is not assignable to type 'S'. + 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(10,35): error TS2322: Type 'T' is not assignable to type 'S'. + 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2322: Type '""' is not assignable to type 'number'. @@ -15,12 +17,14 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete (new Chain(t)).then(tt => s).then(ss => t); ~ !!! error TS2322: Type 'T' is not assignable to type 'S'. +!!! error TS2322: 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. !!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:3:27: The expected type comes from the return type of this signature. // But error to try to climb up the chain (new Chain(s)).then(ss => t); ~ !!! error TS2322: Type 'T' is not assignable to type 'S'. +!!! error TS2322: 'T' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. !!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:3:27: The expected type comes from the return type of this signature. // Staying at T or S should be fine diff --git a/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt b/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt index 32e8464a19573..d2c8c0111aede 100644 --- a/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt +++ b/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts(6,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts(12,9): error TS2322: Type 'T2' is not assignable to type 'T1'. + 'T2' is assignable to the constraint of type 'T1', but 'T1' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts (2 errors) ==== @@ -19,4 +20,5 @@ tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOpera var result: T1 = (x, y); //error here ~~~~~~ !!! error TS2322: Type 'T2' is not assignable to type 'T1'. +!!! error TS2322: 'T2' is assignable to the constraint of type 'T1', but 'T1' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/complexRecursiveCollections.errors.txt b/tests/baselines/reference/complexRecursiveCollections.errors.txt index aaed4f2636092..27bb24bc5cc14 100644 --- a/tests/baselines/reference/complexRecursiveCollections.errors.txt +++ b/tests/baselines/reference/complexRecursiveCollections.errors.txt @@ -2,14 +2,17 @@ tests/cases/compiler/immutable.ts(341,22): error TS2430: Interface 'Keyed' Types of property 'toSeq' are incompatible. Type '() => Keyed' is not assignable to type '() => this'. Type 'Keyed' is not assignable to type 'this'. + 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. tests/cases/compiler/immutable.ts(359,22): error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Indexed' is not assignable to type '() => this'. Type 'Indexed' is not assignable to type 'this'. + 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Set' is not assignable to type '() => this'. Type 'Set' is not assignable to type 'this'. + 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. ==== tests/cases/compiler/complex.ts (0 errors) ==== @@ -380,6 +383,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco !!! error TS2430: Types of property 'toSeq' are incompatible. !!! error TS2430: Type '() => Keyed' is not assignable to type '() => this'. !!! error TS2430: Type 'Keyed' is not assignable to type 'this'. +!!! error TS2430: 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. toJS(): Object; toJSON(): { [key: string]: V }; toSeq(): Seq.Keyed; @@ -403,6 +407,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco !!! error TS2430: Types of property 'toSeq' are incompatible. !!! error TS2430: Type '() => Indexed' is not assignable to type '() => this'. !!! error TS2430: Type 'Indexed' is not assignable to type 'this'. +!!! error TS2430: 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. toJS(): Array; toJSON(): Array; // Reading values @@ -440,6 +445,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco !!! error TS2430: Types of property 'toSeq' are incompatible. !!! error TS2430: Type '() => Set' is not assignable to type '() => this'. !!! error TS2430: Type 'Set' is not assignable to type 'this'. +!!! error TS2430: 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. toJS(): Array; toJSON(): Array; toSeq(): Seq.Set; diff --git a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt index 97cd312b2637a..af63c18523d6a 100644 --- a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt +++ b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt @@ -10,13 +10,15 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t Type '"text"' is not assignable to type 'ChannelOfType["type"]'. Type '"text"' is not assignable to type 'T & "text"'. Type '"text"' is not assignable to type 'T'. - Type 'T' is not assignable to type 'T & "text"'. - Type '"text" | "email"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T'. - Type 'T' is not assignable to type '"text"'. - Type '"text" | "email"' is not assignable to type '"text"'. - Type '"email"' is not assignable to type '"text"'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type 'T & "text"'. + Type '"text" | "email"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type '"text"'. + Type '"text" | "email"' is not assignable to type '"text"'. + Type '"email"' is not assignable to type '"text"'. ==== tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.ts (1 errors) ==== @@ -66,13 +68,15 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. !!! error TS2322: Type '"text"' is not assignable to type 'T'. -!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T'. -!!! error TS2322: Type 'T' is not assignable to type '"text"'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. -!!! error TS2322: Type '"email"' is not assignable to type '"text"'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type '"text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. +!!! error TS2322: Type '"email"' is not assignable to type '"text"'. } const newTextChannel = makeNewChannel('text'); diff --git a/tests/baselines/reference/compositeWithNodeModulesSourceFile.js b/tests/baselines/reference/compositeWithNodeModulesSourceFile.js new file mode 100644 index 0000000000000..9a2caf39c61a3 --- /dev/null +++ b/tests/baselines/reference/compositeWithNodeModulesSourceFile.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/compositeWithNodeModulesSourceFile.ts] //// + +//// [index.ts] +export class c { } + +//// [test.ts] +import myModule = require("myModule"); +new myModule.c(); + + + +//// [test.js] +"use strict"; +exports.__esModule = true; +var myModule = require("myModule"); +new myModule.c(); + + +//// [test.d.ts] +export {}; diff --git a/tests/baselines/reference/compositeWithNodeModulesSourceFile.symbols b/tests/baselines/reference/compositeWithNodeModulesSourceFile.symbols new file mode 100644 index 0000000000000..9daaf1ad5ffd7 --- /dev/null +++ b/tests/baselines/reference/compositeWithNodeModulesSourceFile.symbols @@ -0,0 +1,14 @@ +=== /foo/test.ts === +import myModule = require("myModule"); +>myModule : Symbol(myModule, Decl(test.ts, 0, 0)) + +new myModule.c(); +>myModule.c : Symbol(myModule.c, Decl(index.ts, 0, 0)) +>myModule : Symbol(myModule, Decl(test.ts, 0, 0)) +>c : Symbol(myModule.c, Decl(index.ts, 0, 0)) + + +=== /foo/node_modules/myModule/index.ts === +export class c { } +>c : Symbol(c, Decl(index.ts, 0, 0)) + diff --git a/tests/baselines/reference/compositeWithNodeModulesSourceFile.types b/tests/baselines/reference/compositeWithNodeModulesSourceFile.types new file mode 100644 index 0000000000000..d34838ae88a09 --- /dev/null +++ b/tests/baselines/reference/compositeWithNodeModulesSourceFile.types @@ -0,0 +1,15 @@ +=== /foo/test.ts === +import myModule = require("myModule"); +>myModule : typeof myModule + +new myModule.c(); +>new myModule.c() : myModule.c +>myModule.c : typeof myModule.c +>myModule : typeof myModule +>c : typeof myModule.c + + +=== /foo/node_modules/myModule/index.ts === +export class c { } +>c : c + diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index 62239eca7b821..7abcf55b8e7cb 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -14,7 +14,9 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(30,9): error TS23 Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick' is not assignable to type 'T'. + 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'Pick' is not assignable to type 'T'. + 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. @@ -36,10 +38,14 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(135,5): error TS2 tests/cases/conformance/types/conditional/conditionalTypes1.ts(136,22): error TS2540: Cannot assign to 'id' because it is a read-only property. tests/cases/conformance/types/conditional/conditionalTypes1.ts(137,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2322: Type 'ZeroOf' is not assignable to type 'T'. - Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. - Type '0' is not assignable to type 'T'. - Type '"" | 0' is not assignable to type 'T'. - Type '""' is not assignable to type 'T'. + 'ZeroOf' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. + Type '0' is not assignable to type 'T'. + '0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + Type '"" | 0' is not assignable to type 'T'. + '"" | 0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + Type '""' is not assignable to type 'T'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf'. Type 'string | number' is not assignable to type 'ZeroOf'. Type 'string' is not assignable to type 'ZeroOf'. @@ -175,9 +181,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS x = y; // Error ~ !!! error TS2322: Type 'Pick' is not assignable to type 'T'. +!!! error TS2322: 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. x = z; // Error ~ !!! error TS2322: Type 'Pick' is not assignable to type 'T'. +!!! error TS2322: 'Pick' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; y = z; // Error ~ @@ -265,10 +273,14 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS x = y; // Error ~ !!! error TS2322: Type 'ZeroOf' is not assignable to type 'T'. -!!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. -!!! error TS2322: Type '0' is not assignable to type 'T'. -!!! error TS2322: Type '"" | 0' is not assignable to type 'T'. -!!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: 'ZeroOf' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. +!!! error TS2322: Type '0' is not assignable to type 'T'. +!!! error TS2322: '0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'T'. +!!! error TS2322: '"" | 0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. y = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'ZeroOf'. diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index ee7c10ada5891..f17a55dd61c6f 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -1,7 +1,9 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. Type 'A' is not assignable to type 'B'. + 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(19,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. Type 'A' is not assignable to type 'B'. + 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. @@ -19,6 +21,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS23 Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. Type 'A' is not assignable to type 'B'. + 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. @@ -49,6 +52,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 ~ !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. } function f2(a: Contravariant, b: Contravariant) { @@ -56,6 +60,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 ~ !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. b = a; } @@ -81,6 +86,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint '{}'. } // Extract is a T that is known to be a Function diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt index cc2c1e871e5ed..e326d163c8ced 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Types of property 'a2' are incompatible. Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts (2 errors) ==== @@ -86,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Types of property 'a2' are incompatible. !!! error TS2430: Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: new (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 1a9edc159af19..59d8105c59cc9 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type 'new (x: T) => U[]' is not assignable to type 'new (x: number) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(50,19): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a8' are incompatible. Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. @@ -30,6 +31,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. Type 'string[]' is not assignable to type 'T[]'. Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(95,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'. Types of property 'a2' are incompatible. Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. @@ -85,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => U[]' is not assignable to type 'new (x: number) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'T'. +!!! error TS2430: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic } @@ -161,6 +164,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. !!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => string[]; // error } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt index 6245fead91964..a2ea2c70c65ee 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt @@ -3,27 +3,32 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(28,11): error TS2430: Interface 'I2' incorrectly extends interface 'A'. Types of property 'a2' are incompatible. Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => string[]'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(32,11): error TS2430: Interface 'I3' incorrectly extends interface 'A'. Types of property 'a3' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new (x: T) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(36,11): error TS2430: Interface 'I4' incorrectly extends interface 'A'. Types of property 'a4' are incompatible. Type 'new (x: T, y: U) => string' is not assignable to type 'new (x: T, y: U) => string'. Types of parameters 'x' and 'x' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(40,11): error TS2430: Interface 'I5' incorrectly extends interface 'A'. Types of property 'a5' are incompatible. Type 'new (x: (arg: T) => U) => T' is not assignable to type 'new (x: (arg: T) => U) => T'. Types of parameters 'x' and 'x' are incompatible. Types of parameters 'arg' and 'arg' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(44,11): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a11' are incompatible. Type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base'. @@ -31,6 +36,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts(48,11): error TS2430: Interface 'I9' incorrectly extends interface 'A'. Types of property 'a16' are incompatible. Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. @@ -38,7 +44,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - Type 'Base' is not assignable to type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'Base' is not assignable to type 'T'. + 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts (7 errors) ==== @@ -72,6 +80,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => T[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new (x: T) => T[]; } @@ -82,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => string[]'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => string[]; } @@ -92,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T) => T' is not assignable to type 'new (x: T) => void'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new (x: T) => T; } @@ -102,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type 'new (x: T, y: U) => string' is not assignable to type 'new (x: T, y: U) => string'. !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new (x: T, y: U) => string; } @@ -113,6 +125,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Types of parameters 'x' and 'x' are incompatible. !!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new (x: (arg: T) => U) => T; } @@ -125,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type '{ foo: T; }' is not assignable to type '{ foo: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'foo' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; } @@ -137,6 +151,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: T; b: T; }'. Two different types with this name exist, but they are unrelated. !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: Type 'Base' is not assignable to type 'T'. +!!! error TS2430: 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a16: new (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt index 9cad967dd7727..38fadde8f5b99 100644 --- a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt +++ b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(3,17): error TS2322: Type '1' is not assignable to type 'string'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,17): error TS2322: Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,27): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(17,17): error TS2322: Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. ==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts (4 errors) ==== @@ -19,8 +22,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x: T = 1, public y: U = x) { // error ~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'T'. +!!! error TS2322: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var z = x; } } @@ -30,6 +35,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x: T = new Date()) { // error ~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. var y = x; } } \ No newline at end of file diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index 6d3644eabb035..499b31460b7dc 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,18): error TS2322: Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== @@ -39,6 +40,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class. ~ !!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. !!! related TS6500 tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts:24:5: The expected type comes from property 'x' which is declared here on type 'F' } } diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index df0b788459476..4e6f9f71c923e 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -105,9 +105,9 @@ >(...numbers) => numbers.every(n => n > 0) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean >numbers : [number, number, number] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >numbers : [number, number, number] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean @@ -123,9 +123,9 @@ >(...mixed) => mixed.every(n => !!n) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean >mixed : [number, string, string] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >mixed : [number, string, string] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >n => !!n : (n: string | number) => boolean >n : string | number >!!n : boolean @@ -141,9 +141,9 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : () => boolean >noNumbers : [] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >noNumbers : [] ->some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: never) => boolean >n : never >n > 0 : boolean diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types index e20c08a20debf..18ad0a1241f73 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.types +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -105,9 +105,9 @@ >(...numbers) => numbers.every(n => n > 0) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean >numbers : [number, number, number] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >numbers : [number, number, number] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean @@ -123,9 +123,9 @@ >(...mixed) => mixed.every(n => !!n) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean >mixed : [number, string, string] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >mixed : [number, string, string] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any) => boolean >n => !!n : (n: string | number) => boolean >n : string | number >!!n : boolean @@ -141,9 +141,9 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : () => boolean >noNumbers : [] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >noNumbers : [] ->some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>some : (callbackfn: (value: never, index: number, array: never[]) => unknown, thisArg?: any) => boolean >n => n > 0 : (n: never) => boolean >n : never >n > 0 : boolean diff --git a/tests/baselines/reference/convertKeywordsYes.errors.txt b/tests/baselines/reference/convertKeywordsYes.errors.txt index 7218e1fd12c66..e142e6de03d7f 100644 --- a/tests/baselines/reference/convertKeywordsYes.errors.txt +++ b/tests/baselines/reference/convertKeywordsYes.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/convertKeywordsYes.ts(175,12): error TS18006: Classes may not have a field named 'constructor'. tests/cases/compiler/convertKeywordsYes.ts(292,11): error TS1213: Identifier expected. 'implements' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/convertKeywordsYes.ts(293,11): error TS1213: Identifier expected. 'interface' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/convertKeywordsYes.ts(294,11): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode. @@ -9,7 +10,7 @@ tests/cases/compiler/convertKeywordsYes.ts(301,11): error TS1213: Identifier exp tests/cases/compiler/convertKeywordsYes.ts(303,11): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. -==== tests/cases/compiler/convertKeywordsYes.ts (9 errors) ==== +==== tests/cases/compiler/convertKeywordsYes.ts (10 errors) ==== // reserved ES5 future in strict mode var constructor = 0; @@ -185,6 +186,8 @@ tests/cases/compiler/convertKeywordsYes.ts(303,11): error TS1213: Identifier exp class bigClass { public "constructor" = 0; + ~~~~~~~~~~~~~ +!!! error TS18006: Classes may not have a field named 'constructor'. public any = 0; public boolean = 0; public implements = 0; diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index f545baeb443bb..56ff62f6e1d4e 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -26,14 +26,14 @@ export async function runSampleWorks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >el => !!el : (el: bluebird) => boolean >el : bluebird >!!el : boolean @@ -88,14 +88,14 @@ export async function runSampleBreaks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>[a, b, c, d, e].filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any): bluebird[]; } +>filter : { >(callbackfn: (value: bluebird, index: number, array: bluebird[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: bluebird, index: number, array: bluebird[]) => unknown, thisArg?: any): bluebird[]; } >el => !!el : (el: bluebird) => boolean >el : bluebird >!!el : boolean diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index 359fab212e909..e63849e4aa887 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -3,7 +3,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type '""' is not assignable to type 'T'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E' is not assignable to type 'C'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'number'. @@ -50,10 +52,12 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. foo(): T { return ''; // error ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. } } diff --git a/tests/baselines/reference/duplicateLocalVariable1.types b/tests/baselines/reference/duplicateLocalVariable1.types index 4a7dcb41919a7..9ad7673412e18 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.types +++ b/tests/baselines/reference/duplicateLocalVariable1.types @@ -41,9 +41,9 @@ export class TestRunner { return (arg1.every(function (val, index) { return val === arg2[index] })); >(arg1.every(function (val, index) { return val === arg2[index] })) : boolean >arg1.every(function (val, index) { return val === arg2[index] }) : boolean ->arg1.every : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>arg1.every : (callbackfn: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean >arg1 : any[] ->every : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>every : (callbackfn: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean >function (val, index) { return val === arg2[index] } : (val: any, index: number) => boolean >val : any >index : number diff --git a/tests/baselines/reference/enumAssignability.errors.txt b/tests/baselines/reference/enumAssignability.errors.txt index bfabb5eae8819..b582f9f8048ce 100644 --- a/tests/baselines/reference/enumAssignability.errors.txt +++ b/tests/baselines/reference/enumAssignability.errors.txt @@ -14,10 +14,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(43,9): error TS2322: Type 'E' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(45,9): error TS2322: Type 'E' is not assignable to type 'String'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(48,9): error TS2322: Type 'E' is not assignable to type 'T'. + 'E' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(49,9): error TS2322: Type 'E' is not assignable to type 'U'. + 'E' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(50,9): error TS2322: Type 'E' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(51,13): error TS2322: Type 'E' is not assignable to type 'A'. + 'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(52,13): error TS2322: Type 'E' is not assignable to type 'B'. + 'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts (20 errors) ==== @@ -101,17 +105,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi x = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'T'. +!!! error TS2322: 'E' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'U'. +!!! error TS2322: 'E' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. z = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'V'. var a: A = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'A'. +!!! error TS2322: 'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'. var b: B = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'B'. +!!! error TS2322: 'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'. } } \ No newline at end of file diff --git a/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt b/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt index e2b18aa2fc35a..6cfeeb8aeb816 100644 --- a/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt +++ b/tests/baselines/reference/errorElaborationDivesIntoApparentlyPresentPropsOnly.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(2,5): error TS2322: Type '{ a: string; b: number; c: number; }' is not assignable to type 'T'. tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(6,5): error TS2322: Type '{ a: number; }' is not assignable to type 'T'. tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(10,5): error TS2322: Type '{ a: string; }' is not assignable to type 'T'. + '{ a: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ a: string; }'. ==== tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts (3 errors) ==== @@ -20,5 +21,6 @@ tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts(10,5 x = { a: "not ok" }; ~ !!! error TS2322: Type '{ a: string; }' is not assignable to type 'T'. +!!! error TS2322: '{ a: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ a: string; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt b/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt index e37ff82aa7b54..2ca7218764a00 100644 --- a/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt +++ b/tests/baselines/reference/errorMessagesIntersectionTypes03.errors.txt @@ -1,6 +1,9 @@ tests/cases/compiler/errorMessagesIntersectionTypes03.ts(17,5): error TS2322: Type 'A & B' is not assignable to type 'T'. + 'A & B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(18,5): error TS2322: Type 'A & B' is not assignable to type 'U'. + 'A & B' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(19,5): error TS2322: Type 'A & B' is not assignable to type 'V'. + 'A & B' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'A'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(22,5): error TS2322: Type 'T & B' is not assignable to type 'U'. tests/cases/compiler/errorMessagesIntersectionTypes03.ts(23,5): error TS2322: Type 'T & B' is not assignable to type 'V'. @@ -25,12 +28,15 @@ tests/cases/compiler/errorMessagesIntersectionTypes03.ts(23,5): error TS2322: Ty t = a_and_b; ~ !!! error TS2322: Type 'A & B' is not assignable to type 'T'. +!!! error TS2322: 'A & B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = a_and_b; ~ !!! error TS2322: Type 'A & B' is not assignable to type 'U'. +!!! error TS2322: 'A & B' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'A'. v = a_and_b; ~ !!! error TS2322: Type 'A & B' is not assignable to type 'V'. +!!! error TS2322: 'A & B' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'A'. t = t_and_b; u = t_and_b; diff --git a/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt b/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt index 33d06763bbea2..732235157224d 100644 --- a/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt +++ b/tests/baselines/reference/functionTypeArgumentAssignmentCompat.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts(9,1): error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. Type 'unknown[]' is not assignable to type 'T'. + 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts (1 errors) ==== @@ -15,6 +16,7 @@ tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts(9,1): error TS2322: ~ !!! error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. !!! error TS2322: Type 'unknown[]' is not assignable to type 'T'. +!!! error TS2322: 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var s = f("str").toUpperCase(); console.log(s); diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt index ca3e195a8a762..16f2e47a1b951 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt @@ -3,12 +3,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,24): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. Type 'string' is not assignable to type '1'. @@ -51,6 +54,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r10 = foo2(1, (x) => ''); // string var r11 = foo3(1, (x: T) => '', ''); // error @@ -58,11 +62,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r11b = foo3(1, (x: T) => '', 1); // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r12 = foo3(1, function (a) { return '' }, 1); // error ~~~~~~~~ !!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types index 1cd9e7ccd111f..9699261a641fb 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types @@ -78,15 +78,15 @@ var r4 = foo2(1, i2); // error >i2 : I2 var r4b = foo2(1, a); // any ->r4b : unknown ->foo2(1, a) : unknown +>r4b : number +>foo2(1, a) : number >foo2 : (x: T, cb: new (a: T) => U) => U >1 : 1 >a : new (x: T) => T var r5 = foo2(1, i); // any ->r5 : unknown ->foo2(1, i) : unknown +>r5 : number +>foo2(1, i) : number >foo2 : (x: T, cb: new (a: T) => U) => U >1 : 1 >i : I @@ -112,16 +112,16 @@ function foo3(x: T, cb: new(a: T) => U, y: U) { } var r7 = foo3(null, i, ''); // any ->r7 : unknown ->foo3(null, i, '') : unknown +>r7 : any +>foo3(null, i, '') : any >foo3 : (x: T, cb: new (a: T) => U, y: U) => U >null : null >i : I >'' : "" var r7b = foo3(null, a, ''); // any ->r7b : unknown ->foo3(null, a, '') : unknown +>r7b : any +>foo3(null, a, '') : any >foo3 : (x: T, cb: new (a: T) => U, y: U) => U >null : null >a : new (x: T) => T diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index a66672f515131..c308e16c224c0 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -2,12 +2,14 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,43): error TS2322: Type 'F' is not assignable to type 'E'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(50,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(60,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. @@ -38,6 +40,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen var r9 = r7(new Date()); // should be ok ~~~~~~~~~~ !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. +!!! error TS2345: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. var r10 = r7(1); // error ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. @@ -84,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen var r9 = r7(new Date()); ~~~~~~~~~~ !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. +!!! error TS2345: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. var r10 = r7(1); ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt index 08b5dbc177136..1f4db6be557b7 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts(19,17): error TS2345: Argument of type 'C' is not assignable to parameter of type 'D'. Property 'y' is missing in type 'C' but required in type 'D'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts(30,24): error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts (2 errors) ==== @@ -40,6 +41,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var r5 = foo(c, d); // error ~ !!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. +!!! error TS2345: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt index 0fd0f98209aa9..df3b228bf059d 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(19,23): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'. Type 'void' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(22,24): error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. + 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts (3 errors) ==== @@ -37,5 +38,6 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var r5 = foo(c, d); // error ~ !!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. +!!! error TS2345: 'C' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt index b65b21e127b43..1e3e2466ed3f0 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt @@ -1,7 +1,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(6,37): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(8,56): error TS2322: Type 'U' is not assignable to type 'V'. - Type 'T' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'V'. + 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts (3 errors) ==== @@ -12,12 +16,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC function foo3(x: T = 1) { } // error ~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'T'. +!!! error TS2322: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. function foo4(x: T, y: U = x) { } // error ~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. function foo5(x: U, y: T = x) { } // ok function foo6(x: T, y: U, z: V = y) { } // error ~~~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'V'. -!!! error TS2322: Type 'T' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'V'. +!!! error TS2322: 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. function foo7(x: V, y: U = x) { } // should be ok \ No newline at end of file diff --git a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt index ff4c2235b4925..26f97751caaf8 100644 --- a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt +++ b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt @@ -1,9 +1,11 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(2,16): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(3,16): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(4,16): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(8,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(9,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(12,17): error TS2345: Argument of type 'U' is not assignable to parameter of type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(13,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17): error TS2558: Expected 0 type arguments, but got 1. @@ -16,6 +18,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17 var r2 = f(1); ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r3 = f(null); ~~~ !!! error TS2558: Expected 0 type arguments, but got 1. @@ -33,6 +36,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17 var r12 = f(y); ~ !!! error TS2345: Argument of type 'U' is not assignable to parameter of type 'T'. +!!! error TS2345: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r22 = f(y); ~~~~~~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt index c44a1e155ac54..5366fbc9aeb32 100644 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt @@ -1,12 +1,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,29): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,30): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,31): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type '1' is not assignable to type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,30): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. Type 'string' is not assignable to type '1'. @@ -73,6 +76,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r10 = c.foo2(1, (x) => ''); // string var r11 = c3.foo3(1, (x: T) => '', ''); // error @@ -80,11 +84,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r11b = c3.foo3(1, (x: T) => '', 1); // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type '1' is not assignable to type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r12 = c3.foo3(1, function (a) { return '' }, 1); // error ~~~~~~~~ !!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. diff --git a/tests/baselines/reference/genericContextualTypes1.types b/tests/baselines/reference/genericContextualTypes1.types index fb97b190d659e..e52f26e73d919 100644 --- a/tests/baselines/reference/genericContextualTypes1.types +++ b/tests/baselines/reference/genericContextualTypes1.types @@ -155,9 +155,9 @@ const arrayFilter = (f: (x: T) => boolean) => (a: T[]) => a.filter(f); >(a: T[]) => a.filter(f) : (a: T[]) => T[] >a : T[] >a.filter(f) : T[] ->a.filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; } +>a.filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; } >a : T[] ->filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; } +>filter : { (callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; } >f : (x: T) => boolean const f20: (a: string[]) => number[] = arrayMap(x => x.length); diff --git a/tests/baselines/reference/genericDefaultsErrors.errors.txt b/tests/baselines/reference/genericDefaultsErrors.errors.txt index e1dca77d958d0..91d4d608f1aef 100644 --- a/tests/baselines/reference/genericDefaultsErrors.errors.txt +++ b/tests/baselines/reference/genericDefaultsErrors.errors.txt @@ -3,6 +3,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(4,59): error TS2344: Type 'T' does Type 'string' is not assignable to type 'number'. tests/cases/compiler/genericDefaultsErrors.ts(5,44): error TS2344: Type 'T' does not satisfy the constraint 'number'. tests/cases/compiler/genericDefaultsErrors.ts(6,39): error TS2344: Type 'number' does not satisfy the constraint 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericDefaultsErrors.ts(10,5): error TS2558: Expected 2-3 type arguments, but got 1. tests/cases/compiler/genericDefaultsErrors.ts(13,5): error TS2558: Expected 2-3 type arguments, but got 4. tests/cases/compiler/genericDefaultsErrors.ts(17,13): error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'. @@ -16,6 +17,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(27,52): error TS2344: Type 'T' doe Type 'string' is not assignable to type 'number'. tests/cases/compiler/genericDefaultsErrors.ts(28,37): error TS2344: Type 'T' does not satisfy the constraint 'number'. tests/cases/compiler/genericDefaultsErrors.ts(29,32): error TS2344: Type 'number' does not satisfy the constraint 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/genericDefaultsErrors.ts(32,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. tests/cases/compiler/genericDefaultsErrors.ts(33,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. tests/cases/compiler/genericDefaultsErrors.ts(36,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. @@ -40,6 +42,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet declare function f06(): void; // error ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'T'. +!!! error TS2344: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. declare function f11(): void; f11(); // ok @@ -88,6 +91,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet interface i08 { } // error ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'T'. +!!! error TS2344: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. interface i09 { } type i09t00 = i09; // error diff --git a/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt b/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt index 4f24a4560235e..4c15da868c5ac 100644 --- a/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt +++ b/tests/baselines/reference/genericFunctionCallSignatureReturnTypeMismatch.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts(6,1): error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. Type 'unknown[]' is not assignable to type 'T'. + 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts (1 errors) ==== @@ -12,6 +13,7 @@ tests/cases/compiler/genericFunctionCallSignatureReturnTypeMismatch.ts(6,1): err ~ !!! error TS2322: Type '() => S[]' is not assignable to type '(x: T) => T'. !!! error TS2322: Type 'unknown[]' is not assignable to type 'T'. +!!! error TS2322: 'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var s = f("str").toUpperCase(); diff --git a/tests/baselines/reference/genericFunctionInference1.errors.txt b/tests/baselines/reference/genericFunctionInference1.errors.txt index 7fcbc93ea0dca..5c910e7ff5d26 100644 --- a/tests/baselines/reference/genericFunctionInference1.errors.txt +++ b/tests/baselines/reference/genericFunctionInference1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. +tests/cases/compiler/genericFunctionInference1.ts(135,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. Type 'number' is not assignable to type 'string'. @@ -67,6 +67,53 @@ tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument let f60 = wrap3(baz); + declare const list2: { + (a: T): T[]; + foo: string; + bar(): number; + } + + let f70 = pipe(list2, box); + let f71 = pipe(box, list2); + + declare class Point { + constructor(x: number, y: number); + readonly x: number; + readonly y: number; + } + + declare class Bag { + constructor(...args: T[]); + contains(value: T): boolean; + static foo: string; + } + + function asFunction(cf: new (...args: A) => B) { + return (...args: A) => new cf(...args); + } + + const newPoint = asFunction(Point); + const newBag = asFunction(Bag); + const p1 = new Point(10, 20); + const p2 = newPoint(10, 20); + const bag1 = new Bag(1, 2, 3); + const bag2 = newBag('a', 'b', 'c'); + + declare class Comp

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

= new (props: P) => Comp

; + + declare function myHoc

(C: CompClass

): CompClass

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

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

= new (props: P) => Comp

; + +declare function myHoc

(C: CompClass

): CompClass

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

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

= new (props: P) => Comp

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

(C: CompClass

): CompClass

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

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

(C: Component

) => Component

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

(C: Component

) => Component

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

{ +>Comp : Comp

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

= new (props: P) => Comp

; +>CompClass : CompClass

+>props : P + +declare function myHoc

(C: CompClass

): CompClass

; +>myHoc :

(C: CompClass

) => CompClass

+>C : CompClass

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

(C: CompClass

) => CompClass

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

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

'. diff --git a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt index a162b997c0f6d..2781d2fcee524 100644 --- a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt +++ b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(2,15): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(3,15): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): error TS2558: Expected 0 type arguments, but got 1. @@ -11,6 +12,7 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): erro var r2 = f(1); ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. +!!! error TS2345: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. var r3 = f(null); ~~~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/typeGuardBoolean.js b/tests/baselines/reference/typeGuardBoolean.js new file mode 100644 index 0000000000000..1bfe41983d83b --- /dev/null +++ b/tests/baselines/reference/typeGuardBoolean.js @@ -0,0 +1,30 @@ +//// [typeGuardBoolean.ts] +function test(strOrNull: string | null, strOrUndefined: string | undefined) { + var str: string = "original"; + var nil: null; + if (!Boolean(strOrNull)) { + nil = strOrNull; + } + else { + str = strOrNull; + } + if (Boolean(strOrUndefined)) { + str = strOrUndefined; + } +} + + +//// [typeGuardBoolean.js] +function test(strOrNull, strOrUndefined) { + var str = "original"; + var nil; + if (!Boolean(strOrNull)) { + nil = strOrNull; + } + else { + str = strOrNull; + } + if (Boolean(strOrUndefined)) { + str = strOrUndefined; + } +} diff --git a/tests/baselines/reference/typeGuardBoolean.symbols b/tests/baselines/reference/typeGuardBoolean.symbols new file mode 100644 index 0000000000000..6a08dcbda8a06 --- /dev/null +++ b/tests/baselines/reference/typeGuardBoolean.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts === +function test(strOrNull: string | null, strOrUndefined: string | undefined) { +>test : Symbol(test, Decl(typeGuardBoolean.ts, 0, 0)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) +>strOrUndefined : Symbol(strOrUndefined, Decl(typeGuardBoolean.ts, 0, 39)) + + var str: string = "original"; +>str : Symbol(str, Decl(typeGuardBoolean.ts, 1, 5)) + + var nil: null; +>nil : Symbol(nil, Decl(typeGuardBoolean.ts, 2, 5)) + + if (!Boolean(strOrNull)) { +>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) + + nil = strOrNull; +>nil : Symbol(nil, Decl(typeGuardBoolean.ts, 2, 5)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) + } + else { + str = strOrNull; +>str : Symbol(str, Decl(typeGuardBoolean.ts, 1, 5)) +>strOrNull : Symbol(strOrNull, Decl(typeGuardBoolean.ts, 0, 14)) + } + if (Boolean(strOrUndefined)) { +>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>strOrUndefined : Symbol(strOrUndefined, Decl(typeGuardBoolean.ts, 0, 39)) + + str = strOrUndefined; +>str : Symbol(str, Decl(typeGuardBoolean.ts, 1, 5)) +>strOrUndefined : Symbol(strOrUndefined, Decl(typeGuardBoolean.ts, 0, 39)) + } +} + diff --git a/tests/baselines/reference/typeGuardBoolean.types b/tests/baselines/reference/typeGuardBoolean.types new file mode 100644 index 0000000000000..db3d6f39cd841 --- /dev/null +++ b/tests/baselines/reference/typeGuardBoolean.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardBoolean.ts === +function test(strOrNull: string | null, strOrUndefined: string | undefined) { +>test : (strOrNull: string | null, strOrUndefined: string | undefined) => void +>strOrNull : string | null +>null : null +>strOrUndefined : string | undefined + + var str: string = "original"; +>str : string +>"original" : "original" + + var nil: null; +>nil : null +>null : null + + if (!Boolean(strOrNull)) { +>!Boolean(strOrNull) : boolean +>Boolean(strOrNull) : boolean +>Boolean : BooleanConstructor +>strOrNull : string | null + + nil = strOrNull; +>nil = strOrNull : null +>nil : null +>strOrNull : null + } + else { + str = strOrNull; +>str = strOrNull : string +>str : string +>strOrNull : string + } + if (Boolean(strOrUndefined)) { +>Boolean(strOrUndefined) : boolean +>Boolean : BooleanConstructor +>strOrUndefined : string | undefined + + str = strOrUndefined; +>str = strOrUndefined : string +>str : string +>strOrUndefined : string + } +} + diff --git a/tests/baselines/reference/typeInferenceTypePredicate2.types b/tests/baselines/reference/typeInferenceTypePredicate2.types index d0f36101e1243..a0c05e4a4d0ee 100644 --- a/tests/baselines/reference/typeInferenceTypePredicate2.types +++ b/tests/baselines/reference/typeInferenceTypePredicate2.types @@ -3,7 +3,7 @@ >[true, true, false, null] .filter((thing): thing is boolean => thing !== null) .map(thing => thing.toString()) : string[] >[true, true, false, null] .filter((thing): thing is boolean => thing !== null) .map : (callbackfn: (value: boolean, index: number, array: boolean[]) => U, thisArg?: any) => U[] >[true, true, false, null] .filter((thing): thing is boolean => thing !== null) : boolean[] ->[true, true, false, null] .filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => any, thisArg?: any): boolean[]; } +>[true, true, false, null] .filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => unknown, thisArg?: any): boolean[]; } >[true, true, false, null] : boolean[] >true : true >true : true @@ -11,7 +11,7 @@ >null : null .filter((thing): thing is boolean => thing !== null) ->filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => any, thisArg?: any): boolean[]; } +>filter : { (callbackfn: (value: boolean, index: number, array: boolean[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: boolean, index: number, array: boolean[]) => unknown, thisArg?: any): boolean[]; } >(thing): thing is boolean => thing !== null : (thing: boolean) => thing is boolean >thing : boolean >thing !== null : boolean diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt index 39e6db64fbf3c..f0360609a575b 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/typeParameterArgumentEquivalence.ts(4,5): error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: number) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'number' is not assignable to type 'T'. + 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence.ts(5,5): error TS2322: Type '(item: number) => boolean' is not assignable to type '(item: T) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'T' is not assignable to type 'number'. @@ -15,6 +16,7 @@ tests/cases/compiler/typeParameterArgumentEquivalence.ts(5,5): error TS2322: Typ !!! error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: number) => boolean'. !!! error TS2322: Types of parameters 'item' and 'item' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: number) => boolean' is not assignable to type '(item: T) => boolean'. diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt index 17fce0384f780..d1727b53863ca 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt @@ -1,9 +1,11 @@ tests/cases/compiler/typeParameterArgumentEquivalence2.ts(4,5): error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: U) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence2.ts(5,5): error TS2322: Type '(item: U) => boolean' is not assignable to type '(item: T) => boolean'. Types of parameters 'item' and 'item' are incompatible. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterArgumentEquivalence2.ts (2 errors) ==== @@ -15,10 +17,12 @@ tests/cases/compiler/typeParameterArgumentEquivalence2.ts(5,5): error TS2322: Ty !!! error TS2322: Type '(item: T) => boolean' is not assignable to type '(item: U) => boolean'. !!! error TS2322: Types of parameters 'item' and 'item' are incompatible. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: U) => boolean' is not assignable to type '(item: T) => boolean'. !!! error TS2322: Types of parameters 'item' and 'item' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt index 1f126d7c00daa..c361a276b9622 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeParameterArgumentEquivalence3.ts(4,5): error TS2322: Type '(item: any) => boolean' is not assignable to type '(item: any) => T'. Type 'boolean' is not assignable to type 'T'. + 'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence3.ts(5,5): error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => boolean'. Type 'T' is not assignable to type 'boolean'. @@ -12,6 +13,7 @@ tests/cases/compiler/typeParameterArgumentEquivalence3.ts(5,5): error TS2322: Ty ~ !!! error TS2322: Type '(item: any) => boolean' is not assignable to type '(item: any) => T'. !!! error TS2322: Type 'boolean' is not assignable to type 'T'. +!!! error TS2322: 'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => boolean'. diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt index c7b19e8725c70..ce194146f6ca9 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt @@ -1,7 +1,9 @@ tests/cases/compiler/typeParameterArgumentEquivalence4.ts(4,5): error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence4.ts(5,5): error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterArgumentEquivalence4.ts (2 errors) ==== @@ -12,9 +14,11 @@ tests/cases/compiler/typeParameterArgumentEquivalence4.ts(5,5): error TS2322: Ty ~ !!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt index 82290733a9e0f..e5196d3d4a50d 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt @@ -1,9 +1,11 @@ tests/cases/compiler/typeParameterArgumentEquivalence5.ts(4,5): error TS2322: Type '() => (item: any) => T' is not assignable to type '() => (item: any) => U'. Type '(item: any) => T' is not assignable to type '(item: any) => U'. Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterArgumentEquivalence5.ts(5,5): error TS2322: Type '() => (item: any) => U' is not assignable to type '() => (item: any) => T'. Type '(item: any) => U' is not assignable to type '(item: any) => T'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterArgumentEquivalence5.ts (2 errors) ==== @@ -15,10 +17,12 @@ tests/cases/compiler/typeParameterArgumentEquivalence5.ts(5,5): error TS2322: Ty !!! error TS2322: Type '() => (item: any) => T' is not assignable to type '() => (item: any) => U'. !!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'. !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. y = x; // Shound be an error ~ !!! error TS2322: Type '() => (item: any) => U' is not assignable to type '() => (item: any) => T'. !!! error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability.errors.txt b/tests/baselines/reference/typeParameterAssignability.errors.txt index 0e8546097d0c3..0bab4a4c74c69 100644 --- a/tests/baselines/reference/typeParameterAssignability.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability.errors.txt @@ -1,5 +1,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts(5,5): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts (2 errors) ==== @@ -9,7 +11,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index 9d32aed12328d..776649105b40e 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -1,33 +1,63 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(5,5): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(9,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(17,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(20,5): error TS2322: Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(25,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(26,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(27,5): error TS2322: Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(30,5): error TS2322: Type 'V' is not assignable to type 'U'. - Type 'Date' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(31,5): error TS2322: Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(35,5): error TS2322: Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(45,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(46,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(47,5): error TS2322: Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(50,5): error TS2322: Type 'V' is not assignable to type 'U'. - Type 'Date' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(51,5): error TS2322: Type 'Date' is not assignable to type 'U'. + 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(55,5): error TS2322: Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(64,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(65,5): error TS2322: Type 'V' is not assignable to type 'T'. + 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(68,5): error TS2322: Type 'V' is not assignable to type 'U'. + 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(70,5): error TS2322: Type 'T' is not assignable to type 'V'. - Type 'U' is not assignable to type 'V'. + 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'U' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(71,5): error TS2322: Type 'U' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts (22 errors) ==== @@ -38,12 +68,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara u = t; // ok ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } function foo2(t: T, u: U) { t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // ok } @@ -51,17 +83,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. v = t; // ok u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. v = u; // ok } @@ -69,29 +105,38 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. u = t; u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. -!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. v = t; v = u; v = new Date(); // ok ~ !!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. var d: Date; d = t; // ok @@ -104,29 +149,38 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. u = t; u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. -!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. v = t; v = u; v = new Date(); // ok ~ !!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. var d: Date; d = t; // ok @@ -138,20 +192,26 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // ok u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. v = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. -!!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. v = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability3.errors.txt b/tests/baselines/reference/typeParameterAssignability3.errors.txt index ca7850d747e40..52091c02b8f72 100644 --- a/tests/baselines/reference/typeParameterAssignability3.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability3.errors.txt @@ -1,11 +1,19 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'T'. + 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(15,5): error TS2322: Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'U'. + 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(22,9): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'T'. + 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. + Type 'Foo' is not assignable to type 'U'. + 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts (4 errors) ==== @@ -25,11 +33,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. } class C { @@ -39,10 +51,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara this.t = this.u; // error ~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'T'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. this.u = this.t; // error ~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. +!!! error TS2322: Type 'Foo' is not assignable to type 'U'. +!!! error TS2322: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt index 2ca4299c7f8d6..dfef4d192689c 100644 --- a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt +++ b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(8,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(16,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. @@ -17,6 +18,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type ~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. return x; ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. diff --git a/tests/baselines/reference/typeParameterDiamond2.errors.txt b/tests/baselines/reference/typeParameterDiamond2.errors.txt index f268724c6efaa..eecfac811275d 100644 --- a/tests/baselines/reference/typeParameterDiamond2.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond2.errors.txt @@ -1,8 +1,13 @@ tests/cases/compiler/typeParameterDiamond2.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'. - Type 'U' is not assignable to type 'Top'. -tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. - Type 'T | U' is not assignable to type 'Top'. + 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. Type 'U' is not assignable to type 'Top'. + 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. + 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T | U' is not assignable to type 'Top'. + 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'U' is not assignable to type 'Top'. + 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterDiamond2.ts (2 errors) ==== @@ -16,13 +21,18 @@ tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom top = middle; ~~~ !!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. middle = bottom; top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. -!!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T | U' is not assignable to type 'Top'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'Top'. +!!! error TS2322: 'U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond3.errors.txt b/tests/baselines/reference/typeParameterDiamond3.errors.txt index 14d5e4a313aac..15abd9973d17e 100644 --- a/tests/baselines/reference/typeParameterDiamond3.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond3.errors.txt @@ -1,15 +1,24 @@ tests/cases/compiler/typeParameterDiamond3.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'. - Type 'T' is not assignable to type 'Top'. + 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterDiamond3.ts(9,13): error TS2322: Type 'Bottom' is not assignable to type 'T | U'. Type 'Top | T | U' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'U'. - Type 'Bottom' is not assignable to type 'U'. - Type 'Top | T | U' is not assignable to type 'U'. - Type 'Top' is not assignable to type 'U'. + 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'Bottom' is not assignable to type 'U'. + 'Bottom' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'Top | T | U' is not assignable to type 'U'. + 'Top | T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'Top' is not assignable to type 'U'. + 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. - Type 'Top | T | U' is not assignable to type 'Top'. - Type 'T' is not assignable to type 'Top'. + 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'Top | T | U' is not assignable to type 'Top'. + 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterDiamond3.ts (3 errors) ==== @@ -23,21 +32,30 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom top = middle; ~~~ !!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. middle = bottom; ~~~~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top | T | U' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'U'. -!!! error TS2322: Type 'Bottom' is not assignable to type 'U'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'. -!!! error TS2322: Type 'Top' is not assignable to type 'U'. +!!! error TS2322: 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Bottom' is not assignable to type 'U'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top' is not assignable to type 'U'. +!!! error TS2322: 'Top' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond4.errors.txt b/tests/baselines/reference/typeParameterDiamond4.errors.txt index 2a7fbdaf15c9f..e135515389232 100644 --- a/tests/baselines/reference/typeParameterDiamond4.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond4.errors.txt @@ -1,8 +1,13 @@ tests/cases/compiler/typeParameterDiamond4.ts(8,13): error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. - Type 'T' is not assignable to type 'Top'. -tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. - Type 'Top | T | U' is not assignable to type 'Top'. + 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. + 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'Top | T | U' is not assignable to type 'Top'. + 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'Top'. + 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/compiler/typeParameterDiamond4.ts (2 errors) ==== @@ -16,13 +21,18 @@ tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom top = middle; ~~~ !!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. middle = bottom; top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'Bottom' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. +!!! error TS2322: 'Top | T | U' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'Top'. +!!! error TS2322: 'T' is assignable to the constraint of type 'Top', but 'Top' could be instantiated with a different subtype of constraint '{}'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt index b5c9fd60206fc..30f71cdfeba1b 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt @@ -1,6 +1,8 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? ==== tests/cases/compiler/typeParametersShouldNotBeEqual.ts (2 errors) ==== @@ -10,10 +12,12 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type x = y; // Error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. x = z; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? z = x; // Ok } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt index d452b99798094..5d04f500fd691 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -1,11 +1,17 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + Type 'Date' is not assignable to type 'T'. + 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(5,5): error TS2322: Type 'V' is not assignable to type 'T'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(6,5): error TS2322: Type 'T' is not assignable to type 'V'. - Type 'Date' is not assignable to type 'V'. + 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(7,5): error TS2322: Type 'V' is not assignable to type 'U'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(8,5): error TS2322: Type 'U' is not assignable to type 'V'. - Type 'Date' is not assignable to type 'V'. + 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. + Type 'Date' is not assignable to type 'V'. + 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type 'Object' is not assignable to type 'T'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? @@ -17,21 +23,27 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type x = y; // Ok ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. x = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. z = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. -!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'T' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. y = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. z = y; // Error ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. -!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'U' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'Date' is not assignable to type 'V'. +!!! error TS2322: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. x = zz; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt index 816db440a4c6d..fcc9c0d3c8786 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt @@ -1,8 +1,11 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. - Type 'Object' is not assignable to type 'T'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. + Type 'Object' is not assignable to type 'T'. + 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. + The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. + The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? ==== tests/cases/compiler/typeParametersShouldNotBeEqual3.ts (2 errors) ==== @@ -12,12 +15,15 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type x = y; // Ok ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. +!!! error TS2322: Type 'Object' is not assignable to type 'T'. +!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. +!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? x = z; // Ok ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. +!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? z = x; // Ok } \ No newline at end of file diff --git a/tests/baselines/reference/typeRelationships.errors.txt b/tests/baselines/reference/typeRelationships.errors.txt index 36f127224022d..6176fc84d2cfb 100644 --- a/tests/baselines/reference/typeRelationships.errors.txt +++ b/tests/baselines/reference/typeRelationships.errors.txt @@ -1,6 +1,8 @@ tests/cases/conformance/types/thisType/typeRelationships.ts(9,9): error TS2322: Type 'C' is not assignable to type 'this'. + 'C' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'C'. tests/cases/conformance/types/thisType/typeRelationships.ts(35,9): error TS2739: Type 'C' is missing the following properties from type 'D': self1, self2, self3, d, bar tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: Type 'D' is not assignable to type 'this'. + 'D' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'D'. ==== tests/cases/conformance/types/thisType/typeRelationships.ts (3 errors) ==== @@ -15,6 +17,7 @@ tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: this.self = this.c; // Error ~~~~~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'this'. +!!! error TS2322: 'C' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'C'. } f2() { var a: C[]; @@ -46,6 +49,7 @@ tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: this.self = this.d; // Error ~~~~~~~~~ !!! error TS2322: Type 'D' is not assignable to type 'this'. +!!! error TS2322: 'D' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'D'. this.c = this.d; } } diff --git a/tests/baselines/reference/unionTypesAssignability.errors.txt b/tests/baselines/reference/unionTypesAssignability.errors.txt index b74bbbd4e08ac..5affcf89ea57c 100644 --- a/tests/baselines/reference/unionTypesAssignability.errors.txt +++ b/tests/baselines/reference/unionTypesAssignability.errors.txt @@ -19,11 +19,17 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(41,1): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(43,1): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(64,5): error TS2322: Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(65,5): error TS2322: Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(70,5): error TS2322: Type 'T | U' is not assignable to type 'T'. - Type 'U' is not assignable to type 'T'. + 'T | U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + Type 'U' is not assignable to type 'T'. + 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(71,5): error TS2322: Type 'T | U' is not assignable to type 'U'. - Type 'T' is not assignable to type 'U'. + 'T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + Type 'T' is not assignable to type 'U'. + 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts (19 errors) ==== @@ -132,9 +138,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. var x : T | U; x = t; // ok x = u; // ok @@ -142,10 +150,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp t = x; // error U not assignable to T ~ !!! error TS2322: Type 'T | U' is not assignable to type 'T'. -!!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. u = x; // error T not assignable to U ~ !!! error TS2322: Type 'T | U' is not assignable to type 'U'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T | U' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. } \ No newline at end of file diff --git a/tests/baselines/reference/unknownSymbolOffContextualType1.types b/tests/baselines/reference/unknownSymbolOffContextualType1.types index 04321b94dadd8..8ad87586580ff 100644 --- a/tests/baselines/reference/unknownSymbolOffContextualType1.types +++ b/tests/baselines/reference/unknownSymbolOffContextualType1.types @@ -35,9 +35,9 @@ function getMaxWidth(elementNames: string[]) { var enabled = elements.filter(function (e) { >enabled : HTMLElement[] >elements.filter(function (e) { return !e.isDisabled; }) : HTMLElement[] ->elements.filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any): HTMLElement[]; } +>elements.filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => unknown, thisArg?: any): HTMLElement[]; } >elements : HTMLElement[] ->filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any): HTMLElement[]; } +>filter : { (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => unknown, thisArg?: any): HTMLElement[]; } >function (e) { return !e.isDisabled; } : (e: HTMLElement) => boolean >e : HTMLElement diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 45ba3fc971a56..4fd3354a2bbbc 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -698,6 +698,13 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10092,16): error TS2304: Cannot find name 'd41d8cd98f00b204e9800998ecf8427e_LibraryDetectorTests'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10513,19): error TS2488: Type 'NodeListOf' must have a '[Symbol.iterator]()' method that returns an iterator. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10811,19): error TS2304: Cannot find name 'getElementsInDocument'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11441,1): error TS2322: Type 'unknown' is not assignable to type 'number'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11444,1): error TS2322: Type 'unknown' is not assignable to type 'number'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11447,15): error TS2339: Property 'textLength' does not exist on type 'unknown'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11447,28): error TS2339: Property 'textLength' does not exist on type 'unknown'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11450,43): error TS2339: Property 'node' does not exist on type 'unknown'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11453,6): error TS2339: Property 'cssRule' does not exist on type 'unknown'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11460,6): error TS2339: Property 'cssRule' does not exist on type 'unknown'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12197,34): error TS2554: Expected 0 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12327,36): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(13607,7): error TS2339: Property 'protocolMethod' does not exist on type 'Error'. @@ -3090,11 +3097,14 @@ node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(60 Types of parameters 'debuggerModel' and 'model' are incompatible. Type 'T' is not assignable to type 'DebuggerModel'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(97,56): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(122,22): error TS2339: Property 'remove' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(153,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(158,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(166,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(181,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(183,45): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(237,46): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(300,73): error TS2339: Property 'valuesArray' does not exist on type 'Map>'. @@ -3104,6 +3114,7 @@ node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(33 node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(350,58): error TS2339: Property 'keysArray' does not exist on type 'Map>>'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(396,17): error TS2339: Property 'remove' does not exist on type 'Breakpoint[]'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(399,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(442,23): error TS2339: Property 'remove' does not exist on type 'Breakpoint[]'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(444,23): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(446,19): error TS2339: Property 'remove' does not exist on type 'Map>'. @@ -3140,17 +3151,25 @@ node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js( node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(132,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(160,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(169,27): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. + 'CSSStyleSheetHeader' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(172,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(182,48): error TS2345: Argument of type 'LiveLocation' is not assignable to parameter of type 'V'. + 'LiveLocation' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(184,37): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(191,46): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. + 'CSSStyleSheetHeader' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(196,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(204,16): error TS2339: Property '_header' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(205,27): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. + 'CSSStyleSheetHeader' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(206,16): error TS2339: Property 'update' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(212,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(216,46): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. + 'CSSStyleSheetHeader' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(221,31): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. + 'CSSStyleSheetHeader' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(261,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/CompilerScriptMapping.js(184,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/CompilerScriptMapping.js(194,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -3178,8 +3197,11 @@ node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBindin node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(230,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(267,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(276,25): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. + 'Script' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(285,28): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. + 'Script' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(292,46): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. + 'Script' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(349,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(389,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(452,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -3367,7 +3389,7 @@ node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2765,22): error node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2785,91): error TS2339: Property 'xRel' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2855,32): error TS2339: Property 'left' does not exist on type 'never'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2855,49): error TS2339: Property 'right' does not exist on type 'never'. -node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2856,10): error TS2365: Operator '+' cannot be applied to types 'null' and '1 | 0'. +node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2856,10): error TS2365: Operator '+' cannot be applied to types 'null' and '0 | 1'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2858,32): error TS2339: Property 'left' does not exist on type 'never'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2858,49): error TS2339: Property 'right' does not exist on type 'never'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(3034,25): error TS2339: Property 'xRel' does not exist on type 'Pos'. @@ -4419,7 +4441,9 @@ node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(461 node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(470,51): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(489,49): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(50,72): error TS2345: Argument of type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }' is not assignable to parameter of type 'K'. + '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(115,72): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'V'. + 'UISourceCode' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(135,32): error TS2694: Namespace 'Coverage' has no exported member 'RawLocation'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(169,16): error TS2403: Subsequent variable declarations must have the same type. Variable 'location' must be of type 'Location', but here has type 'CSSLocation'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(170,31): error TS2339: Property 'header' does not exist on type 'Location'. @@ -4509,6 +4533,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(94,42): er node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(96,45): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(98,48): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(109,26): error TS2352: Conversion of type 'DataGridNode' to type 'NODE_TYPE' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + 'DataGridNode' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(121,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(123,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(134,45): error TS2554: Expected 0 arguments, but got 1. @@ -4552,11 +4577,13 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(375,13): e node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(421,32): error TS2339: Property 'isCreationNode' does not exist on type 'DataGridNode'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(435,32): error TS2339: Property 'isCreationNode' does not exist on type 'DataGridNode'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(472,24): error TS2345: Argument of type 'DataGridNode' is not assignable to parameter of type 'NODE_TYPE'. + 'DataGridNode' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(474,27): error TS2339: Property 'isCreationNode' does not exist on type 'DataGridNode'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(591,44): error TS2345: Argument of type 'NODE_TYPE' is not assignable to parameter of type 'DataGridNode'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(595,25): error TS2339: Property 'data' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(622,5): error TS2322: Type 'DataGridNode[]' is not assignable to type 'NODE_TYPE[]'. Type 'DataGridNode' is not assignable to type 'NODE_TYPE'. + 'DataGridNode' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(641,56): error TS2339: Property 'offsetWidth' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(648,37): error TS2339: Property 'offsetWidth' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(649,41): error TS2339: Property 'rows' does not exist on type 'Element'. @@ -4690,12 +4717,15 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1736,37): node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1741,33): error TS2339: Property 'children' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1756,24): error TS2339: Property 'revealed' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1764,43): error TS2345: Argument of type 'this' is not assignable to parameter of type 'NODE_TYPE'. - Type 'DataGridNode' is not assignable to type 'NODE_TYPE'. + 'this' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. + Type 'DataGridNode' is not assignable to type 'NODE_TYPE'. + 'DataGridNode' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1779,26): error TS2339: Property 'revealed' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1784,26): error TS2339: Property '_detach' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1792,19): error TS2339: Property 'revealed' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1793,17): error TS2339: Property '_attach' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1810,43): error TS2345: Argument of type 'this' is not assignable to parameter of type 'NODE_TYPE'. + 'this' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1818,48): error TS2339: Property '_isRoot' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1819,28): error TS2339: Property 'expanded' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1820,25): error TS2339: Property 'expand' does not exist on type 'NODE_TYPE'. @@ -4703,6 +4733,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1821,41): node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1824,20): error TS2339: Property 'scrollIntoViewIfNeeded' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1892,9): error TS2367: This condition will always return 'false' since the types 'this' and 'NODE_TYPE' have no overlap. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1899,5): error TS2322: Type 'this' is not assignable to type 'NODE_TYPE'. + 'this' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1900,26): error TS2339: Property '_isRoot' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1900,60): error TS2339: Property 'revealed' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1900,77): error TS2339: Property 'nextSibling' does not exist on type 'NODE_TYPE'. @@ -4740,6 +4771,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/SortableDataGrid.js(19 Types of parameters 'a' and 'arg0' are incompatible. Type 'NODE_TYPE' is not assignable to type 'SortableDataGridNode'. node_modules/chrome-devtools-frontend/front_end/data_grid/SortableDataGrid.js(20,80): error TS2345: Argument of type 'SortableDataGridNode' is not assignable to parameter of type 'NODE_TYPE'. + 'SortableDataGridNode' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/SortableDataGrid.js(82,56): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. node_modules/chrome-devtools-frontend/front_end/data_grid/SortableDataGrid.js(131,20): error TS2352: Conversion of type 'NODE_TYPE' to type 'SortableDataGridNode' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. node_modules/chrome-devtools-frontend/front_end/data_grid/SortableDataGrid.js(141,21): error TS2339: Property 'recalculateSiblings' does not exist on type 'NODE_TYPE'. @@ -4759,6 +4791,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/ViewportDataGrid.js(9, Type '{ ViewportCalculated: symbol; }' is not assignable to type '{ SelectedNode: symbol; DeselectedNode: symbol; OpenedNode: symbol; SortingChanged: symbol; PaddingChanged: symbol; }'. node_modules/chrome-devtools-frontend/front_end/data_grid/ViewportDataGrid.js(11,41): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. node_modules/chrome-devtools-frontend/front_end/data_grid/ViewportDataGrid.js(32,22): error TS2345: Argument of type 'ViewportDataGridNode' is not assignable to parameter of type 'NODE_TYPE'. + 'ViewportDataGridNode' is assignable to the constraint of type 'NODE_TYPE', but 'NODE_TYPE' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/data_grid/ViewportDataGrid.js(43,41): error TS2339: Property 'flatChildren' does not exist on type 'NODE_TYPE'. node_modules/chrome-devtools-frontend/front_end/data_grid/ViewportDataGrid.js(87,49): error TS2339: Property 'isScrolledToBottom' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/ViewportDataGrid.js(104,51): error TS2339: Property 'isScrolledToBottom' does not exist on type 'Element'. @@ -5659,11 +5692,17 @@ node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(11 node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1131,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1145,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1232,7): error TS2322: Type 'StylePropertiesSection' is not assignable to type 'this'. + 'StylePropertiesSection' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertiesSection'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1236,7): error TS2322: Type 'StylePropertiesSection' is not assignable to type 'this'. + 'StylePropertiesSection' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertiesSection'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1238,9): error TS2322: Type 'StylePropertiesSection' is not assignable to type 'this'. + 'StylePropertiesSection' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertiesSection'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1250,7): error TS2322: Type 'StylePropertiesSection' is not assignable to type 'this'. + 'StylePropertiesSection' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertiesSection'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1254,7): error TS2322: Type 'StylePropertiesSection' is not assignable to type 'this'. + 'StylePropertiesSection' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertiesSection'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1256,9): error TS2322: Type 'StylePropertiesSection' is not assignable to type 'this'. + 'StylePropertiesSection' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertiesSection'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1273,15): error TS2339: Property 'setOverloaded' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1273,62): error TS2339: Property 'property' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1296,13): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -5769,6 +5808,7 @@ node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(27 node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2750,49): error TS2694: Namespace 'Elements.StylePropertyTreeElement' has no exported member 'Context'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2765,40): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2769,7): error TS2322: Type 'StylePropertyTreeElement' is not assignable to type 'this'. + 'StylePropertyTreeElement' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertyTreeElement'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2780,32): error TS2339: Property 'isWhitespace' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2785,32): error TS2339: Property 'focus' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2788,77): error TS2339: Property 'isWhitespace' does not exist on type 'string'. @@ -5779,6 +5819,7 @@ node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(28 node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2839,25): error TS2339: Property 'startEditing' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2849,61): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2857,9): error TS2322: Type 'StylePropertyTreeElement' is not assignable to type 'this'. + 'StylePropertyTreeElement' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'StylePropertyTreeElement'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2906,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2910,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2918,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. @@ -8089,6 +8130,7 @@ node_modules/chrome-devtools-frontend/front_end/performance_test_runner/Timeline node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(220,44): error TS2339: Property 'peekLast' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(255,46): error TS2554: Expected 2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(321,53): error TS2345: Argument of type 'number' is not assignable to parameter of type 'V'. + 'number' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(347,30): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(355,13): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/persistence/Automapping.js(12,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -8185,6 +8227,7 @@ node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemMa node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(171,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(185,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(211,21): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(222,30): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(264,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(284,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -8204,10 +8247,14 @@ node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(176,2 node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(218,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(323,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(326,47): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(331,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(334,50): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(341,52): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(343,74): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/persistence/PersistenceActions.js(30,44): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/persistence/PersistenceActions.js(34,9): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/persistence/PersistenceActions.js(39,44): error TS2555: Expected at least 2 arguments, but got 1. @@ -8278,8 +8325,10 @@ node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(944,41): e node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(954,49): error TS1110: Type expected. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(961,8): error TS2339: Property 'format' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(963,51): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Q'. + 'string' is assignable to the constraint of type 'Q', but 'Q' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(978,42): error TS2339: Property 'tokenizeFormatString' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1000,31): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Q'. + 'string' is assignable to the constraint of type 'Q', but 'Q' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1057,39): error TS2339: Property 'regexSpecialCharacters' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1108,15): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1116,15): error TS2339: Property 'firstValue' does not exist on type 'Set'. @@ -8294,9 +8343,12 @@ node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1169,24): node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1169,30): error TS2304: Cannot find name 'VALUE'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1171,15): error TS2339: Property 'inverse' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1200,13): error TS2345: Argument of type 'V' is not assignable to parameter of type 'V'. + 'V' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1211,5): error TS2719: Type 'Set' is not assignable to type 'Set'. Two different types with this name exist, but they are unrelated. Type 'V' is not assignable to type 'V'. Two different types with this name exist, but they are unrelated. + 'V' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1231,20): error TS2345: Argument of type 'V' is not assignable to parameter of type 'V'. + 'V' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1267,22): error TS2339: Property 'keysArray' does not exist on type 'Map>'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1277,14): error TS2339: Property 'pushAll' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1277,40): error TS2339: Property 'valuesArray' does not exist on type 'Set'. @@ -8777,6 +8829,7 @@ node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.j node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1289,22): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1306,40): error TS2339: Property 'snapshot' does not exist on type 'HeapSnapshotSortableDataGrid'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1314,7): error TS2322: Type 'AllocationGridNode' is not assignable to type 'this'. + 'AllocationGridNode' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'AllocationGridNode'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1321,39): error TS2339: Property '_createComparator' does not exist on type 'HeapSnapshotSortableDataGrid'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1347,44): error TS2339: Property 'heapProfilerModel' does not exist on type 'HeapSnapshotSortableDataGrid'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1349,38): error TS2339: Property '_linkifier' does not exist on type 'HeapSnapshotSortableDataGrid'. @@ -9038,7 +9091,9 @@ node_modules/chrome-devtools-frontend/front_end/profiler/TopDownProfileDataGrid. Property 'populate' does not exist on type 'TopDownProfileDataGridTree'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(148,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(168,40): error TS2345: Argument of type 'S' is not assignable to parameter of type 'S'. + 'S' is assignable to the constraint of type 'S', but 'S' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(170,24): error TS2345: Argument of type 'S' is not assignable to parameter of type 'T'. + 'S' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(194,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(201,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(202,20): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -9744,6 +9799,7 @@ node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(853,65): error T node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(860,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(880,34): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(896,7): error TS2322: Type 'DOMNode' is not assignable to type 'this'. + 'DOMNode' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'DOMNode'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(928,12): error TS2339: Property 'scrollIntoViewIfNeeded' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(940,29): error TS2339: Property 'pageAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(947,12): error TS2339: Property 'focus' does not exist on type 'Element'. @@ -9758,6 +9814,7 @@ node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1176,34): error node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1188,46): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1202,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1214,16): error TS2345: Argument of type 'T' is not assignable to parameter of type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1220,24): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1235,24): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(1248,31): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. @@ -10477,23 +10534,35 @@ node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(558,18): error node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(559,29): error TS2339: Property 'upperBound' does not exist on type 'SourceMapEntry[]'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(52,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(85,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(86,46): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(87,51): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(141,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(146,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(159,36): error TS2352: Conversion of type 'TextSourceMap' to type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(159,36): error TS2352: Conversion of type 'TextSourceMap' to type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property '_json' does not exist on type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(163,12): error TS2339: Property 'catchException' does not exist on type 'Promise'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(173,60): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(174,52): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(193,39): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(208,39): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(210,31): error TS2339: Property 'containsAll' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(227,47): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(228,53): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(232,40): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(234,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(16,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Factory'. node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(148,48): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(159,53): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. @@ -10509,13 +10578,16 @@ node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(104,35): er node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(105,32): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(106,30): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(108,27): error TS2345: Argument of type 'T' is not assignable to parameter of type 'T'. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(117,35): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. Type 'T' is not assignable to type 'SDKModel'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(119,46): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(120,15): error TS2339: Property 'remove' does not exist on type '{ modelAdded(model: T): void; modelRemoved(model: T): void; }[]'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(122,35): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(134,27): error TS2345: Argument of type 'SDKModel' is not assignable to parameter of type 'T'. + 'SDKModel' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(146,29): error TS2345: Argument of type 'SDKModel' is not assignable to parameter of type 'T'. + 'SDKModel' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(152,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(152,31): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(157,42): error TS2345: Argument of type 'Function' is not assignable to parameter of type 'new (arg1: Target) => any'. @@ -11043,6 +11115,7 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(41,27): error TS2339: Property 'removeChildren' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(42,47): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(53,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(66,35): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(73,36): error TS2339: Property 'createChild' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(78,37): error TS2339: Property 'uiLocation' does not exist on type 'V'. @@ -11146,14 +11219,18 @@ node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(167,22) node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(175,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(183,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(189,52): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(191,19): error TS2339: Property 'updateTitle' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(192,55): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(194,22): error TS2339: Property 'updateTitle' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(212,22): error TS2339: Property 'updateTitle' does not exist on type 'NavigatorTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(262,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(275,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(283,55): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(336,33): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(346,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(354,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(388,58): error TS2339: Property 'reverse' does not exist on type 'string'. @@ -11161,10 +11238,13 @@ node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(499,29) node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(527,28): error TS2339: Property '_boostOrder' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(578,14): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(592,45): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(593,22): error TS2339: Property 'firstValue' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(623,45): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(625,36): error TS2345: Argument of type 'V' is not assignable to parameter of type 'NavigatorUISourceCodeTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(633,36): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. + 'UISourceCode' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(638,27): error TS2339: Property 'parent' does not exist on type 'NavigatorUISourceCodeTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(643,25): error TS2339: Property 'parent' does not exist on type 'NavigatorUISourceCodeTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(655,93): error TS2339: Property '_folderPath' does not exist on type '(NavigatorUISourceCodeTreeNode & NavigatorGroupTreeNode) | (NavigatorUISourceCodeTreeNode & NavigatorFolderTreeNode)'. @@ -11720,13 +11800,17 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(735,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(796,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(842,27): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. + 'number' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(855,13): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(856,13): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(863,27): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. + 'number' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(866,49): error TS2694: Namespace 'TextEditor.CodeMirrorTextEditor' has no exported member 'Decoration'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(879,27): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. + 'number' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(883,49): error TS2694: Namespace 'TextEditor.CodeMirrorTextEditor' has no exported member 'Decoration'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(889,32): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. + 'number' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(899,25): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(902,27): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(955,5): error TS2322: Type 'string' is not assignable to type 'number'. @@ -12587,6 +12671,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTr node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(501,46): error TS2322: Type 'Node' is not assignable to type 'this'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(508,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'node' must be of type 'this', but here has type 'Node'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(512,9): error TS2322: Type 'BottomUpNode' is not assignable to type 'this'. + 'BottomUpNode' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'BottomUpNode'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(559,23): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(563,33): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TracingLayerTree.js(6,41): error TS2694: Namespace 'TimelineModel' has no exported member 'TracingLayerPayload'. @@ -12958,12 +13043,16 @@ node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(155,15): error node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(16,56): error TS2694: Namespace 'UI.KeyboardShortcut' has no exported member 'Descriptor'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(26,83): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(34,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(39,44): error TS2694: Namespace 'UI.KeyboardShortcut' has no exported member 'Descriptor'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(42,46): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(88,15): error TS2339: Property 'consume' does not exist on type 'KeyboardEvent'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(94,15): error TS2339: Property 'consume' does not exist on type 'KeyboardEvent'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(147,39): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(148,35): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(163,27): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutsScreen.js(42,54): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutsScreen.js(46,46): error TS2555: Expected at least 2 arguments, but got 1. @@ -13047,6 +13136,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/SoftContextMenu.js(147,47): e node_modules/chrome-devtools-frontend/front_end/ui/SoftContextMenu.js(162,22): error TS2339: Property '_isSeparator' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/SoftContextMenu.js(163,22): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/SoftContextMenu.js(183,7): error TS2322: Type 'SoftContextMenu' is not assignable to type 'this'. + 'SoftContextMenu' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'SoftContextMenu'. node_modules/chrome-devtools-frontend/front_end/ui/SoftDropDown.js(20,37): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/ui/SoftDropDown.js(25,39): error TS2345: Argument of type 'symbol' is not assignable to parameter of type 'boolean'. node_modules/chrome-devtools-frontend/front_end/ui/SoftDropDown.js(40,30): error TS2339: Property 'disabled' does not exist on type 'Element'. @@ -13502,12 +13592,15 @@ node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(669,14): error TS70 node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(693,51): error TS2339: Property 'deepActiveElement' does not exist on type 'Document'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(713,1): error TS2322: Type '(child: Node) => Node' is not assignable to type '(newChild: T) => T'. Type 'Node' is not assignable to type 'T'. + 'Node' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(715,14): error TS2339: Property '__widget' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(726,1): error TS2322: Type '(child: Node, anchor: Node) => Node' is not assignable to type '(newChild: T, refChild: Node) => T'. Type 'Node' is not assignable to type 'T'. + 'Node' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(728,14): error TS2339: Property '__widget' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(738,1): error TS2322: Type '(child: Node) => Node' is not assignable to type '(oldChild: T) => T'. Type 'Node' is not assignable to type 'T'. + 'Node' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(740,14): error TS2339: Property '__widgetCounter' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(740,40): error TS2339: Property '__widget' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(745,19): error TS2339: Property 'removeChildren' does not exist on type 'Element'. @@ -13602,7 +13695,9 @@ node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(838,11): error node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(850,17): error TS2339: Property 'treeElement' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(864,29): error TS2339: Property 'treeElement' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(896,7): error TS2322: Type 'TreeElement' is not assignable to type 'this'. + 'TreeElement' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(945,7): error TS2322: Type 'TreeElement' is not assignable to type 'this'. + 'TreeElement' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(1063,55): error TS2339: Property 'hasFocus' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(1064,28): error TS2339: Property 'focus' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/treeoutline.js(1078,51): error TS2345: Argument of type '0' is not assignable to parameter of type 'string'. @@ -13628,11 +13723,15 @@ node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(45,25) node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(136,14): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(298,26): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(546,27): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(556,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(557,33): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(567,5): error TS2322: Type 'V[]' is not assignable to type 'LineMarker[]'. Type 'V' is not assignable to type 'LineMarker'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(584,54): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. + 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/workspace/Workspace.js(37,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/workspace/Workspace.js(42,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/workspace/Workspace.js(47,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index c5feff00abc0d..a01fffa63cfe6 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -1,74 +1,74 @@ Exit Code: 1 Standard output: -node_modules/uglify-js/lib/ast.js(207,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/ast.js(328,33): error TS2339: Property 'transform' does not exist on type 'string'. -node_modules/uglify-js/lib/ast.js(869,5): error TS2322: Type '{ _visit: (node: any, descend: any) => any; parent: (n: any) => any; push: typeof push; pop: typeof pop; self: () => any; find_parent: (type: any) => any; has_directive: (type: any) => any; loopcontrol_target: (node: any) => any; in_boolean_context: () => boolean | undefined; }' is not assignable to type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(223,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/ast.js(344,33): error TS2339: Property 'transform' does not exist on type 'string'. +node_modules/uglify-js/lib/ast.js(885,5): error TS2322: Type '{ _visit: (node: any, descend: any) => any; parent: (n: any) => any; push: typeof push; pop: typeof pop; self: () => any; find_parent: (type: any) => any; has_directive: (type: any) => any; loopcontrol_target: (node: any) => any; in_boolean_context: () => boolean | undefined; }' is not assignable to type 'TreeWalker'. Object literal may only specify known properties, but '_visit' does not exist in type 'TreeWalker'. Did you mean to write 'visit'? -node_modules/uglify-js/lib/ast.js(870,14): error TS2339: Property 'push' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(877,14): error TS2339: Property 'pop' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(932,25): error TS2339: Property 'self' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(933,37): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(175,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(532,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(858,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1114,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1128,51): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'true | ((node: any) => any)' has no compatible call signatures. -node_modules/uglify-js/lib/compress.js(1192,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1233,112): error TS2454: Variable 'args' is used before being assigned. -node_modules/uglify-js/lib/compress.js(1234,29): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(1243,87): error TS2322: Type 'false' is not assignable to type 'number'. -node_modules/uglify-js/lib/compress.js(1251,29): error TS2322: Type 'false' is not assignable to type 'never'. -node_modules/uglify-js/lib/compress.js(1359,53): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1460,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1570,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1602,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1714,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/ast.js(886,14): error TS2339: Property 'push' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(893,14): error TS2339: Property 'pop' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(948,25): error TS2339: Property 'self' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(949,37): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(173,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(512,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(838,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1094,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1108,51): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'true | ((node: any) => any)' has no compatible call signatures. +node_modules/uglify-js/lib/compress.js(1172,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1213,112): error TS2454: Variable 'args' is used before being assigned. +node_modules/uglify-js/lib/compress.js(1214,29): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(1223,87): error TS2322: Type 'false' is not assignable to type 'number'. +node_modules/uglify-js/lib/compress.js(1231,29): error TS2322: Type 'false' is not assignable to type 'never'. +node_modules/uglify-js/lib/compress.js(1339,53): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1440,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1550,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1582,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1694,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'number[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2037,59): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2075,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(2017,59): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2055,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'any[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2223,34): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2948,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3400,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3413,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. -node_modules/uglify-js/lib/compress.js(3547,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3600,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3617,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3642,75): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3715,63): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3900,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3921,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3931,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4090,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4142,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. -node_modules/uglify-js/lib/compress.js(4203,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4315,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4614,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4698,37): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4906,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[RegExp, (string | undefined)?]'. +node_modules/uglify-js/lib/compress.js(2203,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2925,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3378,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3391,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. +node_modules/uglify-js/lib/compress.js(3525,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3578,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3595,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3620,75): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3693,63): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3878,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3899,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3909,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4068,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4120,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. +node_modules/uglify-js/lib/compress.js(4181,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4291,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4588,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4672,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4880,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[RegExp, (string | undefined)?]'. Property '0' is missing in type 'any[]' but required in type '[RegExp, (string | undefined)?]'. -node_modules/uglify-js/lib/compress.js(5070,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5077,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. -node_modules/uglify-js/lib/compress.js(5081,36): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(5086,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(5589,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6084,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. -node_modules/uglify-js/lib/compress.js(6111,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6185,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6257,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6263,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6696,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6711,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6714,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(6720,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6748,34): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/minify.js(170,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. +node_modules/uglify-js/lib/compress.js(5044,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5051,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. +node_modules/uglify-js/lib/compress.js(5055,36): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(5060,41): error TS2339: Property 'get' does not exist on type 'string'. +node_modules/uglify-js/lib/compress.js(5563,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6058,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. +node_modules/uglify-js/lib/compress.js(6085,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6159,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6231,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6237,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6670,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6685,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6688,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(6694,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6722,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/minify.js(166,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. node_modules/uglify-js/lib/mozilla-ast.js(566,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(246,25): error TS2554: Expected 0 arguments, but got 2. -node_modules/uglify-js/lib/output.js(475,37): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(767,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1163,44): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1445,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. +node_modules/uglify-js/lib/output.js(235,25): error TS2554: Expected 0 arguments, but got 2. +node_modules/uglify-js/lib/output.js(464,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(756,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(1152,44): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(1434,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. node_modules/uglify-js/lib/parse.js(361,20): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'. node_modules/uglify-js/lib/parse.js(443,32): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. diff --git a/tests/baselines/reference/user/webpack.log b/tests/baselines/reference/user/webpack.log index 03a6b924f8865..0cde6bb162311 100644 --- a/tests/baselines/reference/user/webpack.log +++ b/tests/baselines/reference/user/webpack.log @@ -2,6 +2,9 @@ Exit Code: 1 Standard output: ../../../../../built/local/lib.dom.d.ts(17676,19): error TS2451: Cannot redeclare block-scoped variable 'WebAssembly'. declarations.d.ts(258,15): error TS2451: Cannot redeclare block-scoped variable 'WebAssembly'. +lib/ContextModuleFactory.js(253,50): error TS2339: Property 'concat' does not exist on type 'unknown'. +lib/web/JsonpChunkTemplatePlugin.js(13,6): error TS2339: Property 'id' does not exist on type 'unknown'. +lib/web/JsonpMainTemplatePlugin.js(501,11): error TS2339: Property 'id' does not exist on type 'unknown'. diff --git a/tests/cases/compiler/awaitInNonAsyncFunction.ts b/tests/cases/compiler/awaitInNonAsyncFunction.ts new file mode 100644 index 0000000000000..5ebf37dc7ed04 --- /dev/null +++ b/tests/cases/compiler/awaitInNonAsyncFunction.ts @@ -0,0 +1,41 @@ +// @target: esnext +// https://github.com/Microsoft/TypeScript/issues/26586 + +function normalFunc(p: Promise) { + for await (const _ of []); + return await p; +} + +export function exportedFunc(p: Promise) { + for await (const _ of []); + return await p; +} + +const functionExpression = function(p: Promise) { + for await (const _ of []); + await p; +} + +const arrowFunc = (p: Promise) => { + for await (const _ of []); + return await p; +}; + +function* generatorFunc(p: Promise) { + for await (const _ of []); + yield await p; +} + +class clazz { + constructor(p: Promise) { + for await (const _ of []); + await p; + } + method(p: Promise) { + for await (const _ of []); + await p; + } +} + +for await (const _ of []); +await null; \ No newline at end of file diff --git a/tests/cases/compiler/compositeWithNodeModulesSourceFile.ts b/tests/cases/compiler/compositeWithNodeModulesSourceFile.ts new file mode 100644 index 0000000000000..b2d0020156751 --- /dev/null +++ b/tests/cases/compiler/compositeWithNodeModulesSourceFile.ts @@ -0,0 +1,13 @@ +// @filename: /foo/tsconfig.json +{ + "compilerOptions": { "composite": true }, + "exclude": [ "node_modules" ] +} + +// @filename: /foo/node_modules/myModule/index.ts +export class c { } + +// @filename: /foo/test.ts +import myModule = require("myModule"); +new myModule.c(); + diff --git a/tests/cases/compiler/genericFunctionInference1.ts b/tests/cases/compiler/genericFunctionInference1.ts index c6b864f82e518..c90c94cf5e874 100644 --- a/tests/cases/compiler/genericFunctionInference1.ts +++ b/tests/cases/compiler/genericFunctionInference1.ts @@ -65,6 +65,53 @@ declare function baz(t1: T, t2: T, u: U): [T, U]; let f60 = wrap3(baz); +declare const list2: { + (a: T): T[]; + foo: string; + bar(): number; +} + +let f70 = pipe(list2, box); +let f71 = pipe(box, list2); + +declare class Point { + constructor(x: number, y: number); + readonly x: number; + readonly y: number; +} + +declare class Bag { + constructor(...args: T[]); + contains(value: T): boolean; + static foo: string; +} + +function asFunction(cf: new (...args: A) => B) { + return (...args: A) => new cf(...args); +} + +const newPoint = asFunction(Point); +const newBag = asFunction(Bag); +const p1 = new Point(10, 20); +const p2 = newPoint(10, 20); +const bag1 = new Bag(1, 2, 3); +const bag2 = newBag('a', 'b', 'c'); + +declare class Comp

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

= new (props: P) => Comp

; + +declare function myHoc

(C: CompClass

): CompClass

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