* Fix 33436

* Fix code

* Fix error message after bad merge

* Remove whitespace
This commit is contained in:
Jack Williams
2020-03-12 22:40:14 +00:00
committed by GitHub
parent d727d5a5eb
commit dcc73944f4
96 changed files with 661 additions and 520 deletions

View File

@@ -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) {

View File

@@ -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",