mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Make finer-grained errors get reported on function arguments (#26784)
This commit is contained in:
1 parent
2deb3189de
commit
cd37e41d3d
33 files changed
+257
-395
No files matched your search
@@ -10528,9 +10528,13 @@ namespace ts {
|
||||
* attempt to issue more specific errors on, for example, specific object literal properties or tuple members.
|
||||
*/
|
||||
function checkTypeAssignableToAndOptionallyElaborate(source: Type, target: Type, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean {
|
||||
if (isTypeAssignableTo(source, target)) return true;
|
||||
if (!elaborateError(expr, source, target)) {
|
||||
return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain);
|
||||
return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain);
|
||||
}
|
||||
|
||||
function checkTypeRelatedToAndOptionallyElaborate(source: Type, target: Type, relation: Map<RelationComparisonResult>, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean {
|
||||
if (isTypeRelatedTo(source, target, relation)) return true;
|
||||
if (!errorNode || !elaborateError(expr, source, target)) {
|
||||
return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -18869,7 +18873,7 @@ namespace ts {
|
||||
// we obtain the regular type of any object literal arguments because we may not have inferred complete
|
||||
// parameter types yet and therefore excess property checks may yield false positives (see #17041).
|
||||
const checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType;
|
||||
if (!checkTypeRelatedTo(checkArgType, paramType, relation, reportErrors ? arg : undefined, headMessage)) {
|
||||
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user