From 8c2cd2610317dcc0f22f3f57c60c959a2cb53e41 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 24 Mar 2015 18:29:52 -0700 Subject: [PATCH] Add createIterableType --- src/compiler/checker.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c3a9b2960ef..80e0ebfc665 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3408,6 +3408,10 @@ module ts { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + function createIterableType(elementType: Type): Type { + return globalIterableType !== emptyObjectType ? createTypeReference(globalIterableType, [elementType]) : emptyObjectType; + } + function createArrayType(elementType: Type): Type { // globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if // 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 { // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. if (expressionForError && iteratedType) { - let completeIterableType = globalIterableType !== emptyObjectType - ? createTypeReference(globalIterableType, [iteratedType]) - : emptyObjectType; - checkTypeAssignableTo(iterable, completeIterableType, expressionForError); + checkTypeAssignableTo(iterable, createIterableType(iteratedType), expressionForError); } return iteratedType;