@@ -1657,8 +1657,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1657
1657
getFullyQualifiedName,
1658
1658
getResolvedSignature: (node, candidatesOutArray, argumentCount) =>
1659
1659
getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal),
1660
- getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) =>
1661
- runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions)),
1660
+ getCandidateSignaturesForStringLiteralCompletions,
1662
1661
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) =>
1663
1662
runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.IsForSignatureHelp)),
1664
1663
getExpandedParameters,
@@ -1839,17 +1838,41 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1839
1838
typeHasCallOrConstructSignatures,
1840
1839
};
1841
1840
1841
+ function getCandidateSignaturesForStringLiteralCompletions(call: CallLikeExpression, editingArgument: Node) {
1842
+ const candidatesSet = new Set<Signature>();
1843
+ const candidates: Signature[] = [];
1844
+
1845
+ // first, get candidates when inference is blocked from the source node.
1846
+ runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidates, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions));
1847
+ for (const candidate of candidates) {
1848
+ candidatesSet.add(candidate);
1849
+ }
1850
+
1851
+ // reset candidates for second pass
1852
+ candidates.length = 0;
1853
+
1854
+ // next, get candidates where the source node is considered for inference.
1855
+ runWithoutResolvedSignatureCaching(editingArgument, () => getResolvedSignatureWorker(call, candidates, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions));
1856
+ for (const candidate of candidates) {
1857
+ candidatesSet.add(candidate);
1858
+ }
1859
+
1860
+ return arrayFrom(candidatesSet);
1861
+ }
1862
+
1842
1863
function runWithoutResolvedSignatureCaching<T>(node: Node | undefined, fn: () => T): T {
1843
1864
const containingCall = findAncestor(node, isCallLikeExpression);
1844
- const containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
1845
1865
if (containingCall) {
1846
- getNodeLinks(containingCall).resolvedSignature = undefined;
1866
+ const links = getNodeLinks(containingCall);
1867
+ const containingCallResolvedSignature = links.resolvedSignature;
1868
+ links.resolvedSignature = undefined;
1869
+ const result = fn();
1870
+ links.resolvedSignature = containingCallResolvedSignature;
1871
+ return result;
1847
1872
}
1848
- const result = fn();
1849
- if (containingCall) {
1850
- getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
1873
+ else {
1874
+ return fn();
1851
1875
}
1852
- return result;
1853
1876
}
1854
1877
1855
1878
function runWithInferenceBlockedFromSourceNode<T>(node: Node | undefined, fn: () => T): T {
@@ -2036,7 +2059,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2036
2059
getGlobalIterableType: getGlobalAsyncIterableType,
2037
2060
getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
2038
2061
getGlobalGeneratorType: getGlobalAsyncGeneratorType,
2039
- resolveIterationType: getAwaitedType,
2062
+ resolveIterationType: (type, errorNode) => getAwaitedType(type, errorNode, Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) ,
2040
2063
mustHaveANextMethodDiagnostic: Diagnostics.An_async_iterator_must_have_a_next_method,
2041
2064
mustBeAMethodDiagnostic: Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
2042
2065
mustHaveAValueDiagnostic: Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property,
0 commit comments