Skip to content

Commit 8c2cd26

Browse files
committed
Add createIterableType
1 parent 4a0af76 commit 8c2cd26

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,6 +3408,10 @@ module ts {
34083408
return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
34093409
}
34103410

3411+
function createIterableType(elementType: Type): Type {
3412+
return globalIterableType !== emptyObjectType ? createTypeReference(<GenericType>globalIterableType, [elementType]) : emptyObjectType;
3413+
}
3414+
34113415
function createArrayType(elementType: Type): Type {
34123416
// globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if
34133417
// user code augments the Array type with call or construct signatures that have an array type as the return type.
@@ -9268,10 +9272,7 @@ module ts {
92689272
// Now even though we have extracted the iteratedType, we will have to validate that the type
92699273
// passed in is actually an Iterable.
92709274
if (expressionForError && iteratedType) {
9271-
let completeIterableType = globalIterableType !== emptyObjectType
9272-
? createTypeReference(<GenericType>globalIterableType, [iteratedType])
9273-
: emptyObjectType;
9274-
checkTypeAssignableTo(iterable, completeIterableType, expressionForError);
9275+
checkTypeAssignableTo(iterable, createIterableType(iteratedType), expressionForError);
92759276
}
92769277

92779278
return iteratedType;

0 commit comments

Comments
 (0)