* Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from from common heuristics. * * If we previously analyzed this type and found no iteration types, `noIterationTypes` is * returned. If we found iteration types, an
(type, resolver)
| 83306 | * `getIterationTypesOfIterable` instead. |
| 83307 | */ |
| 83308 | function getIterationTypesOfIterableFast(type, resolver) { |
| 83309 | // As an optimization, if the type is an instantiation of one of the following global types, then |
| 83310 | // just grab its related type argument: |
| 83311 | // - `Iterable<T>` or `AsyncIterable<T>` |
| 83312 | // - `IterableIterator<T>` or `AsyncIterableIterator<T>` |
| 83313 | var globalType; |
| 83314 | if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || |
| 83315 | isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { |
| 83316 | var yieldType = getTypeArguments(type)[0]; |
| 83317 | // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the |
| 83318 | // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. |
| 83319 | // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use |
| 83320 | // different definitions. |
| 83321 | var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType; |
| 83322 | return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(yieldType, /*errorNode*/ undefined) || yieldType, resolver.resolveIterationType(returnType, /*errorNode*/ undefined) || returnType, nextType)); |
| 83323 | } |
| 83324 | // As an optimization, if the type is an instantiation of the following global type, then |
| 83325 | // just grab its related type arguments: |
| 83326 | // - `Generator<T, TReturn, TNext>` or `AsyncGenerator<T, TReturn, TNext>` |
| 83327 | if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { |
| 83328 | var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; |
| 83329 | return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(yieldType, /*errorNode*/ undefined) || yieldType, resolver.resolveIterationType(returnType, /*errorNode*/ undefined) || returnType, nextType)); |
| 83330 | } |
| 83331 | } |
| 83332 | function getPropertyNameForKnownSymbolName(symbolName) { |
| 83333 | var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); |
| 83334 | var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); |
no test coverage detected
searching dependent graphs…