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

Function getIterationTypesOfIterableWorker

test/fixtures/snapshot/typescript.js:83232–83280  ·  view source on GitHub ↗

* Gets the *yield*, *return*, and *next* types from a non-union type. * * If we are unable to find the *yield*, *return*, and *next* types, `noIterationTypes` is * returned to indicate to the caller that it should report an error. Otherwise, an * `IterationTypes`

(type, use, errorNode)

Source from the content-addressed store, hash-verified

83230 * `getIterationTypesOfIterable` instead.
83231 */
83232 function getIterationTypesOfIterableWorker(type, use, errorNode) {
83233 if (isTypeAny(type)) {
83234 return anyIterationTypes;
83235 }
83236 if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
83237 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
83238 getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
83239 if (iterationTypes) {
83240 return use & 8 /* IterationUse.ForOfFlag */ ?
83241 getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
83242 iterationTypes;
83243 }
83244 }
83245 if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) {
83246 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
83247 getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
83248 if (iterationTypes) {
83249 if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
83250 // for a sync iterable in an async context, only use the cached types if they are valid.
83251 if (iterationTypes !== noIterationTypes) {
83252 return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
83253 }
83254 }
83255 else {
83256 return iterationTypes;
83257 }
83258 }
83259 }
83260 if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
83261 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
83262 if (iterationTypes !== noIterationTypes) {
83263 return iterationTypes;
83264 }
83265 }
83266 if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) {
83267 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
83268 if (iterationTypes !== noIterationTypes) {
83269 if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
83270 return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
83271 ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
83272 : noIterationTypes);
83273 }
83274 else {
83275 return iterationTypes;
83276 }
83277 }
83278 }
83279 return noIterationTypes;
83280 }
83281 /**
83282 * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or
83283 * `AsyncIterable`-like type from the cache.

Callers 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…