MCPcopy Index your code
hub / github.com/nodejs/node / invocationErrorDetails

Function invocationErrorDetails

test/fixtures/snapshot/typescript.js:76686–76749  ·  view source on GitHub ↗
(errorTarget, apparentType, kind)

Source from the content-addressed store, hash-verified

76684 return true;
76685 }
76686 function invocationErrorDetails(errorTarget, apparentType, kind) {
76687 var errorInfo;
76688 var isCall = kind === 0 /* SignatureKind.Call */;
76689 var awaitedType = getAwaitedType(apparentType);
76690 var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
76691 if (apparentType.flags & 1048576 /* TypeFlags.Union */) {
76692 var types = apparentType.types;
76693 var hasSignatures = false;
76694 for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
76695 var constituent = types_20[_i];
76696 var signatures = getSignaturesOfType(constituent, kind);
76697 if (signatures.length !== 0) {
76698 hasSignatures = true;
76699 if (errorInfo) {
76700 // Bail early if we already have an error, no chance of "No constituent of type is callable"
76701 break;
76702 }
76703 }
76704 else {
76705 // Error on the first non callable constituent only
76706 if (!errorInfo) {
76707 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
76708 ts.Diagnostics.Type_0_has_no_call_signatures :
76709 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
76710 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
76711 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
76712 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
76713 }
76714 if (hasSignatures) {
76715 // Bail early if we already found a siganture, no chance of "No constituent of type is callable"
76716 break;
76717 }
76718 }
76719 }
76720 if (!hasSignatures) {
76721 errorInfo = ts.chainDiagnosticMessages(
76722 /* detials */ undefined, isCall ?
76723 ts.Diagnostics.No_constituent_of_type_0_is_callable :
76724 ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
76725 }
76726 if (!errorInfo) {
76727 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
76728 ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
76729 ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
76730 }
76731 }
76732 else {
76733 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
76734 ts.Diagnostics.Type_0_has_no_call_signatures :
76735 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
76736 }
76737 var headMessage = isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable;
76738 // Diagnose get accessors incorrectly called as functions
76739 if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) {
76740 var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol;
76741 if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) {
76742 headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without;
76743 }

Callers 2

invocationErrorFunction · 0.85
resolveDecoratorFunction · 0.85

Calls 4

getAwaitedTypeFunction · 0.85
getSignaturesOfTypeFunction · 0.85
typeToStringFunction · 0.85
getNodeLinksFunction · 0.85

Tested by

no test coverage detected