mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 13:42:16 -05:00
Rephrase error message to be 100% technically correct (#50471)
This commit is contained in:
@@ -34582,26 +34582,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function tryGiveBetterPrimaryError(errNode: Node, maybeMissingAwait: boolean, leftStr: string, rightStr: string) {
|
||||
let typeName: string | undefined;
|
||||
switch (operatorToken.kind) {
|
||||
case SyntaxKind.EqualsEqualsEqualsToken:
|
||||
case SyntaxKind.EqualsEqualsToken:
|
||||
typeName = "false";
|
||||
break;
|
||||
case SyntaxKind.ExclamationEqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsToken:
|
||||
typeName = "true";
|
||||
return errorAndMaybeSuggestAwait(
|
||||
errNode,
|
||||
maybeMissingAwait,
|
||||
Diagnostics.This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap,
|
||||
leftStr, rightStr);
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeName) {
|
||||
return errorAndMaybeSuggestAwait(
|
||||
errNode,
|
||||
maybeMissingAwait,
|
||||
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap,
|
||||
typeName, leftStr, rightStr);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1864,7 +1864,7 @@
|
||||
"category": "Error",
|
||||
"code": 2366
|
||||
},
|
||||
"This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap.": {
|
||||
"This comparison appears to be unintentional because the types '{0}' and '{1}' have no overlap.": {
|
||||
"category": "Error",
|
||||
"code": 2367
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ts.codefix {
|
||||
Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code,
|
||||
Diagnostics.Operator_0_cannot_be_applied_to_type_1.code,
|
||||
Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code,
|
||||
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code,
|
||||
Diagnostics.This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap.code,
|
||||
Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code,
|
||||
Diagnostics.Type_0_is_not_an_array_type.code,
|
||||
Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace ts.projectSystem {
|
||||
);
|
||||
const errorResult = session.executeCommand(getErrRequest).response as protocol.Diagnostic[];
|
||||
assert.isTrue(errorResult.length === 1);
|
||||
assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code);
|
||||
assert.equal(errorResult[0].code, Diagnostics.This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap.code);
|
||||
});
|
||||
|
||||
it("should report semantic errors for configured js project with '// @ts-check' and skipLibCheck=true", () => {
|
||||
@@ -194,7 +194,7 @@ namespace ts.projectSystem {
|
||||
);
|
||||
const errorResult = session.executeCommand(getErrRequest).response as protocol.Diagnostic[];
|
||||
assert.isTrue(errorResult.length === 1);
|
||||
assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code);
|
||||
assert.equal(errorResult[0].code, Diagnostics.This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap.code);
|
||||
});
|
||||
|
||||
it("should report semantic errors for configured js project with checkJs=true and skipLibCheck=true", () => {
|
||||
@@ -223,7 +223,7 @@ namespace ts.projectSystem {
|
||||
);
|
||||
const errorResult = session.executeCommand(getErrRequest).response as protocol.Diagnostic[];
|
||||
assert.isTrue(errorResult.length === 1);
|
||||
assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code);
|
||||
assert.equal(errorResult[0].code, Diagnostics.This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap.code);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user