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

Function getIterationTypesOfIterable

test/fixtures/snapshot/typescript.js:83173–83209  ·  view source on GitHub ↗

* Gets the *yield*, *return*, and *next* types from an `Iterable`-like or `AsyncIterable`-like type. * * At every level that involves analyzing return types of signatures, we union the return types of all the signatures. * * Another thing to note is that at any st

(type, use, errorNode)

Source from the content-addressed store, hash-verified

83171 * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
83172 */
83173 function getIterationTypesOfIterable(type, use, errorNode) {
83174 if (isTypeAny(type)) {
83175 return anyIterationTypes;
83176 }
83177 if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
83178 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
83179 if (iterationTypes_1 === noIterationTypes) {
83180 if (errorNode) {
83181 reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */));
83182 }
83183 return undefined;
83184 }
83185 return iterationTypes_1;
83186 }
83187 var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
83188 var cachedTypes = getCachedIterationTypes(type, cacheKey);
83189 if (cachedTypes)
83190 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
83191 var allIterationTypes;
83192 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
83193 var constituent = _a[_i];
83194 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
83195 if (iterationTypes_2 === noIterationTypes) {
83196 if (errorNode) {
83197 reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */));
83198 }
83199 setCachedIterationTypes(type, cacheKey, noIterationTypes);
83200 return undefined;
83201 }
83202 else {
83203 allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
83204 }
83205 }
83206 var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
83207 setCachedIterationTypes(type, cacheKey, iterationTypes);
83208 return iterationTypes === noIterationTypes ? undefined : iterationTypes;
83209 }
83210 function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
83211 if (iterationTypes === noIterationTypes)
83212 return noIterationTypes;

Calls 7

isTypeAnyFunction · 0.85
getCachedIterationTypesFunction · 0.85
setCachedIterationTypesFunction · 0.85
combineIterationTypesFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…