(node, source, target, relation, containingMessageChain, errorOutputContainer)
| 63943 | return false; |
| 63944 | } |
| 63945 | function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) { |
| 63946 | // Don't elaborate blocks |
| 63947 | if (ts.isBlock(node.body)) { |
| 63948 | return false; |
| 63949 | } |
| 63950 | // Or functions with annotated parameter types |
| 63951 | if (ts.some(node.parameters, ts.hasType)) { |
| 63952 | return false; |
| 63953 | } |
| 63954 | var sourceSig = getSingleCallSignature(source); |
| 63955 | if (!sourceSig) { |
| 63956 | return false; |
| 63957 | } |
| 63958 | var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); |
| 63959 | if (!ts.length(targetSignatures)) { |
| 63960 | return false; |
| 63961 | } |
| 63962 | var returnExpression = node.body; |
| 63963 | var sourceReturn = getReturnTypeOfSignature(sourceSig); |
| 63964 | var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature)); |
| 63965 | if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, /*errorNode*/ undefined)) { |
| 63966 | var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); |
| 63967 | if (elaborated) { |
| 63968 | return elaborated; |
| 63969 | } |
| 63970 | var resultObj = errorOutputContainer || {}; |
| 63971 | checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, /*message*/ undefined, containingMessageChain, resultObj); |
| 63972 | if (resultObj.errors) { |
| 63973 | if (target.symbol && ts.length(target.symbol.declarations)) { |
| 63974 | ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); |
| 63975 | } |
| 63976 | if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 |
| 63977 | // exclude cases where source itself is promisy - this way we don't make a suggestion when relating |
| 63978 | // an IPromise and a Promise that are slightly different |
| 63979 | && !getTypeOfPropertyOfType(sourceReturn, "then") |
| 63980 | && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, /*errorNode*/ undefined)) { |
| 63981 | ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async)); |
| 63982 | } |
| 63983 | return true; |
| 63984 | } |
| 63985 | } |
| 63986 | return false; |
| 63987 | } |
| 63988 | function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) { |
| 63989 | var idx = getIndexedAccessTypeOrUndefined(target, nameType); |
| 63990 | if (idx) { |
no test coverage detected
searching dependent graphs…