mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Fix 33436 (#35225)
* Fix 33436 * Fix code * Fix error message after bad merge * Remove whitespace
This commit is contained in:
@@ -15218,13 +15218,24 @@ namespace ts {
|
||||
if (incompatibleStack.length) reportIncompatibleStack();
|
||||
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 (target.flags & TypeFlags.TypeParameter) {
|
||||
const constraint = getBaseConstraintOfType(target);
|
||||
const constraintElab = constraint && isTypeAssignableTo(source, constraint);
|
||||
if (constraintElab) {
|
||||
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(constraint!),
|
||||
);
|
||||
}
|
||||
else {
|
||||
reportError(
|
||||
Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1,
|
||||
targetType,
|
||||
sourceType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!message) {
|
||||
|
||||
@@ -3445,6 +3445,10 @@
|
||||
"category": "Error",
|
||||
"code": 5081
|
||||
},
|
||||
"'{0}' could be instantiated with an arbitrary type which could be unrelated to '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 5082
|
||||
},
|
||||
|
||||
"Generates a sourcemap for each corresponding '.d.ts' file.": {
|
||||
"category": "Message",
|
||||
|
||||
Reference in New Issue
Block a user