@@ -99,19 +99,19 @@ module ts {
99
99
100
100
let globals: SymbolTable = {};
101
101
102
- let globalArraySymbol: Symbol;
103
102
let globalESSymbolConstructorSymbol: Symbol;
104
103
105
104
let globalObjectType: ObjectType;
106
105
let globalFunctionType: ObjectType;
107
- let globalArrayType: ObjectType ;
106
+ let globalArrayType: GenericType ;
108
107
let globalStringType: ObjectType;
109
108
let globalNumberType: ObjectType;
110
109
let globalBooleanType: ObjectType;
111
110
let globalRegExpType: ObjectType;
112
111
let globalTemplateStringsArrayType: ObjectType;
113
112
let globalESSymbolType: ObjectType;
114
- let globalIterableType: ObjectType;
113
+ let globalIterableType: GenericType;
114
+ let globalIterableIteratorType: GenericType;
115
115
116
116
let anyArrayType: Type;
117
117
let getGlobalClassDecoratorType: () => ObjectType;
@@ -3468,16 +3468,20 @@ module ts {
3468
3468
return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
3469
3469
}
3470
3470
3471
+ function createTypeFromGlobalGenericType(globalGenericType: GenericType, elementType: Type): Type {
3472
+ return <ObjectType>globalGenericType !== emptyObjectType ? createTypeReference(globalGenericType, [elementType]) : emptyObjectType;
3473
+ }
3474
+
3471
3475
function createIterableType(elementType: Type): Type {
3472
- return globalIterableType !== emptyObjectType ? createTypeReference(<GenericType>globalIterableType, [elementType]) : emptyObjectType;
3476
+ return createTypeFromGlobalGenericType(globalIterableType, elementType);
3477
+ }
3478
+
3479
+ function createIterableIteratorType(elementType: Type): Type {
3480
+ return createTypeFromGlobalGenericType(globalIterableIteratorType, elementType);
3473
3481
}
3474
3482
3475
3483
function createArrayType(elementType: Type): Type {
3476
- // globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if
3477
- // user code augments the Array type with call or construct signatures that have an array type as the return type.
3478
- // We instead use globalArraySymbol to obtain the (not yet fully constructed) Array type.
3479
- let arrayType = globalArrayType || getDeclaredTypeOfSymbol(globalArraySymbol);
3480
- return arrayType !== emptyObjectType ? createTypeReference(<GenericType>arrayType, [elementType]) : emptyObjectType;
3484
+ return createTypeFromGlobalGenericType(globalArrayType, elementType);
3481
3485
}
3482
3486
3483
3487
function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type {
@@ -8142,6 +8146,16 @@ module ts {
8142
8146
}
8143
8147
}
8144
8148
8149
+ function isSyntacticallyValidGenerator(node: SignatureDeclaration): boolean {
8150
+ if (!(<FunctionLikeDeclaration>node).asteriskToken || !(<FunctionLikeDeclaration>node).body) {
8151
+ return false;
8152
+ }
8153
+
8154
+ return node.kind === SyntaxKind.MethodDeclaration ||
8155
+ node.kind === SyntaxKind.FunctionDeclaration ||
8156
+ node.kind === SyntaxKind.FunctionExpression;
8157
+ }
8158
+
8145
8159
function checkSignatureDeclaration(node: SignatureDeclaration) {
8146
8160
// Grammar checking
8147
8161
if (node.kind === SyntaxKind.IndexSignature) {
@@ -11967,8 +11981,7 @@ module ts {
11967
11981
getSymbolLinks(unknownSymbol).type = unknownType;
11968
11982
globals[undefinedSymbol.name] = undefinedSymbol;
11969
11983
// Initialize special types
11970
- globalArraySymbol = getGlobalTypeSymbol("Array");
11971
- globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, /*arity*/ 1);
11984
+ globalArrayType = <GenericType>getGlobalType("Array", /*arity*/ 1);
11972
11985
globalObjectType = getGlobalType("Object");
11973
11986
globalFunctionType = getGlobalType("Function");
11974
11987
globalStringType = getGlobalType("String");
@@ -11986,7 +11999,8 @@ module ts {
11986
11999
globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
11987
12000
globalESSymbolType = getGlobalType("Symbol");
11988
12001
globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol");
11989
- globalIterableType = getGlobalType("Iterable", /*arity*/ 1);
12002
+ globalIterableType = <GenericType>getGlobalType("Iterable", /*arity*/ 1);
12003
+ globalIterableIteratorType = <GenericType>getGlobalType("IterableIterator", /*arity*/ 1);
11990
12004
}
11991
12005
else {
11992
12006
globalTemplateStringsArrayType = unknownType;
0 commit comments