From e5910af2c835ffbc8b67469ad1fff6bbec4e112b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 14:15:49 -0700 Subject: [PATCH 001/402] Always recurse into children in the binder in a uniform manner. --- src/compiler/binder.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 9d6d9fab35b..1682cbdcd44 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -575,10 +575,8 @@ module ts { bindChildren(node, 0, /*isBlockScopeContainer*/ true); break; default: - let saveParent = parent; - parent = node; - forEachChild(node, bind); - parent = saveParent; + bindChildren(node, 0, /*isBlockScopeContainer*/ false); + break; } } From 14e925beb980790b271aec0ee8d6b54da4cfa669 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 14:21:52 -0700 Subject: [PATCH 002/402] ConstructorType's name should be __call not __constructor. --- src/compiler/binder.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1682cbdcd44..4bc79e35c33 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -111,12 +111,12 @@ module ts { return (node.name).text; } switch (node.kind) { - case SyntaxKind.ConstructorType: case SyntaxKind.Constructor: return "__constructor"; case SyntaxKind.FunctionType: case SyntaxKind.CallSignature: return "__call"; + case SyntaxKind.ConstructorType: case SyntaxKind.ConstructSignature: return "__new"; case SyntaxKind.IndexSignature: @@ -368,15 +368,14 @@ module ts { // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - - let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node)); + let name = getDeclarationName(node); + let symbol = createSymbol(SymbolFlags.Signature, name); addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); bindChildren(node, SymbolFlags.Signature, /*isBlockScopeContainer:*/ false); let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); - typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === SyntaxKind.FunctionType ? "__call" : "__new"] = symbol + typeLiteralSymbol.members = { [name]: symbol }; } function bindAnonymousDeclaration(node: Declaration, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) { From 6478155aac000a15c95d6e0bb60bad1d72dd6626 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 14:30:35 -0700 Subject: [PATCH 003/402] Rename locals to more clearly indicate they are flags and not kinds. --- src/compiler/binder.ts | 98 ++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4bc79e35c33..b11a7b5b8c0 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -86,14 +86,27 @@ module ts { } } - function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolKind: SymbolFlags) { - symbol.flags |= symbolKind; - if (!symbol.declarations) symbol.declarations = []; - symbol.declarations.push(node); - if (symbolKind & SymbolFlags.HasExports && !symbol.exports) symbol.exports = {}; - if (symbolKind & SymbolFlags.HasMembers && !symbol.members) symbol.members = {}; + function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolFlags: SymbolFlags) { + symbol.flags |= symbolFlags; + node.symbol = symbol; - if (symbolKind & SymbolFlags.Value && !symbol.valueDeclaration) symbol.valueDeclaration = node; + + if (!symbol.declarations) { + symbol.declarations = []; + } + symbol.declarations.push(node); + + if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { + symbol.exports = {}; + } + + if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) { + symbol.members = {}; + } + + if (symbolFlags & SymbolFlags.Value && !symbol.valueDeclaration) { + symbol.valueDeclaration = node; + } } // Should not be called on a declaration with a computed property name, @@ -189,14 +202,14 @@ module ts { return symbol; } - function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) { + function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export; - if (symbolKind & SymbolFlags.Alias) { + if (symbolFlags & SymbolFlags.Alias) { if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } else { @@ -212,23 +225,23 @@ module ts { // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. if (hasExportModifier || container.flags & NodeFlags.ExportContext) { - let exportKind = (symbolKind & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | - (symbolKind & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | - (symbolKind & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0); + let exportKind = (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | + (symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | + (symbolFlags & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0); let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); - local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; } else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } } // All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function // in the type checker to validate that the local name used for a container is unique. - function bindChildren(node: Node, symbolKind: SymbolFlags, isBlockScopeContainer: boolean) { - if (symbolKind & SymbolFlags.HasLocals) { + function bindChildren(node: Node, symbolFlags: SymbolFlags, isBlockScopeContainer: boolean) { + if (symbolFlags & SymbolFlags.HasLocals) { node.locals = {}; } @@ -236,7 +249,7 @@ module ts { let saveContainer = container; let savedBlockScopeContainer = blockScopeContainer; parent = node; - if (symbolKind & SymbolFlags.IsContainer) { + if (symbolFlags & SymbolFlags.IsContainer) { container = node; if (lastContainer) { @@ -253,7 +266,7 @@ module ts { // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); + setBlockScopeContainer(node, /*cleanLocals*/ (symbolFlags & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); @@ -262,14 +275,14 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } - function bindDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { + function bindDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { switch (container.kind) { case SyntaxKind.ModuleDeclaration: - declareModuleMember(node, symbolKind, symbolExcludes); + declareModuleMember(node, symbolFlags, symbolExcludes); break; case SyntaxKind.SourceFile: if (isExternalModule(container)) { - declareModuleMember(node, symbolKind, symbolExcludes); + declareModuleMember(node, symbolFlags, symbolExcludes); break; } case SyntaxKind.FunctionType: @@ -285,29 +298,32 @@ module ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); + declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); break; case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: if (node.flags & NodeFlags.Static) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); break; } case SyntaxKind.TypeLiteral: case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.InterfaceDeclaration: - declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); + declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); break; case SyntaxKind.EnumDeclaration: - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); + declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); break; } - bindChildren(node, symbolKind, isBlockScopeContainer); + bindChildren(node, symbolFlags, isBlockScopeContainer); } function isAmbientContext(node: Node): boolean { while (node) { - if (node.flags & NodeFlags.Ambient) return true; + if (node.flags & NodeFlags.Ambient) { + return true; + } + node = node.parent; } return false; @@ -378,24 +394,24 @@ module ts { typeLiteralSymbol.members = { [name]: symbol }; } - function bindAnonymousDeclaration(node: Declaration, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) { - let symbol = createSymbol(symbolKind, name); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, isBlockScopeContainer); + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string, isBlockScopeContainer: boolean) { + let symbol = createSymbol(symbolFlags, name); + addDeclarationToSymbol(symbol, node, symbolFlags); + bindChildren(node, symbolFlags, isBlockScopeContainer); } function bindCatchVariableDeclaration(node: CatchClause) { bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true); } - function bindBlockScopedDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) { + function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { switch (blockScopeContainer.kind) { case SyntaxKind.ModuleDeclaration: - declareModuleMember(node, symbolKind, symbolExcludes); + declareModuleMember(node, symbolFlags, symbolExcludes); break; case SyntaxKind.SourceFile: if (isExternalModule(container)) { - declareModuleMember(node, symbolKind, symbolExcludes); + declareModuleMember(node, symbolFlags, symbolExcludes); break; } // fall through. @@ -403,9 +419,9 @@ module ts { if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes); + declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); } - bindChildren(node, symbolKind, /*isBlockScopeContainer*/ false); + bindChildren(node, symbolFlags, /*isBlockScopeContainer*/ false); } function bindBlockScopedVariableDeclaration(node: Declaration) { @@ -598,12 +614,12 @@ module ts { } } - function bindPropertyOrMethodOrAccessor(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { if (hasDynamicName(node)) { - bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer); + bindAnonymousDeclaration(node, symbolFlags, "__computed", isBlockScopeContainer); } else { - bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer); + bindDeclaration(node, symbolFlags, symbolExcludes, isBlockScopeContainer); } } } From 71d0f7affe4d8c5ec9b1841fca9a403ffe14b8a2 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 14:46:01 -0700 Subject: [PATCH 004/402] Simplify concerns in the binder. --- src/compiler/binder.ts | 89 ++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b11a7b5b8c0..af7226eee2d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -202,14 +202,14 @@ module ts { return symbol; } - function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export; if (symbolFlags & SymbolFlags.Alias) { if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { - declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } else { @@ -231,9 +231,10 @@ module ts { let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; + return local; } else { - declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } } @@ -275,16 +276,17 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } - function bindDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { + function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean): void { + declareSymbolAndAddToAppropriateContainer(node, symbolFlags, symbolExcludes, isBlockScopeContainer); + bindChildren(node, symbolFlags, isBlockScopeContainer); + } + + function declareSymbolAndAddToAppropriateContainer(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean): Symbol { switch (container.kind) { case SyntaxKind.ModuleDeclaration: - declareModuleMember(node, symbolFlags, symbolExcludes); - break; + return declareModuleMember(node, symbolFlags, symbolExcludes); case SyntaxKind.SourceFile: - if (isExternalModule(container)) { - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - } + return declareSourceFileMember(container, node, symbolFlags, symbolExcludes); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: @@ -298,24 +300,35 @@ module ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - break; + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: - if (node.flags & NodeFlags.Static) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - break; - } + return declareClassMember(node, symbolFlags, symbolExcludes); case SyntaxKind.TypeLiteral: case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.InterfaceDeclaration: - declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - break; + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case SyntaxKind.EnumDeclaration: - declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - break; + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + } + } + + function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + if (node.flags & NodeFlags.Static) { + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + } + else { + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + } + } + + function declareSourceFileMember(container: SourceFile, node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + if (isExternalModule(container)) { + return declareModuleMember(node, symbolFlags, symbolExcludes); + } + else { + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } - bindChildren(node, symbolFlags, isBlockScopeContainer); } function isAmbientContext(node: Node): boolean { @@ -355,15 +368,15 @@ module ts { function bindModuleDeclaration(node: ModuleDeclaration) { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { - bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); } else { let state = getModuleInstanceState(node); if (state === ModuleInstanceState.NonInstantiated) { - bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true); } else { - bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; if (node.symbol.constEnumOnlyModule === undefined) { // non-merged case - use the current state @@ -437,7 +450,7 @@ module ts { switch (node.kind) { case SyntaxKind.TypeParameter: - bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); break; case SyntaxKind.Parameter: bindParameter(node); @@ -451,7 +464,7 @@ module ts { bindBlockScopedVariableDeclaration(node); } else { - bindDeclaration(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes, /*isBlockScopeContainer*/ false); } break; case SyntaxKind.PropertyDeclaration: @@ -468,7 +481,7 @@ module ts { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - bindDeclaration(node, SymbolFlags.Signature, 0, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Signature, 0, /*isBlockScopeContainer*/ false); break; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: @@ -480,10 +493,10 @@ module ts { isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true); break; case SyntaxKind.FunctionDeclaration: - bindDeclaration(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes, /*isBlockScopeContainer*/ true); break; case SyntaxKind.Constructor: - bindDeclaration(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true); break; case SyntaxKind.GetAccessor: bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true); @@ -517,17 +530,17 @@ module ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); break; case SyntaxKind.InterfaceDeclaration: - bindDeclaration(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false); break; case SyntaxKind.TypeAliasDeclaration: - bindDeclaration(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false); break; case SyntaxKind.EnumDeclaration: if (isConst(node)) { - bindDeclaration(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false); } else { - bindDeclaration(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false); } break; case SyntaxKind.ModuleDeclaration: @@ -537,11 +550,11 @@ module ts { case SyntaxKind.NamespaceImport: case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - bindDeclaration(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false); break; case SyntaxKind.ImportClause: if ((node).name) { - bindDeclaration(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false); } else { bindChildren(node, 0, /*isBlockScopeContainer*/ false); @@ -600,7 +613,7 @@ module ts { bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node), /*isBlockScopeContainer*/ false); } else { - bindDeclaration(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false); } // If this is a property-parameter, then also declare the property symbol into the @@ -619,7 +632,7 @@ module ts { bindAnonymousDeclaration(node, symbolFlags, "__computed", isBlockScopeContainer); } else { - bindDeclaration(node, symbolFlags, symbolExcludes, isBlockScopeContainer); + declareSymbolForDeclarationAndBindChildren(node, symbolFlags, symbolExcludes, isBlockScopeContainer); } } } From 9e64b4500118a662c9087f42997d9a1e242d81f0 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 14:57:35 -0700 Subject: [PATCH 005/402] Add explanatory comments to the binder. --- src/compiler/binder.ts | 59 ++++++++++++++++++++++++++++++++---------- src/compiler/types.ts | 9 ++++--- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index af7226eee2d..0beed9b1152 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -277,16 +277,51 @@ module ts { } function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean): void { + // First we declare a symbol for the provided node. The symbol will be added to an + // appropriate symbol table. Possible symbol tables include: + // + // 1) The 'exports' table of the current container's symbol. + // 2) The 'members' table of the current container's symbol. + // 3) The 'locals' table of the current container. + // + // Then, we recurse down the children of this declaration, seeking more declarations + // to bind. + declareSymbolAndAddToAppropriateContainer(node, symbolFlags, symbolExcludes, isBlockScopeContainer); bindChildren(node, symbolFlags, isBlockScopeContainer); } function declareSymbolAndAddToAppropriateContainer(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean): Symbol { switch (container.kind) { + // Modules, source files, and classes need specialized handling for how their + // members are declared (for example, a member of a class will go into a specific + // symbol table depending on if it is static or not). As such, we defer to + // specialized handlers to take care of declaring these child members. case SyntaxKind.ModuleDeclaration: return declareModuleMember(node, symbolFlags, symbolExcludes); + case SyntaxKind.SourceFile: - return declareSourceFileMember(container, node, symbolFlags, symbolExcludes); + return declareSourceFileMember(node, symbolFlags, symbolExcludes); + + case SyntaxKind.ClassExpression: + case SyntaxKind.ClassDeclaration: + return declareClassMember(node, symbolFlags, symbolExcludes); + + case SyntaxKind.EnumDeclaration: + // Enum members are always put int the 'exports' of the containing enum. + // They are only accessibly through their container, and are never in + // scope otherwise (even inside the body of the enum declaring them.). + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + + case SyntaxKind.TypeLiteral: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.InterfaceDeclaration: + // Interface/Object-types always have their children added to the 'members' of + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: @@ -300,16 +335,14 @@ module ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: + // All the children of these container types are never visible through another + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // more or less, they're only accessed 'lexically' (i.e. from code that exists + // underneath their container in the tree. To accomplish this, we simply add + // their declared symbol to the 'locals' of the container. These symbols can + // then be found as the type checker walks up the containers, checking them + // for matching names. return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - case SyntaxKind.ClassExpression: - case SyntaxKind.ClassDeclaration: - return declareClassMember(node, symbolFlags, symbolExcludes); - case SyntaxKind.TypeLiteral: - case SyntaxKind.ObjectLiteralExpression: - case SyntaxKind.InterfaceDeclaration: - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case SyntaxKind.EnumDeclaration: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } } @@ -322,12 +355,12 @@ module ts { } } - function declareSourceFileMember(container: SourceFile, node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - if (isExternalModule(container)) { + function declareSourceFileMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + if (isExternalModule(file)) { return declareModuleMember(node, symbolFlags, symbolExcludes); } else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 078f3d060a6..6b1191f4a5e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1360,14 +1360,15 @@ module ts { export interface Symbol { flags: SymbolFlags; // Symbol flags name: string; // Name of symbol - /* @internal */ id?: number; // Unique id (used to look up SymbolLinks) - /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) declarations?: Declaration[]; // Declarations associated with this symbol - /* @internal */ parent?: Symbol; // Parent symbol + valueDeclaration?: Declaration; // First value declaration of the symbol + members?: SymbolTable; // Class, interface or literal instance members exports?: SymbolTable; // Module exports + /* @internal */ id?: number; // Unique id (used to look up SymbolLinks) + /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) + /* @internal */ parent?: Symbol; // Parent symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol - valueDeclaration?: Declaration; // First value declaration of the symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums } From e7ddba508ab30e4961467cdeb1e2c9e06e877e2c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 15:50:02 -0700 Subject: [PATCH 006/402] Merge block container logic in the binder to use the same mechanism as SymbolFlags --- src/compiler/binder.ts | 96 +++++++++++++++++++++--------------------- src/compiler/types.ts | 2 + 2 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 0beed9b1152..9670b44d80e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -241,7 +241,7 @@ module ts { // All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function // in the type checker to validate that the local name used for a container is unique. - function bindChildren(node: Node, symbolFlags: SymbolFlags, isBlockScopeContainer: boolean) { + function bindChildren(node: Node, symbolFlags: SymbolFlags) { if (symbolFlags & SymbolFlags.HasLocals) { node.locals = {}; } @@ -260,7 +260,7 @@ module ts { lastContainer = container; } - if (isBlockScopeContainer) { + if (symbolFlags & SymbolFlags.IsBlockScopedContainer) { // in incremental scenarios we might reuse nodes that already have locals being allocated // during the bind step these locals should be dropped to prevent using stale data. // locals should always be dropped unless they were previously initialized by the binder @@ -276,7 +276,7 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } - function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean): void { + function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { // First we declare a symbol for the provided node. The symbol will be added to an // appropriate symbol table. Possible symbol tables include: // @@ -287,11 +287,11 @@ module ts { // Then, we recurse down the children of this declaration, seeking more declarations // to bind. - declareSymbolAndAddToAppropriateContainer(node, symbolFlags, symbolExcludes, isBlockScopeContainer); - bindChildren(node, symbolFlags, isBlockScopeContainer); + declareSymbolAndAddToAppropriateContainer(node, symbolFlags, symbolExcludes); + bindChildren(node, symbolFlags); } - function declareSymbolAndAddToAppropriateContainer(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean): Symbol { + function declareSymbolAndAddToAppropriateContainer(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { switch (container.kind) { // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific @@ -401,15 +401,15 @@ module ts { function bindModuleDeclaration(node: ModuleDeclaration) { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } else { let state = getModuleInstanceState(node); if (state === ModuleInstanceState.NonInstantiated) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; if (node.symbol.constEnumOnlyModule === undefined) { // non-merged case - use the current state @@ -433,21 +433,21 @@ module ts { let name = getDeclarationName(node); let symbol = createSymbol(SymbolFlags.Signature, name); addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); - bindChildren(node, SymbolFlags.Signature, /*isBlockScopeContainer:*/ false); + bindChildren(node, SymbolFlags.Signature); let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = { [name]: symbol }; } - function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string, isBlockScopeContainer: boolean) { + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { let symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); - bindChildren(node, symbolFlags, isBlockScopeContainer); + bindChildren(node, symbolFlags); } function bindCatchVariableDeclaration(node: CatchClause) { - bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true); + bindChildren(node, SymbolFlags.BlockScopedContainer); } function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { @@ -467,7 +467,7 @@ module ts { } declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); } - bindChildren(node, symbolFlags, /*isBlockScopeContainer*/ false); + bindChildren(node, symbolFlags); } function bindBlockScopedVariableDeclaration(node: Declaration) { @@ -483,7 +483,7 @@ module ts { switch (node.kind) { case SyntaxKind.TypeParameter: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); break; case SyntaxKind.Parameter: bindParameter(node); @@ -491,30 +491,30 @@ module ts { case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: if (isBindingPattern((node).name)) { - bindChildren(node, 0, /*isBlockScopeContainer*/ false); + bindChildren(node, 0); } else if (isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); } break; case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false); + bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes); break; case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false); + bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); break; case SyntaxKind.EnumMember: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false); + bindPropertyOrMethodOrAccessor(node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes); break; case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Signature, 0, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Signature, 0); break; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: @@ -523,19 +523,19 @@ module ts { // so that it will conflict with any other object literal members with the same // name. bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : 0), - isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true); + isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); break; case SyntaxKind.FunctionDeclaration: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes, /*isBlockScopeContainer*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); break; case SyntaxKind.Constructor: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0); break; case SyntaxKind.GetAccessor: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true); + bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); break; case SyntaxKind.SetAccessor: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true); + bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); break; case SyntaxKind.FunctionType: @@ -544,17 +544,17 @@ module ts { break; case SyntaxKind.TypeLiteral: - bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false); + bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type"); break; case SyntaxKind.ObjectLiteralExpression: - bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object", /*isBlockScopeContainer*/ false); + bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); break; case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - bindAnonymousDeclaration(node, SymbolFlags.Function, "__function", /*isBlockScopeContainer*/ true); + bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); break; case SyntaxKind.ClassExpression: - bindAnonymousDeclaration(node, SymbolFlags.Class, "__class", /*isBlockScopeContainer*/ false); + bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); break; case SyntaxKind.CatchClause: bindCatchVariableDeclaration(node); @@ -563,17 +563,17 @@ module ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); break; case SyntaxKind.InterfaceDeclaration: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); break; case SyntaxKind.TypeAliasDeclaration: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); break; case SyntaxKind.EnumDeclaration: if (isConst(node)) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); } break; case SyntaxKind.ModuleDeclaration: @@ -583,14 +583,14 @@ module ts { case SyntaxKind.NamespaceImport: case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); break; case SyntaxKind.ImportClause: if ((node).name) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } else { - bindChildren(node, 0, /*isBlockScopeContainer*/ false); + bindChildren(node, 0); } break; case SyntaxKind.ExportDeclaration: @@ -598,7 +598,7 @@ module ts { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, 0); } - bindChildren(node, 0, /*isBlockScopeContainer*/ false); + bindChildren(node, 0); break; case SyntaxKind.ExportAssignment: if ((node).expression.kind === SyntaxKind.Identifier) { @@ -609,12 +609,12 @@ module ts { // An export default clause with an expression exports a value declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } - bindChildren(node, 0, /*isBlockScopeContainer*/ false); + bindChildren(node, 0); break; case SyntaxKind.SourceFile: setExportContextFlag(node); if (isExternalModule(node)) { - bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"', /*isBlockScopeContainer*/ true); + bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"'); break; } case SyntaxKind.Block: @@ -626,27 +626,27 @@ module ts { // let x; // } // 'let x' will be placed into the function locals and 'let x' - into the locals of the block - bindChildren(node, 0, /*isBlockScopeContainer*/ !isFunctionLike(node.parent)); + bindChildren(node, isFunctionLike(node.parent) ? 0 : SymbolFlags.BlockScopedContainer); break; case SyntaxKind.CatchClause: case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.CaseBlock: - bindChildren(node, 0, /*isBlockScopeContainer*/ true); + bindChildren(node, SymbolFlags.BlockScopedContainer); break; default: - bindChildren(node, 0, /*isBlockScopeContainer*/ false); + bindChildren(node, 0); break; } } function bindParameter(node: ParameterDeclaration) { if (isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node), /*isBlockScopeContainer*/ false); + bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false); + declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); } // If this is a property-parameter, then also declare the property symbol into the @@ -660,12 +660,12 @@ module ts { } } - function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { if (hasDynamicName(node)) { - bindAnonymousDeclaration(node, symbolFlags, "__computed", isBlockScopeContainer); + bindAnonymousDeclaration(node, symbolFlags, "__computed"); } else { - declareSymbolForDeclarationAndBindChildren(node, symbolFlags, symbolExcludes, isBlockScopeContainer); + declareSymbolForDeclarationAndBindChildren(node, symbolFlags, symbolExcludes); } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6b1191f4a5e..5b5150ab132 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1310,6 +1310,7 @@ module ts { UnionProperty = 0x10000000, // Property in union type Optional = 0x20000000, // Optional property ExportStar = 0x40000000, // Export * declaration + BlockScopedContainer = 0x80000000, Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, @@ -1352,6 +1353,7 @@ module ts { HasExports = Class | Enum | Module, HasMembers = Class | Interface | TypeLiteral | ObjectLiteral, + IsBlockScopedContainer = BlockScopedContainer | Module | Function | Accessor | Method | Constructor, IsContainer = HasLocals | HasExports | HasMembers, PropertyOrAccessor = Property | Accessor, Export = ExportNamespace | ExportType | ExportValue, From b75fda1052f637853802962fa8793c2fe1b2d4ad Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 15:55:21 -0700 Subject: [PATCH 007/402] Explicitly type 'bind' as being a void function. --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 9670b44d80e..1665da1431f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -478,7 +478,7 @@ module ts { return "__" + indexOf((node.parent).parameters, node); } - function bind(node: Node) { + function bind(node: Node): void { node.parent = parent; switch (node.kind) { From 9043121188f6d6544bdb599bb2660d8da9231a89 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:02:07 -0700 Subject: [PATCH 008/402] Add a 'None' member to SymbolFlags enum. --- src/compiler/binder.ts | 1 - src/compiler/types.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1665da1431f..f5364f71d13 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -480,7 +480,6 @@ module ts { function bind(node: Node): void { node.parent = parent; - switch (node.kind) { case SyntaxKind.TypeParameter: declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5b5150ab132..010b6308348 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1279,6 +1279,7 @@ module ts { } export const enum SymbolFlags { + None = 0, FunctionScopedVariable = 0x00000001, // Variable (var) or parameter BlockScopedVariable = 0x00000002, // A block-scoped variable (let or const) Property = 0x00000004, // Property or enum member From c5d920e912585084dbe04d7993890a43ed6a511d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:23:56 -0700 Subject: [PATCH 009/402] Simplify recursion in the binder. We now only recurse in a single place in the binder. The rest of the binding code is only concerned with how to bind a single node to a symbol and add that symbol to a symbol table. Recursion is handled as a separate concern, greatly simplifying binder flow. --- src/compiler/binder.ts | 193 +++++++++++++++++++++-------------------- 1 file changed, 100 insertions(+), 93 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f5364f71d13..cee2ff08a78 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -276,7 +276,7 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } - function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { + function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { // First we declare a symbol for the provided node. The symbol will be added to an // appropriate symbol table. Possible symbol tables include: // @@ -288,7 +288,7 @@ module ts { // to bind. declareSymbolAndAddToAppropriateContainer(node, symbolFlags, symbolExcludes); - bindChildren(node, symbolFlags); + return symbolFlags; } function declareSymbolAndAddToAppropriateContainer(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { @@ -401,16 +401,25 @@ module ts { function bindModuleDeclaration(node: ModuleDeclaration) { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } else { let state = getModuleInstanceState(node); if (state === ModuleInstanceState.NonInstantiated) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + } + } + } + + function postBindModuleDeclarationChildren(node: ModuleDeclaration) { + if (node.name.kind !== SyntaxKind.StringLiteral) { + let state = getModuleInstanceState(node); + if (state !== ModuleInstanceState.NonInstantiated) { let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; + if (node.symbol.constEnumOnlyModule === undefined) { // non-merged case - use the current state node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; @@ -423,7 +432,7 @@ module ts { } } - function bindFunctionOrConstructorType(node: SignatureDeclaration) { + function bindFunctionOrConstructorType(node: SignatureDeclaration): SymbolFlags { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // @@ -433,24 +442,24 @@ module ts { let name = getDeclarationName(node); let symbol = createSymbol(SymbolFlags.Signature, name); addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); - bindChildren(node, SymbolFlags.Signature); + return SymbolFlags.Signature; + } + function postBindFunctionOrConstructorTypeChildren(node: SignatureDeclaration): void { + let symbol = node.symbol; + let name = symbol.name; let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = { [name]: symbol }; } - function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string): SymbolFlags { let symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); - bindChildren(node, symbolFlags); + return symbolFlags; } - function bindCatchVariableDeclaration(node: CatchClause) { - bindChildren(node, SymbolFlags.BlockScopedContainer); - } - - function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { switch (blockScopeContainer.kind) { case SyntaxKind.ModuleDeclaration: declareModuleMember(node, symbolFlags, symbolExcludes); @@ -467,11 +476,12 @@ module ts { } declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); } - bindChildren(node, symbolFlags); + + return symbolFlags; } - function bindBlockScopedVariableDeclaration(node: Declaration) { - bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); + function bindBlockScopedVariableDeclaration(node: Declaration): SymbolFlags { + return bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); } function getDestructuringParameterName(node: Declaration) { @@ -479,126 +489,112 @@ module ts { } function bind(node: Node): void { + // First we bind declaration nodes to a symbol if possible. We'll both create a symbol + // and add the symbol to an appropriate symbol table. The symbolFlags that are retuerned + // from this help inform how we recurse into the children of this node. + var symbolFlags = bindWorker(node); + + // Then we recurse into the children of the node to bind them as well. For certain + // symbols we do specialized work when we recurse. For example, we'll keep track of + // the current 'container' node when it changes. This helps us know which symbol table + // a local should go into for example. + bindChildren(node, symbolFlags); + + // Allow certain nodes to do specialized work after their children have been bound. + postBindChildren(node); + } + + function bindWorker(node: Node): SymbolFlags { node.parent = parent; switch (node.kind) { case SyntaxKind.TypeParameter: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); case SyntaxKind.Parameter: - bindParameter(node); - break; + return bindParameter(node); case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: if (isBindingPattern((node).name)) { - bindChildren(node, 0); + return SymbolFlags.None; } else if (isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); + return bindBlockScopedVariableDeclaration(node); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); } - break; case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes); - break; + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes); case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); - break; + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); case SyntaxKind.EnumMember: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes); - break; + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes); case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Signature, 0); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Signature, 0); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : 0), + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : 0), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); - break; case SyntaxKind.FunctionDeclaration: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); case SyntaxKind.Constructor: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0); case SyntaxKind.GetAccessor: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); - break; + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); case SyntaxKind.SetAccessor: - bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); - break; - + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: - bindFunctionOrConstructorType(node); - break; - + return bindFunctionOrConstructorType(node); case SyntaxKind.TypeLiteral: - bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type"); - break; + return bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type"); case SyntaxKind.ObjectLiteralExpression: - bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); - break; + return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); - break; + return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); case SyntaxKind.ClassExpression: - bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); - break; - case SyntaxKind.CatchClause: - bindCatchVariableDeclaration(node); - break; + return bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); case SyntaxKind.ClassDeclaration: - bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); - break; + return bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); case SyntaxKind.InterfaceDeclaration: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); case SyntaxKind.TypeAliasDeclaration: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); case SyntaxKind.EnumDeclaration: if (isConst(node)) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); } - break; case SyntaxKind.ModuleDeclaration: - bindModuleDeclaration(node); - break; + return bindModuleDeclaration(node); case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.NamespaceImport: case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); - break; + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); case SyntaxKind.ImportClause: if ((node).name) { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } else { - bindChildren(node, 0); + return SymbolFlags.None; } - break; case SyntaxKind.ExportDeclaration: if (!(node).exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, 0); } - bindChildren(node, 0); - break; + return SymbolFlags.None; case SyntaxKind.ExportAssignment: if ((node).expression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier @@ -608,14 +604,14 @@ module ts { // An export default clause with an expression exports a value declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } - bindChildren(node, 0); - break; + return SymbolFlags.None; case SyntaxKind.SourceFile: setExportContextFlag(node); if (isExternalModule(node)) { - bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"'); - break; + return bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"'); } + // fall through. + case SyntaxKind.Block: // do not treat function block a block-scope container // all block-scope locals that reside in this block should go to the function locals. @@ -625,29 +621,40 @@ module ts { // let x; // } // 'let x' will be placed into the function locals and 'let x' - into the locals of the block - bindChildren(node, isFunctionLike(node.parent) ? 0 : SymbolFlags.BlockScopedContainer); - break; + return isFunctionLike(node.parent) ? 0 : SymbolFlags.BlockScopedContainer; case SyntaxKind.CatchClause: case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.CaseBlock: - bindChildren(node, SymbolFlags.BlockScopedContainer); - break; - default: - bindChildren(node, 0); - break; + return SymbolFlags.BlockScopedContainer; + } + + return SymbolFlags.None; + } + + function postBindChildren(node: Node) { + switch (node.kind) { + case SyntaxKind.Parameter: + return postParameterChildren(node); + case SyntaxKind.ModuleDeclaration: + return postBindModuleDeclarationChildren(node); + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return postBindFunctionOrConstructorTypeChildren(node); } } - function bindParameter(node: ParameterDeclaration) { + function bindParameter(node: ParameterDeclaration): SymbolFlags { if (isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); + return bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } else { - declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); } + } + function postParameterChildren(node: ParameterDeclaration): void { // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & NodeFlags.AccessibilityModifier && @@ -659,12 +666,12 @@ module ts { } } - function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { if (hasDynamicName(node)) { - bindAnonymousDeclaration(node, symbolFlags, "__computed"); + return bindAnonymousDeclaration(node, symbolFlags, "__computed"); } else { - declareSymbolForDeclarationAndBindChildren(node, symbolFlags, symbolExcludes); + return declareSymbolForDeclarationAndBindChildren(node, symbolFlags, symbolExcludes); } } } From 02640a397f8af4b7d33e9cd2b6e4c62a6dd85d34 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:37:24 -0700 Subject: [PATCH 010/402] Extract any complicated code in top level bind function to individual helpers. --- src/compiler/binder.ts | 102 ++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 41 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cee2ff08a78..fdff9d2e7ea 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -513,15 +513,7 @@ module ts { return bindParameter(node); case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: - if (isBindingPattern((node).name)) { - return SymbolFlags.None; - } - else if (isBlockOrCatchScoped(node)) { - return bindBlockScopedVariableDeclaration(node); - } - else { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); - } + return bindVariableDeclarationOrBindingElement(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes); @@ -569,12 +561,7 @@ module ts { case SyntaxKind.TypeAliasDeclaration: return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); case SyntaxKind.EnumDeclaration: - if (isConst(node)) { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes); - } - else { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); - } + return bindEnumDeclaration(node); case SyntaxKind.ModuleDeclaration: return bindModuleDeclaration(node); case SyntaxKind.ImportEqualsDeclaration: @@ -583,35 +570,13 @@ module ts { case SyntaxKind.ExportSpecifier: return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); case SyntaxKind.ImportClause: - if ((node).name) { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); - } - else { - return SymbolFlags.None; - } + return bindImportClause(node); case SyntaxKind.ExportDeclaration: - if (!(node).exportClause) { - // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, 0); - } - return SymbolFlags.None; + return bindExportDeclaration(node); case SyntaxKind.ExportAssignment: - if ((node).expression.kind === SyntaxKind.Identifier) { - // An export default clause with an identifier exports all meanings of that identifier - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); - } - else { - // An export default clause with an expression exports a value - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); - } - return SymbolFlags.None; + return bindExportAssignment(node); case SyntaxKind.SourceFile: - setExportContextFlag(node); - if (isExternalModule(node)) { - return bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"'); - } - // fall through. - + return bindSourceFileIfExternalModule(); case SyntaxKind.Block: // do not treat function block a block-scope container // all block-scope locals that reside in this block should go to the function locals. @@ -645,6 +610,61 @@ module ts { } } + function bindSourceFileIfExternalModule() { + setExportContextFlag(file); + return isExternalModule(file) + ? bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"') + : SymbolFlags.BlockScopedContainer; + } + + function bindExportAssignment(node: ExportAssignment) { + if (node.expression.kind === SyntaxKind.Identifier) { + // An export default clause with an identifier exports all meanings of that identifier + declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); + } + else { + // An export default clause with an expression exports a value + declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); + } + + return SymbolFlags.None; + } + + function bindExportDeclaration(node: ExportDeclaration) { + if (!node.exportClause) { + // All export * declarations are collected in an __export symbol + declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, 0); + } + return SymbolFlags.None; + } + + function bindImportClause(node: ImportClause) { + if (node.name) { + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + } + else { + return SymbolFlags.None; + } + } + + function bindEnumDeclaration(node: EnumDeclaration) { + return isConst(node) + ? declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) + : declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); + } + + function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { + if (isBindingPattern(node.name)) { + return SymbolFlags.None; + } + else if (isBlockOrCatchScoped(node)) { + return bindBlockScopedVariableDeclaration(node); + } + else { + return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + } + } + function bindParameter(node: ParameterDeclaration): SymbolFlags { if (isBindingPattern(node.name)) { return bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); From fb925ee4d136792fc1ed4283b5840187cdc43759 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:39:09 -0700 Subject: [PATCH 011/402] Rename methods. --- src/compiler/binder.ts | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index fdff9d2e7ea..b994f3ea7bc 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -276,7 +276,7 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } - function declareSymbolForDeclarationAndBindChildren(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { + function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { // First we declare a symbol for the provided node. The symbol will be added to an // appropriate symbol table. Possible symbol tables include: // @@ -287,11 +287,11 @@ module ts { // Then, we recurse down the children of this declaration, seeking more declarations // to bind. - declareSymbolAndAddToAppropriateContainer(node, symbolFlags, symbolExcludes); + declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); return symbolFlags; } - function declareSymbolAndAddToAppropriateContainer(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { + function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { switch (container.kind) { // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific @@ -401,15 +401,15 @@ module ts { function bindModuleDeclaration(node: ModuleDeclaration) { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } else { let state = getModuleInstanceState(node); if (state === ModuleInstanceState.NonInstantiated) { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } else { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } } } @@ -508,7 +508,7 @@ module ts { node.parent = parent; switch (node.kind) { case SyntaxKind.TypeParameter: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); case SyntaxKind.Parameter: return bindParameter(node); case SyntaxKind.VariableDeclaration: @@ -525,7 +525,7 @@ module ts { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Signature, 0); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Signature, 0); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: // If this is an ObjectLiteralExpression method, then it sits in the same space @@ -535,9 +535,9 @@ module ts { return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : 0), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); case SyntaxKind.Constructor: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0); case SyntaxKind.GetAccessor: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); case SyntaxKind.SetAccessor: @@ -557,9 +557,9 @@ module ts { case SyntaxKind.ClassDeclaration: return bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); case SyntaxKind.InterfaceDeclaration: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); case SyntaxKind.TypeAliasDeclaration: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); case SyntaxKind.EnumDeclaration: return bindEnumDeclaration(node); case SyntaxKind.ModuleDeclaration: @@ -568,7 +568,7 @@ module ts { case SyntaxKind.NamespaceImport: case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); case SyntaxKind.ImportClause: return bindImportClause(node); case SyntaxKind.ExportDeclaration: @@ -640,7 +640,7 @@ module ts { function bindImportClause(node: ImportClause) { if (node.name) { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } else { return SymbolFlags.None; @@ -649,8 +649,8 @@ module ts { function bindEnumDeclaration(node: EnumDeclaration) { return isConst(node) - ? declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) - : declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); + ? declareSymbolAndAddToSymbolTable(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) + : declareSymbolAndAddToSymbolTable(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); } function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { @@ -661,7 +661,7 @@ module ts { return bindBlockScopedVariableDeclaration(node); } else { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); } } @@ -670,7 +670,7 @@ module ts { return bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } else { - return declareSymbolForDeclarationAndBindChildren(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); } } @@ -691,7 +691,7 @@ module ts { return bindAnonymousDeclaration(node, symbolFlags, "__computed"); } else { - return declareSymbolForDeclarationAndBindChildren(node, symbolFlags, symbolExcludes); + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } } From eb29eb9acd5074c1e8ca698e4d34013492a988c4 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:43:42 -0700 Subject: [PATCH 012/402] Remove code to post bind parameters. --- src/compiler/binder.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b994f3ea7bc..3d9204c81a9 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -600,8 +600,6 @@ module ts { function postBindChildren(node: Node) { switch (node.kind) { - case SyntaxKind.Parameter: - return postParameterChildren(node); case SyntaxKind.ModuleDeclaration: return postBindModuleDeclarationChildren(node); case SyntaxKind.FunctionType: @@ -667,14 +665,12 @@ module ts { function bindParameter(node: ParameterDeclaration): SymbolFlags { if (isBindingPattern(node.name)) { - return bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); + bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } else { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); + declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); } - } - function postParameterChildren(node: ParameterDeclaration): void { // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & NodeFlags.AccessibilityModifier && @@ -684,6 +680,8 @@ module ts { let classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); } + + return SymbolFlags.FunctionScopedVariable; } function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { From fab6fca5b4af8685ace4496a02db8eb312662605 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:48:28 -0700 Subject: [PATCH 013/402] Remove post bind step for modules. --- src/compiler/binder.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3d9204c81a9..d214cba6140 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -409,17 +409,9 @@ module ts { return declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } else { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); - } - } - } + let result = declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); - function postBindModuleDeclarationChildren(node: ModuleDeclaration) { - if (node.name.kind !== SyntaxKind.StringLiteral) { - let state = getModuleInstanceState(node); - if (state !== ModuleInstanceState.NonInstantiated) { let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; - if (node.symbol.constEnumOnlyModule === undefined) { // non-merged case - use the current state node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; @@ -428,6 +420,8 @@ module ts { // merged case: module is const enum only if all its pieces are non-instantiated or const enum node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; } + + return result; } } } @@ -600,8 +594,6 @@ module ts { function postBindChildren(node: Node) { switch (node.kind) { - case SyntaxKind.ModuleDeclaration: - return postBindModuleDeclarationChildren(node); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: return postBindFunctionOrConstructorTypeChildren(node); From ea7bafa9fb0e4a95e879fc5ca024726d3aedae06 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:54:09 -0700 Subject: [PATCH 014/402] Remove unncessary postbind for function/constructor types. --- src/compiler/binder.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d214cba6140..381e2750fd5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -436,15 +436,12 @@ module ts { let name = getDeclarationName(node); let symbol = createSymbol(SymbolFlags.Signature, name); addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); - return SymbolFlags.Signature; - } - function postBindFunctionOrConstructorTypeChildren(node: SignatureDeclaration): void { - let symbol = node.symbol; - let name = symbol.name; let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = { [name]: symbol }; + + return SymbolFlags.Signature; } function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string): SymbolFlags { @@ -483,6 +480,8 @@ module ts { } function bind(node: Node): void { + node.parent = parent; + // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and add the symbol to an appropriate symbol table. The symbolFlags that are retuerned // from this help inform how we recurse into the children of this node. @@ -493,13 +492,9 @@ module ts { // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. bindChildren(node, symbolFlags); - - // Allow certain nodes to do specialized work after their children have been bound. - postBindChildren(node); } function bindWorker(node: Node): SymbolFlags { - node.parent = parent; switch (node.kind) { case SyntaxKind.TypeParameter: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); @@ -592,14 +587,6 @@ module ts { return SymbolFlags.None; } - function postBindChildren(node: Node) { - switch (node.kind) { - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return postBindFunctionOrConstructorTypeChildren(node); - } - } - function bindSourceFileIfExternalModule() { setExportContextFlag(file); return isExternalModule(file) From db128252b0b59ca0fe0ef8fa437a64e35439f077 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 16:57:44 -0700 Subject: [PATCH 015/402] Simplify code in the binder. --- src/compiler/binder.ts | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 381e2750fd5..56022bc61d4 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -347,21 +347,15 @@ module ts { } function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - if (node.flags & NodeFlags.Static) { - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - } - else { - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - } + return node.flags & NodeFlags.Static + ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) + : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } function declareSourceFileMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - if (isExternalModule(file)) { - return declareModuleMember(node, symbolFlags, symbolExcludes); - } - else { - return declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); - } + return isExternalModule(file) + ? declareModuleMember(node, symbolFlags, symbolExcludes) + : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function isAmbientContext(node: Node): boolean { @@ -616,12 +610,9 @@ module ts { } function bindImportClause(node: ImportClause) { - if (node.name) { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); - } - else { - return SymbolFlags.None; - } + return node.name + ? declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes) + : SymbolFlags.None; } function bindEnumDeclaration(node: EnumDeclaration) { @@ -664,12 +655,9 @@ module ts { } function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { - if (hasDynamicName(node)) { - return bindAnonymousDeclaration(node, symbolFlags, "__computed"); - } - else { - return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); - } + return hasDynamicName(node) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed") + : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } } From 941128ba79483a73a3ba3800f1201c6d89a3e962 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 17:02:49 -0700 Subject: [PATCH 016/402] Clean up comments. --- src/compiler/binder.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 56022bc61d4..4fca9a65508 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -277,16 +277,6 @@ module ts { } function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { - // First we declare a symbol for the provided node. The symbol will be added to an - // appropriate symbol table. Possible symbol tables include: - // - // 1) The 'exports' table of the current container's symbol. - // 2) The 'members' table of the current container's symbol. - // 3) The 'locals' table of the current container. - // - // Then, we recurse down the children of this declaration, seeking more declarations - // to bind. - declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); return symbolFlags; } @@ -477,8 +467,17 @@ module ts { node.parent = parent; // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and add the symbol to an appropriate symbol table. The symbolFlags that are retuerned - // from this help inform how we recurse into the children of this node. + // and add the symbol to an appropriate symbol table (if appropriate). The symbolFlags + // that are returned from this help inform how we recurse into the children of this node. + // + // Possible destination symbol tables are: + // + // 1) The 'exports' table of the current container's symbol. + // 2) The 'members' table of the current container's symbol. + // 3) The 'locals' table of the current container. + // + // However, not all symbols will end up in any of these tables. 'Anonymous' symbols + // (like TypeLiterals for example) will not be put in any table. var symbolFlags = bindWorker(node); // Then we recurse into the children of the node to bind them as well. For certain From 44559954772fe222c4025644a9e1488b48c33e4f Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 17:09:17 -0700 Subject: [PATCH 017/402] Move all symbol table initialization into the same method. --- src/compiler/binder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4fca9a65508..5d449b8b4b1 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -90,6 +90,9 @@ module ts { symbol.flags |= symbolFlags; node.symbol = symbol; + if (symbolFlags & SymbolFlags.HasLocals) { + node.locals = {}; + } if (!symbol.declarations) { symbol.declarations = []; @@ -242,10 +245,6 @@ module ts { // All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function // in the type checker to validate that the local name used for a container is unique. function bindChildren(node: Node, symbolFlags: SymbolFlags) { - if (symbolFlags & SymbolFlags.HasLocals) { - node.locals = {}; - } - let saveParent = parent; let saveContainer = container; let savedBlockScopeContainer = blockScopeContainer; @@ -271,6 +270,7 @@ module ts { } forEachChild(node, bind); + container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; From 221262314c8e1c6d0ae425018e99175ad7c583b8 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 17:14:31 -0700 Subject: [PATCH 018/402] Inline binder method. --- src/compiler/binder.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5d449b8b4b1..fa9cc95128e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -68,8 +68,7 @@ module ts { if (!file.locals) { file.locals = {}; - container = file; - setBlockScopeContainer(file, /*cleanLocals*/ false); + container = blockScopeContainer = file; bind(file); file.symbolCount = symbolCount; } @@ -79,13 +78,6 @@ module ts { return new Symbol(flags, name); } - function setBlockScopeContainer(node: Node, cleanLocals: boolean) { - blockScopeContainer = node; - if (cleanLocals) { - blockScopeContainer.locals = undefined; - } - } - function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolFlags: SymbolFlags) { symbol.flags |= symbolFlags; @@ -266,7 +258,10 @@ module ts { // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, /*cleanLocals*/ (symbolFlags & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); + blockScopeContainer = node; + if ((symbolFlags & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile) { + blockScopeContainer.locals = undefined; + } } forEachChild(node, bind); From 4f8d68bb23a44f6f8603e8e64de009f83a5bbf92 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 17:31:52 -0700 Subject: [PATCH 019/402] Use SymbolFlags.None in the binder. --- src/compiler/binder.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index fa9cc95128e..7abf9d27cc5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -151,7 +151,7 @@ module ts { let symbol: Symbol; if (name !== undefined) { - symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); + symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(SymbolFlags.None, name)); if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -168,11 +168,11 @@ module ts { }); file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, name); + symbol = createSymbol(SymbolFlags.None, name); } } else { - symbol = createSymbol(0, "__missing"); + symbol = createSymbol(SymbolFlags.None, "__missing"); } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; @@ -493,7 +493,7 @@ module ts { return bindVariableDeclarationOrBindingElement(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes); + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes); case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); @@ -502,19 +502,19 @@ module ts { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Signature, 0); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Signature, SymbolFlags.None); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : 0), + return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); case SyntaxKind.Constructor: - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Constructor, /*symbolExcludes:*/ SymbolFlags.None); case SyntaxKind.GetAccessor: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); case SyntaxKind.SetAccessor: @@ -563,7 +563,7 @@ module ts { // let x; // } // 'let x' will be placed into the function locals and 'let x' - into the locals of the block - return isFunctionLike(node.parent) ? 0 : SymbolFlags.BlockScopedContainer; + return isFunctionLike(node.parent) ? SymbolFlags.None : SymbolFlags.BlockScopedContainer; case SyntaxKind.CatchClause: case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: @@ -598,7 +598,7 @@ module ts { function bindExportDeclaration(node: ExportDeclaration) { if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, 0); + declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None); } return SymbolFlags.None; } From 38bae987284d4561299ac5074947094a80c40dd1 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 23:06:42 -0700 Subject: [PATCH 020/402] CR feedback. --- src/compiler/binder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7abf9d27cc5..4f65c81bd53 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -293,8 +293,8 @@ module ts { return declareClassMember(node, symbolFlags, symbolExcludes); case SyntaxKind.EnumDeclaration: - // Enum members are always put int the 'exports' of the containing enum. - // They are only accessibly through their container, and are never in + // Enum members are always put in the 'exports' of the containing enum. + // They are only accessible through their container, and are never in // scope otherwise (even inside the body of the enum declaring them.). return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -462,7 +462,7 @@ module ts { node.parent = parent; // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and add the symbol to an appropriate symbol table (if appropriate). The symbolFlags + // and then potentially add the symbol to an appropriate symbol table. The symbolFlags // that are returned from this help inform how we recurse into the children of this node. // // Possible destination symbol tables are: From e9a73e0cf866f36db72478d275018d7755b4a34f Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 23:20:04 -0700 Subject: [PATCH 021/402] Move code for creating a prototype out of the common declareSymbol codepath. --- src/compiler/binder.ts | 50 ++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4f65c81bd53..a4bf77b22c1 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -174,26 +174,10 @@ module ts { else { symbol = createSymbol(SymbolFlags.None, "__missing"); } + addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if ((node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression) && symbol.exports) { - // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', - // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. - // It is an error to explicitly declare a static property member with the name 'prototype'. - let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], - Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - return symbol; } @@ -530,9 +514,8 @@ module ts { case SyntaxKind.ArrowFunction: return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); case SyntaxKind.ClassExpression: - return bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); case SyntaxKind.ClassDeclaration: - return bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); + return bindClassLikeDeclaration(node); case SyntaxKind.InterfaceDeclaration: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); case SyntaxKind.TypeAliasDeclaration: @@ -609,6 +592,35 @@ module ts { : SymbolFlags.None; } + function bindClassLikeDeclaration(node: ClassLikeDeclaration) { + if (node.kind === SyntaxKind.ClassDeclaration) { + bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); + } + else { + bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); + } + + let symbol = node.symbol; + if (symbol.exports) { + // TypeScript 1.0 spec (April 2014): 8.4 + // Every class automatically contains a static property member named 'prototype', + // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. + // It is an error to explicitly declare a static property member with the name 'prototype'. + let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); + if (hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], + Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + + return SymbolFlags.Class; + } + function bindEnumDeclaration(node: EnumDeclaration) { return isConst(node) ? declareSymbolAndAddToSymbolTable(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) From ee6c7dc0e480f149b967f0432896807466ab0f11 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 23:23:44 -0700 Subject: [PATCH 022/402] Remove unnecessary check. Classes always have exports. --- src/compiler/binder.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a4bf77b22c1..2100936c775 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -601,22 +601,21 @@ module ts { } let symbol = node.symbol; - if (symbol.exports) { - // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', - // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. - // It is an error to explicitly declare a static property member with the name 'prototype'. - let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], - Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + + // TypeScript 1.0 spec (April 2014): 8.4 + // Every class automatically contains a static property member named 'prototype', + // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. + // It is an error to explicitly declare a static property member with the name 'prototype'. + let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); + if (hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; + file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], + Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; return SymbolFlags.Class; } From aaf9371357faa9b38c2adcfef8dd372d22f537d2 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 19 Apr 2015 23:30:06 -0700 Subject: [PATCH 023/402] Add clarifying comments to binder. --- src/compiler/binder.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 2100936c775..6f8140a983a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -603,9 +603,14 @@ module ts { let symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', - // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. - // It is an error to explicitly declare a static property member with the name 'prototype'. + // Every class automatically contains a static property member named 'prototype', the + // type of which is an instantiation of the class type with type Any supplied as a type + // argument for each type parameter. It is an error to explicitly declare a static + // property member with the name 'prototype'. + // + // Note: we check for this here because this class may be merging into a module. The + // module might have an exported variable called 'prototype'. We can't allow that as + // that would clash with the built-in 'prototype' for the class. let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); if (hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { From 2e8e4a1f5c22cc5514a0a2137217b6037cde4779 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 02:24:47 -0700 Subject: [PATCH 024/402] Add clarifying comments to the binder. --- src/compiler/binder.ts | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6f8140a983a..e27851c7806 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -143,7 +143,7 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { + function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { Debug.assert(!hasDynamicName(node)); // The exported symbol for an export default function/class node is always named "default" @@ -151,7 +151,27 @@ module ts { let symbol: Symbol; if (name !== undefined) { - symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(SymbolFlags.None, name)); + // Check and see if the symbol table already has a symbol with this name. If not, + // create a new symbol with this name and add it to the table. Note that we don't + // give the new symbol any flags *yet*. This ensures that it will not conflict + // witht he 'excludes' flags we pass in. + // + // If we do get an existing symbol, see if it conflicts with the new symbol we're + // creating. For example, a 'var' symbol and a 'class' symbol will conflict within + // the same symbol table. If we have a conflict, report the issue on each + // declaration we have for this symbol, and then create a new symbol for this + // declaration. + // + // If we created a new symbol, either because we didn't have a symbol with this name + // in the symbol table, or we conflicted with an existing symbol, then just add this + // node as the sole declaration of the new symbol. + // + // Otherwise, we'll be merging into a compatible existing symbol (for example when + // you have multiple 'vars' with the same name in the same container). In this case + // just add this node into the declarations list of the symbol. + symbol = hasProperty(symbolTable, name) + ? symbolTable[name] + : (symbolTable[name] = createSymbol(SymbolFlags.None, name)); if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -160,9 +180,8 @@ module ts { // Report errors every position with duplicate declaration // Report errors on previous encountered declarations let message = symbol.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; - forEach(symbol.declarations, declaration => { file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -204,7 +223,8 @@ module ts { // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. if (hasExportModifier || container.flags & NodeFlags.ExportContext) { - let exportKind = (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | + let exportKind = + (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | (symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | (symbolFlags & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0); let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); @@ -541,11 +561,10 @@ module ts { // do not treat function block a block-scope container // all block-scope locals that reside in this block should go to the function locals. // Otherwise this won't be considered as redeclaration of a block scoped local: - // function foo() { - // let x; + // function foo(x) { // let x; // } - // 'let x' will be placed into the function locals and 'let x' - into the locals of the block + // 'x' will be placed into the function locals and 'let x' - into the locals of the block return isFunctionLike(node.parent) ? SymbolFlags.None : SymbolFlags.BlockScopedContainer; case SyntaxKind.CatchClause: case SyntaxKind.ForStatement: From 33a74101b8804c10f5a5b915e9598983fd0132ef Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:28:16 -0700 Subject: [PATCH 025/402] Split out the concerns of the binder even more. Don't use SymbolFlags to direct how we handle containers in the binder. Instead, Just determine what we should do based on the .kind of the node itself, and nothing more. --- src/compiler/binder.ts | 200 +++++++++++++++++++++++------------------ src/compiler/types.ts | 4 - 2 files changed, 111 insertions(+), 93 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e27851c7806..612b957cf4a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -52,6 +52,15 @@ module ts { } } + const enum ContainerFlags { + None = 0, + IsContainer = 0x01, + IsBlockScopedContainer = 0x02, + HasLocals = 0x04, + + IsContainerWithLocals = IsContainer | HasLocals + } + export function bindSourceFile(file: SourceFile): void { let start = new Date().getTime(); bindSourceFileWorker(file); @@ -67,8 +76,6 @@ module ts { let Symbol = objectAllocator.getSymbolConstructor(); if (!file.locals) { - file.locals = {}; - container = blockScopeContainer = file; bind(file); file.symbolCount = symbolCount; } @@ -82,9 +89,6 @@ module ts { symbol.flags |= symbolFlags; node.symbol = symbol; - if (symbolFlags & SymbolFlags.HasLocals) { - node.locals = {}; - } if (!symbol.declarations) { symbol.declarations = []; @@ -238,34 +242,29 @@ module ts { } } - // All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function - // in the type checker to validate that the local name used for a container is unique. - function bindChildren(node: Node, symbolFlags: SymbolFlags) { + // All container nodes are kept on a linked list in declaration order. This list is used by + // the getLocalNameOfContainer function in the type checker to validate that the local name + // used for a container is unique. + function bindChildren(node: Node): void { let saveParent = parent; let saveContainer = container; let savedBlockScopeContainer = blockScopeContainer; parent = node; - if (symbolFlags & SymbolFlags.IsContainer) { - container = node; - if (lastContainer) { - lastContainer.nextContainer = container; + let containerFlags = getContainerFlags(node); + if (containerFlags & ContainerFlags.IsContainer) { + container = blockScopeContainer = node; + + // If this is a container that also has locals, initialize them now. + if (containerFlags & ContainerFlags.HasLocals) { + container.locals = {}; } - lastContainer = container; + addContainerToEndOfChain(); } - - if (symbolFlags & SymbolFlags.IsBlockScopedContainer) { - // in incremental scenarios we might reuse nodes that already have locals being allocated - // during the bind step these locals should be dropped to prevent using stale data. - // locals should always be dropped unless they were previously initialized by the binder - // these cases are: - // - node has locals (symbolKind & HasLocals) !== 0 - // - node is a source file + else if (containerFlags & ContainerFlags.IsBlockScopedContainer) { blockScopeContainer = node; - if ((symbolFlags & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile) { - blockScopeContainer.locals = undefined; - } + blockScopeContainer.locals = undefined; } forEachChild(node, bind); @@ -275,9 +274,64 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } - function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { + function getContainerFlags(node: Node): ContainerFlags { + switch (node.kind) { + case SyntaxKind.ClassExpression: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeLiteral: + case SyntaxKind.ObjectLiteralExpression: + return ContainerFlags.IsContainer; + + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.SourceFile: + return ContainerFlags.IsContainerWithLocals; + + case SyntaxKind.CatchClause: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.CaseBlock: + return ContainerFlags.IsBlockScopedContainer; + + case SyntaxKind.Block: + // do not treat function block a block-scope container + // all block-scope locals that reside in this block should go to the function locals. + // Otherwise this won't be considered as redeclaration of a block scoped local: + // function foo(x) { + // let x; + // } + // 'x' will be placed into the function locals and 'let x' - into the locals of the block + return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer; + } + + return ContainerFlags.None; + } + + function addContainerToEndOfChain() { + if (lastContainer) { + lastContainer.nextContainer = container; + } + + lastContainer = container; + } + + function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - return symbolFlags; } function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { @@ -381,7 +435,7 @@ module ts { } } - function bindModuleDeclaration(node: ModuleDeclaration) { + function bindModuleDeclaration(node: ModuleDeclaration): void { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { return declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); @@ -392,7 +446,7 @@ module ts { return declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } else { - let result = declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; if (node.symbol.constEnumOnlyModule === undefined) { @@ -403,13 +457,11 @@ module ts { // merged case: module is const enum only if all its pieces are non-instantiated or const enum node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; } - - return result; } } } - function bindFunctionOrConstructorType(node: SignatureDeclaration): SymbolFlags { + function bindFunctionOrConstructorType(node: SignatureDeclaration): void { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // @@ -423,17 +475,14 @@ module ts { let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = { [name]: symbol }; - - return SymbolFlags.Signature; } - function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string): SymbolFlags { + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string): void { let symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); - return symbolFlags; } - function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { + function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { switch (blockScopeContainer.kind) { case SyntaxKind.ModuleDeclaration: declareModuleMember(node, symbolFlags, symbolExcludes); @@ -450,11 +499,9 @@ module ts { } declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); } - - return symbolFlags; } - function bindBlockScopedVariableDeclaration(node: Declaration): SymbolFlags { + function bindBlockScopedVariableDeclaration(node: Declaration): void { return bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); } @@ -477,16 +524,16 @@ module ts { // // However, not all symbols will end up in any of these tables. 'Anonymous' symbols // (like TypeLiterals for example) will not be put in any table. - var symbolFlags = bindWorker(node); + bindWorker(node); // Then we recurse into the children of the node to bind them as well. For certain // symbols we do specialized work when we recurse. For example, we'll keep track of // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. - bindChildren(node, symbolFlags); + bindChildren(node); } - function bindWorker(node: Node): SymbolFlags { + function bindWorker(node: Node): void { switch (node.kind) { case SyntaxKind.TypeParameter: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); @@ -557,34 +604,17 @@ module ts { return bindExportAssignment(node); case SyntaxKind.SourceFile: return bindSourceFileIfExternalModule(); - case SyntaxKind.Block: - // do not treat function block a block-scope container - // all block-scope locals that reside in this block should go to the function locals. - // Otherwise this won't be considered as redeclaration of a block scoped local: - // function foo(x) { - // let x; - // } - // 'x' will be placed into the function locals and 'let x' - into the locals of the block - return isFunctionLike(node.parent) ? SymbolFlags.None : SymbolFlags.BlockScopedContainer; - case SyntaxKind.CatchClause: - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.CaseBlock: - return SymbolFlags.BlockScopedContainer; } - - return SymbolFlags.None; } - function bindSourceFileIfExternalModule() { + function bindSourceFileIfExternalModule(): void { setExportContextFlag(file); - return isExternalModule(file) - ? bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"') - : SymbolFlags.BlockScopedContainer; + if (isExternalModule(file)) { + bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"'); + } } - function bindExportAssignment(node: ExportAssignment) { + function bindExportAssignment(node: ExportAssignment): void { if (node.expression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); @@ -593,25 +623,22 @@ module ts { // An export default clause with an expression exports a value declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } - - return SymbolFlags.None; } - function bindExportDeclaration(node: ExportDeclaration) { + function bindExportDeclaration(node: ExportDeclaration): void { if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None); } - return SymbolFlags.None; } - function bindImportClause(node: ImportClause) { - return node.name - ? declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes) - : SymbolFlags.None; + function bindImportClause(node: ImportClause): void { + if (node.name) { + declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + } } - function bindClassLikeDeclaration(node: ClassLikeDeclaration) { + function bindClassLikeDeclaration(node: ClassLikeDeclaration): void { if (node.kind === SyntaxKind.ClassDeclaration) { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } @@ -640,29 +667,26 @@ module ts { } symbol.exports[prototypeSymbol.name] = prototypeSymbol; prototypeSymbol.parent = symbol; - - return SymbolFlags.Class; } - function bindEnumDeclaration(node: EnumDeclaration) { + function bindEnumDeclaration(node: EnumDeclaration): void { return isConst(node) ? declareSymbolAndAddToSymbolTable(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) : declareSymbolAndAddToSymbolTable(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); } - function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { - if (isBindingPattern(node.name)) { - return SymbolFlags.None; - } - else if (isBlockOrCatchScoped(node)) { - return bindBlockScopedVariableDeclaration(node); - } - else { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement): void { + if (!isBindingPattern(node.name)) { + if (isBlockOrCatchScoped(node)) { + return bindBlockScopedVariableDeclaration(node); + } + else { + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + } } } - function bindParameter(node: ParameterDeclaration): SymbolFlags { + function bindParameter(node: ParameterDeclaration): void { if (isBindingPattern(node.name)) { bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } @@ -679,11 +703,9 @@ module ts { let classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); } - - return SymbolFlags.FunctionScopedVariable; } - function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): SymbolFlags { + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { return hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 010b6308348..c55f016704d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1311,7 +1311,6 @@ module ts { UnionProperty = 0x10000000, // Property in union type Optional = 0x20000000, // Optional property ExportStar = 0x40000000, // Export * declaration - BlockScopedContainer = 0x80000000, Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, @@ -1350,12 +1349,9 @@ module ts { ExportHasLocal = Function | Class | Enum | ValueModule, - HasLocals = Function | Module | Method | Constructor | Accessor | Signature, HasExports = Class | Enum | Module, HasMembers = Class | Interface | TypeLiteral | ObjectLiteral, - IsBlockScopedContainer = BlockScopedContainer | Module | Function | Accessor | Method | Constructor, - IsContainer = HasLocals | HasExports | HasMembers, PropertyOrAccessor = Property | Accessor, Export = ExportNamespace | ExportType | ExportValue, } From 602c5c8fa93d08d6fe8957bdc104e9296aa0c651 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:33:13 -0700 Subject: [PATCH 026/402] Add explanatory comments. --- src/compiler/binder.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 612b957cf4a..dbe705fbe35 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -246,16 +246,37 @@ module ts { // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node: Node): void { + // Before we recurse into a node's chilren, we first save the existing parent, container + // and block-container. Then after we pop out of processing the children, we restore + // these saved values. let saveParent = parent; let saveContainer = container; let savedBlockScopeContainer = blockScopeContainer; - parent = node; + // This node will now be set as the parent of all of its children as we recurse into them. + parent = node; + + // Depending on what kind of node this is, we may have to adjust the current container + // and block-container. If the current node is a container, then it is automatically + // considered the current block-container as well. Also, for containers that we know + // may contain locals, we proactively initialize the .locals field. We do this because + // it's highly likely that the .locals will be need to place some child in (for example, + // a parameter, or variable declaration). + // + // However, we do not proactively create the locals for block-containers because it's + // totally normal and common for block-containers to never actually have a block-scoped + // variable in them. We don't want to end up allocating an object for every 'block' we + // run into when most of them won't be necessary. + // + // Finally, if this is a block-container, then we clear out any existing locals object + // it may contain within it. This happens in incremental scenarios. Because we can be + // reusing a node from a previous compilation, that node may have had 'locals' created + // for it. We must clear this so we don't accidently move any stale data forward from + // a previous compilation. let containerFlags = getContainerFlags(node); if (containerFlags & ContainerFlags.IsContainer) { container = blockScopeContainer = node; - // If this is a container that also has locals, initialize them now. if (containerFlags & ContainerFlags.HasLocals) { container.locals = {}; } From 60d0b1444d16c18befe2acf3192121f926eb176e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:34:19 -0700 Subject: [PATCH 027/402] CR feedback. --- src/compiler/binder.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index dbe705fbe35..0ffd60b81c7 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -372,9 +372,6 @@ module ts { return declareClassMember(node, symbolFlags, symbolExcludes); case SyntaxKind.EnumDeclaration: - // Enum members are always put in the 'exports' of the containing enum. - // They are only accessible through their container, and are never in - // scope otherwise (even inside the body of the enum declaring them.). return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case SyntaxKind.TypeLiteral: @@ -401,11 +398,10 @@ module ts { case SyntaxKind.ArrowFunction: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // more or less, they're only accessed 'lexically' (i.e. from code that exists - // underneath their container in the tree. To accomplish this, we simply add - // their declared symbol to the 'locals' of the container. These symbols can - // then be found as the type checker walks up the containers, checking them - // for matching names. + // they're only accessed 'lexically' (i.e. from code that exists underneath + // their container in the tree. To accomplish this, we simply add their declared + // symbol to the 'locals' of the container. These symbols can then be found as + // the type checker walks up the containers, checking them for matching names. return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } From d220b7ebb4827d76ec3c4f79a19760a0bac77c82 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:43:54 -0700 Subject: [PATCH 028/402] Add explanatory comments. --- src/compiler/binder.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 0ffd60b81c7..eeee76c3761 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -53,11 +53,27 @@ module ts { } const enum ContainerFlags { - None = 0, - IsContainer = 0x01, - IsBlockScopedContainer = 0x02, + // The current node is not a container, and no container manipulation should happen before + // recursing into it. + None = 0, + + // The current node is a container. It should be set as the current container (and block- + // container) before recursing into it. The current node does not have locals. Examples: + // + // Classes, ObjectLiterals, TypeLiterals, Interfaces... + IsContainer = 0x01, + + // The current node is a block-scoped-container. It should be set as the current block- + // container before recursing into it. Examples: + // + // Blocks (when not parented by functions), Catch clauses, For/For-in/For-of statements... + IsBlockScopedContainer = 0x02, + HasLocals = 0x04, + // If the current node is a container that also container that also contains locals. Examples: + // + // Functions, Methods, Modules, Source-files. IsContainerWithLocals = IsContainer | HasLocals } From 0a144e1806087bcd2ffbd81f6d44a5345bfc85a6 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:44:33 -0700 Subject: [PATCH 029/402] Add explicit return to indicate the end of flow of a method.' --- src/compiler/binder.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index eeee76c3761..e20b7aca0e8 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -96,6 +96,8 @@ module ts { file.symbolCount = symbolCount; } + return; + function createSymbol(flags: SymbolFlags, name: string): Symbol { symbolCount++; return new Symbol(flags, name); From b1417d408dce2cd820ec937953b61298d0fcb481 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:47:42 -0700 Subject: [PATCH 030/402] Clean up comment. --- src/compiler/binder.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e20b7aca0e8..b4a993a805e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -322,7 +322,7 @@ module ts { case SyntaxKind.TypeLiteral: case SyntaxKind.ObjectLiteralExpression: return ContainerFlags.IsContainer; - + case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: @@ -348,13 +348,19 @@ module ts { return ContainerFlags.IsBlockScopedContainer; case SyntaxKind.Block: - // do not treat function block a block-scope container - // all block-scope locals that reside in this block should go to the function locals. - // Otherwise this won't be considered as redeclaration of a block scoped local: - // function foo(x) { - // let x; - // } - // 'x' will be placed into the function locals and 'let x' - into the locals of the block + // do not treat function block a block-scope container. All block-scope locals + // that reside in this block should go to the function locals. Otherwise this + // wouldn't be considered as redeclaration of a block scoped local: + // + // function foo() { + // var x; + // let x; + // } + // + // If we placed 'var x' into the function locals and 'let x' - into the locals of + // the block, then there would be no collision. By doing this, we ensure that both + // 'var x' and 'let x' go into the Function-container's locals, and we do get a + // collision conflict. return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer; } From b81a2c00ba4c3d5604c1305f1f129ca37a7eec7c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:52:46 -0700 Subject: [PATCH 031/402] Clean up comment. --- src/compiler/binder.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b4a993a805e..ad5ca83585e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -348,19 +348,19 @@ module ts { return ContainerFlags.IsBlockScopedContainer; case SyntaxKind.Block: - // do not treat function block a block-scope container. All block-scope locals + // do not treat blocks directly inside a function as a block-scoped-container. // that reside in this block should go to the function locals. Otherwise this // wouldn't be considered as redeclaration of a block scoped local: // - // function foo() { - // var x; - // let x; - // } + // function foo() { + // var x; + // let x; + // } // // If we placed 'var x' into the function locals and 'let x' - into the locals of - // the block, then there would be no collision. By doing this, we ensure that both - // 'var x' and 'let x' go into the Function-container's locals, and we do get a - // collision conflict. + // the block, then there would be no collision. By not creating a new block- + // scoped-container here, we ensure that both 'var x' and 'let x' go into the + // Function - container's locals, and we do get a collision conflict. return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer; } From 93b7c33347b171382c19c90cb3ae9787a198fa91 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:54:05 -0700 Subject: [PATCH 032/402] Remove unnecessary returns. --- src/compiler/binder.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ad5ca83585e..6a3b410df30 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -479,12 +479,12 @@ module ts { function bindModuleDeclaration(node: ModuleDeclaration): void { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } else { let state = getModuleInstanceState(node); if (state === ModuleInstanceState.NonInstantiated) { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); + declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } else { declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); @@ -543,7 +543,7 @@ module ts { } function bindBlockScopedVariableDeclaration(node: Declaration): void { - return bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); + bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); } function getDestructuringParameterName(node: Declaration) { @@ -719,10 +719,10 @@ module ts { function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement): void { if (!isBindingPattern(node.name)) { if (isBlockOrCatchScoped(node)) { - return bindBlockScopedVariableDeclaration(node); + bindBlockScopedVariableDeclaration(node); } else { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); } } } From fac9ab2508d299d8a873692c4f71f5ccf2adba5a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2015 23:56:38 -0700 Subject: [PATCH 033/402] Clean up comment more. --- src/compiler/binder.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6a3b410df30..ed318e1804e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -349,18 +349,21 @@ module ts { case SyntaxKind.Block: // do not treat blocks directly inside a function as a block-scoped-container. - // that reside in this block should go to the function locals. Otherwise this - // wouldn't be considered as redeclaration of a block scoped local: + // that reside in this block should go to the function locals. Othewise 'x' + // would not appear to be a redeclaration of a block scoped local in the following + // example: // // function foo() { // var x; // let x; // } // - // If we placed 'var x' into the function locals and 'let x' - into the locals of - // the block, then there would be no collision. By not creating a new block- - // scoped-container here, we ensure that both 'var x' and 'let x' go into the - // Function - container's locals, and we do get a collision conflict. + // If we placed 'var x' into the function locals and 'let x' into the locals of + // the block, then there would be no collision. + // + // By not creating a new block-scoped-container here, we ensure that both 'var x' + // and 'let x' go into the Function-container's locals, and we do get a collision + // conflict. return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer; } From a93bf1048da11678b6cde0c40f0dd445b611e0f8 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 Apr 2015 00:01:06 -0700 Subject: [PATCH 034/402] Clean up comment. --- src/compiler/binder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ed318e1804e..40168900a6d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -278,15 +278,15 @@ module ts { // and block-container. If the current node is a container, then it is automatically // considered the current block-container as well. Also, for containers that we know // may contain locals, we proactively initialize the .locals field. We do this because - // it's highly likely that the .locals will be need to place some child in (for example, + // it's highly likely that the .locals will be needed to place some child in (for example, // a parameter, or variable declaration). // - // However, we do not proactively create the locals for block-containers because it's + // However, we do not proactively create the .locals for block-containers because it's // totally normal and common for block-containers to never actually have a block-scoped // variable in them. We don't want to end up allocating an object for every 'block' we // run into when most of them won't be necessary. // - // Finally, if this is a block-container, then we clear out any existing locals object + // Finally, if this is a block-container, then we clear out any existing .locals object // it may contain within it. This happens in incremental scenarios. Because we can be // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidently move any stale data forward from From cf00a2bec859eaffa8d82698e57350a149bb2aa4 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 Apr 2015 00:05:08 -0700 Subject: [PATCH 035/402] Clean up comment. --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 40168900a6d..d0bb5edd489 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -349,7 +349,7 @@ module ts { case SyntaxKind.Block: // do not treat blocks directly inside a function as a block-scoped-container. - // that reside in this block should go to the function locals. Othewise 'x' + // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // From ca63d6429297d450df796573be4c724a50cbfb65 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 Apr 2015 12:59:22 -0700 Subject: [PATCH 036/402] CR feedback. --- src/compiler/binder.ts | 48 ++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d0bb5edd489..daec6fee7df 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -77,13 +77,13 @@ module ts { IsContainerWithLocals = IsContainer | HasLocals } - export function bindSourceFile(file: SourceFile): void { + export function bindSourceFile(file: SourceFile) { let start = new Date().getTime(); bindSourceFileWorker(file); bindTime += new Date().getTime() - start; } - function bindSourceFileWorker(file: SourceFile): void { + function bindSourceFileWorker(file: SourceFile) { let parent: Node; let container: Node; let blockScopeContainer: Node; @@ -263,7 +263,7 @@ module ts { // All container nodes are kept on a linked list in declaration order. This list is used by // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. - function bindChildren(node: Node): void { + function bindChildren(node: Node) { // Before we recurse into a node's chilren, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. @@ -378,11 +378,11 @@ module ts { lastContainer = container; } - function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { + function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); } - function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { + function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { switch (container.kind) { // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific @@ -479,7 +479,7 @@ module ts { } } - function bindModuleDeclaration(node: ModuleDeclaration): void { + function bindModuleDeclaration(node: ModuleDeclaration) { setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); @@ -505,7 +505,7 @@ module ts { } } - function bindFunctionOrConstructorType(node: SignatureDeclaration): void { + function bindFunctionOrConstructorType(node: SignatureDeclaration) { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // @@ -521,12 +521,12 @@ module ts { typeLiteralSymbol.members = { [name]: symbol }; } - function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string): void { + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { let symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } - function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { + function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { switch (blockScopeContainer.kind) { case SyntaxKind.ModuleDeclaration: declareModuleMember(node, symbolFlags, symbolExcludes); @@ -545,7 +545,7 @@ module ts { } } - function bindBlockScopedVariableDeclaration(node: Declaration): void { + function bindBlockScopedVariableDeclaration(node: Declaration) { bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); } @@ -553,14 +553,12 @@ module ts { return "__" + indexOf((node.parent).parameters, node); } - function bind(node: Node): void { + function bind(node: Node) { node.parent = parent; // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and then potentially add the symbol to an appropriate symbol table. The symbolFlags - // that are returned from this help inform how we recurse into the children of this node. - // - // Possible destination symbol tables are: + // and then potentially add the symbol to an appropriate symbol table. Possible + // destination symbol tables are: // // 1) The 'exports' table of the current container's symbol. // 2) The 'members' table of the current container's symbol. @@ -577,7 +575,7 @@ module ts { bindChildren(node); } - function bindWorker(node: Node): void { + function bindWorker(node: Node) { switch (node.kind) { case SyntaxKind.TypeParameter: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); @@ -651,14 +649,14 @@ module ts { } } - function bindSourceFileIfExternalModule(): void { + function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (isExternalModule(file)) { bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"'); } } - function bindExportAssignment(node: ExportAssignment): void { + function bindExportAssignment(node: ExportAssignment) { if (node.expression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); @@ -669,20 +667,20 @@ module ts { } } - function bindExportDeclaration(node: ExportDeclaration): void { + function bindExportDeclaration(node: ExportDeclaration) { if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None); } } - function bindImportClause(node: ImportClause): void { + function bindImportClause(node: ImportClause) { if (node.name) { declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } } - function bindClassLikeDeclaration(node: ClassLikeDeclaration): void { + function bindClassLikeDeclaration(node: ClassLikeDeclaration) { if (node.kind === SyntaxKind.ClassDeclaration) { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } @@ -713,13 +711,13 @@ module ts { prototypeSymbol.parent = symbol; } - function bindEnumDeclaration(node: EnumDeclaration): void { + function bindEnumDeclaration(node: EnumDeclaration) { return isConst(node) ? declareSymbolAndAddToSymbolTable(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) : declareSymbolAndAddToSymbolTable(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); } - function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement): void { + function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { if (!isBindingPattern(node.name)) { if (isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -730,7 +728,7 @@ module ts { } } - function bindParameter(node: ParameterDeclaration): void { + function bindParameter(node: ParameterDeclaration) { if (isBindingPattern(node.name)) { bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } @@ -749,7 +747,7 @@ module ts { } } - function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void { + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { return hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); From a54d4154aaad8bce527916a99ce2c4d5fbe3ca54 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 Apr 2015 13:06:40 -0700 Subject: [PATCH 037/402] CR feedback. --- src/compiler/binder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index daec6fee7df..96cd2fdfdc7 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -61,15 +61,15 @@ module ts { // container) before recursing into it. The current node does not have locals. Examples: // // Classes, ObjectLiterals, TypeLiterals, Interfaces... - IsContainer = 0x01, + IsContainer = 1 << 0, // The current node is a block-scoped-container. It should be set as the current block- // container before recursing into it. Examples: // // Blocks (when not parented by functions), Catch clauses, For/For-in/For-of statements... - IsBlockScopedContainer = 0x02, + IsBlockScopedContainer = 1 << 1, - HasLocals = 0x04, + HasLocals = 1 << 2, // If the current node is a container that also container that also contains locals. Examples: // From 8d99ecfa6caddb9f5a37e1829b11d4811bdb7ce1 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 29 Apr 2015 12:13:35 -0700 Subject: [PATCH 038/402] Add a light=true mode for running tests faster. --- Jakefile.js | 14 ++++--- src/compiler/checker.ts | 5 ++- src/compiler/types.ts | 4 ++ src/harness/compilerRunner.ts | 3 +- src/harness/harness.ts | 5 ++- src/harness/runner.ts | 79 ++++++++++++++++++++--------------- 6 files changed, 66 insertions(+), 44 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index cb53b479502..78622f67287 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -503,9 +503,9 @@ function cleanTestDirs() { } // used to pass data from jake command line directly to run.js -function writeTestConfigFile(tests, testConfigFile) { +function writeTestConfigFile(tests, light, testConfigFile) { console.log('Running test(s): ' + tests); - var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}'; + var testConfigContents = JSON.stringify({ test: [tests], light: light }); fs.writeFileSync('test.config', testConfigContents); } @@ -521,13 +521,14 @@ task("runtests", ["tests", builtLocalDirectory], function() { cleanTestDirs(); host = "mocha" tests = process.env.test || process.env.tests || process.env.t; + var light = process.env.light || false; var testConfigFile = 'test.config'; if(fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } - if(tests) { - writeTestConfigFile(tests, testConfigFile); + if(tests || light) { + writeTestConfigFile(tests, light, testConfigFile); } if (tests && tests.toLocaleLowerCase() === "rwc") { @@ -570,12 +571,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function( port = process.env.port || process.env.p || '8888'; browser = process.env.browser || process.env.b || "IE"; tests = process.env.test || process.env.tests || process.env.t; + var light = process.env.light || false; var testConfigFile = 'test.config'; if(fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } - if(tests) { - writeTestConfigFile(tests, testConfigFile); + if(tests || light) { + writeTestConfigFile(tests, light, testConfigFile); } tests = tests ? tests : ''; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bbfa681d72e..03c2fbd9630 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10934,7 +10934,10 @@ module ts { function checkSourceFile(node: SourceFile) { let start = new Date().getTime(); - checkSourceFileWorker(node); + let skipCheck = node.fileName.indexOf("lib.d.ts") >= 0 && compilerOptions.noLibCheck; + if (!skipCheck) { + checkSourceFileWorker(node); + } checkTime += new Date().getTime() - start; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 94053a6484d..2f4e33a6e8b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1677,6 +1677,10 @@ module ts { separateCompilation?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; + + // Skip checking lib.d.ts to help speed up tests. + /* @internal */ noLibCheck?: boolean; + [option: string]: string | number | boolean; } diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index b6997e705b9..11822e2fec5 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -171,7 +171,6 @@ class CompilerBaselineRunner extends RunnerBase { } }); - it('Correct JS output for ' + fileName, () => { if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) { if (result.files.length === 0 && result.errors.length === 0) { @@ -259,7 +258,7 @@ class CompilerBaselineRunner extends RunnerBase { }); it('Correct type/symbol baselines for ' + fileName, () => { - if (fileName.indexOf("APISample") >= 0) { + if (fileName.indexOf("APISample") >= 0 || lightMode) { return; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6af77e3d746..70c5cae8c49 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -800,7 +800,7 @@ module Harness { // Only set the parent nodes if we're asserting invariants. We don't need them otherwise. var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants); if (assertInvariants) { - Utils.assertInvariants(result, /*parent:*/ undefined); + // Utils.assertInvariants(result, /*parent:*/ undefined); } return result; } @@ -937,6 +937,9 @@ module Harness { options.target = options.target || ts.ScriptTarget.ES3; options.module = options.module || ts.ModuleKind.None; options.noErrorTruncation = true; + if (lightMode) { + options.noLibCheck = true; + } if (settingsCallback) { settingsCallback(null); diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 37451639d75..4bcd5643efa 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -36,43 +36,54 @@ var testconfig = 'test.config'; var testConfigFile = Harness.IO.fileExists(mytestconfig) ? Harness.IO.readFile(mytestconfig) : (Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : ''); +var lightMode: boolean; if (testConfigFile !== '') { // TODO: not sure why this is crashing mocha - //var testConfig = JSON.parse(testConfigRaw); - var testConfig = testConfigFile.match(/test:\s\['(.*)'\]/); - var options = testConfig ? [testConfig[1]] : []; - for (var i = 0; i < options.length; i++) { - switch (options[i]) { - case 'compiler': - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); - runners.push(new ProjectRunner()); - break; - case 'conformance': - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - break; - case 'project': - runners.push(new ProjectRunner()); - break; - case 'fourslash': - runners.push(new FourSlashRunner(FourSlashTestType.Native)); - break; - case 'fourslash-shims': - runners.push(new FourSlashRunner(FourSlashTestType.Shims)); - break; - case 'fourslash-server': - runners.push(new FourSlashRunner(FourSlashTestType.Server)); - break; - case 'fourslash-generated': - runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); - break; - case 'rwc': - runners.push(new RWCRunner()); - break; - case 'test262': - runners.push(new Test262BaselineRunner()); - break; + var testConfig = JSON.parse(testConfigFile); + //var testConfig = testConfigFile.match(/test:\s\['(.*)'\]/); + //var options = testConfig ? [testConfig[1]] : []; + if (testConfig.light) { + lightMode = true; + } + + if (testConfig.test && testConfig.test.length > 0) { + for (let option of testConfig.test) { + if (!option) { + continue; + } + ts.sys.write("Option: " + option + "\r\n"); + switch (option) { + case 'compiler': + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + runners.push(new ProjectRunner()); + break; + case 'conformance': + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + break; + case 'project': + runners.push(new ProjectRunner()); + break; + case 'fourslash': + runners.push(new FourSlashRunner(FourSlashTestType.Native)); + break; + case 'fourslash-shims': + runners.push(new FourSlashRunner(FourSlashTestType.Shims)); + break; + case 'fourslash-server': + runners.push(new FourSlashRunner(FourSlashTestType.Server)); + break; + case 'fourslash-generated': + runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); + break; + case 'rwc': + runners.push(new RWCRunner()); + break; + case 'test262': + runners.push(new Test262BaselineRunner()); + break; + } } } } From eb15bb36588a6112fbbbab6522fb8abfbdd0d292 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 29 Apr 2015 17:42:28 -0700 Subject: [PATCH 039/402] Use no-default-lib for the '--noLibCheck' flag. --- src/compiler/checker.ts | 4 +++- src/compiler/types.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 03c2fbd9630..9b3515d3742 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10934,10 +10934,12 @@ module ts { function checkSourceFile(node: SourceFile) { let start = new Date().getTime(); - let skipCheck = node.fileName.indexOf("lib.d.ts") >= 0 && compilerOptions.noLibCheck; + + let skipCheck = node.hasNoDefaultLib && compilerOptions.noLibCheck; if (!skipCheck) { checkSourceFileWorker(node); } + checkTime += new Date().getTime() - start; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2f4e33a6e8b..496153b1513 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1004,6 +1004,14 @@ module ts { amdModuleName: string; referencedFiles: FileReference[]; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * which serves the purpose of ignoring the file in certain ways in the + * presence of compiler options like '--noLib' and '--noLibCheck'. + */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; @@ -1042,7 +1050,7 @@ module ts { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } - export interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost, TypeCheckerHost { /** * Get a list of files in the program */ From e90849d64366eeb8fee45f5d180b877e042d21fb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 29 Apr 2015 17:54:15 -0700 Subject: [PATCH 040/402] Made parameter mandatory, check type baselines again even in light mode. --- src/harness/compilerRunner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 11822e2fec5..293b88c65ef 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -18,7 +18,7 @@ class CompilerBaselineRunner extends RunnerBase { public options: string; - constructor(public testType?: CompilerTestType) { + constructor(public testType: CompilerTestType) { super(); this.errors = true; this.emit = true; @@ -258,7 +258,7 @@ class CompilerBaselineRunner extends RunnerBase { }); it('Correct type/symbol baselines for ' + fileName, () => { - if (fileName.indexOf("APISample") >= 0 || lightMode) { + if (fileName.indexOf("APISample") >= 0) { return; } From d5d7f9f50408f3de4e28e65285ac76862eae49ba Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 30 Apr 2015 18:14:53 -0700 Subject: [PATCH 041/402] Document/rename flag used in compiler. --- src/compiler/program.ts | 17 ++++++++++++----- src/harness/rwcRunner.ts | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cc2fe7ff190..f3d74464464 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -143,18 +143,25 @@ module ts { let files: SourceFile[] = []; let filesByName: Map = {}; let diagnostics = createDiagnosticCollection(); - let seenNoDefaultLib = options.noLib; let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; let noDiagnosticsTypeChecker: TypeChecker; + // shouldExcludeDefaultLib is true if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + let shouldExcludeDefaultLib = options.noLib; + let start = new Date().getTime(); host = host || createCompilerHost(options); - forEach(rootNames, name => processRootFile(name, false)); - if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + + forEach(rootNames, name => processRootFile(name, /*isDefaultLib */ false)); + if (!shouldExcludeDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true); } + verifyCompilerOptions(); programTime += new Date().getTime() - start; @@ -360,7 +367,7 @@ module ts { } }); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; + shouldExcludeDefaultLib = shouldExcludeDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName[canonicalAbsolutePath] = file; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 49a15112e9f..0d56fa7250e 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -75,7 +75,7 @@ module RWC { }); // Add files to compilation - for(let fileRead of ioLog.filesRead) { + for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); From a27de3f7d8986ba87c28bb1d045405e9525dc27b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 1 May 2015 17:08:48 -0700 Subject: [PATCH 042/402] Moved 'lightMode' flag to Harness. --- src/harness/fourslash.ts | 3 ++- src/harness/harness.ts | 11 ++++++----- src/harness/runner.ts | 4 ++-- src/harness/runnerServer.ts | 17 +++++++++++++++++ src/harness/runnerbase.ts | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/harness/runnerServer.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c8f20746a07..ea6fe174eeb 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -343,7 +343,8 @@ module FourSlash { if (!resolvedResult.isLibFile) { this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text); } - } else { + } + else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles ts.forEachKey(this.inputFiles, fileName => { if (!Harness.isLibraryFile(fileName)) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 70c5cae8c49..8934ab70943 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -97,7 +97,7 @@ module Utils { } try { - var content = ts.sys.readFile(Harness.userSpecifiedroot + path); + var content = ts.sys.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -720,7 +720,8 @@ module Harness { } // Settings - export var userSpecifiedroot = ""; + export let userSpecifiedRoot = ""; + export let lightMode = false; /** Functionality for compiling TypeScript code */ export module Compiler { @@ -1610,9 +1611,9 @@ module Harness { function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) { if (subfolder !== undefined) { - return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedRoot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName; } else { - return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedRoot + baselineFolder + '/' + type + '/' + fileName; } } @@ -1728,7 +1729,7 @@ module Harness { } export function getDefaultLibraryFile(): { unitName: string, content: string } { - var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts"; + var libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; return { unitName: libFile, content: IO.readFile(libFile) diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 4bcd5643efa..10992661052 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -18,6 +18,7 @@ /// /// /// +/// function runTests(runners: RunnerBase[]) { for (var i = iterations; i > 0; i--) { @@ -36,7 +37,6 @@ var testconfig = 'test.config'; var testConfigFile = Harness.IO.fileExists(mytestconfig) ? Harness.IO.readFile(mytestconfig) : (Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : ''); -var lightMode: boolean; if (testConfigFile !== '') { // TODO: not sure why this is crashing mocha @@ -44,7 +44,7 @@ if (testConfigFile !== '') { //var testConfig = testConfigFile.match(/test:\s\['(.*)'\]/); //var options = testConfig ? [testConfig[1]] : []; if (testConfig.light) { - lightMode = true; + Harness.lightMode = true; } if (testConfig.test && testConfig.test.length > 0) { diff --git a/src/harness/runnerServer.ts b/src/harness/runnerServer.ts new file mode 100644 index 00000000000..bc60e34910d --- /dev/null +++ b/src/harness/runnerServer.ts @@ -0,0 +1,17 @@ + +/// + +import child_process = require("child_process"); + +type RunnerTestSet = string[] + +let testSets: RunnerTestSet[]; + +for (let testSet of testSets) { + let child = child_process.fork("blah!"); + child.on("message", (data: ) => { + + } +} + +function populateRunnerTestSet \ No newline at end of file diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 49ca796448a..269e889704c 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -12,7 +12,7 @@ class RunnerBase { } public enumerateFiles(folder: string, regex?: RegExp, options?: { recursive: boolean }): string[] { - return Harness.IO.listFiles(Harness.userSpecifiedroot + folder, regex, { recursive: (options ? options.recursive : false) }); + return Harness.IO.listFiles(Harness.userSpecifiedRoot + folder, regex, { recursive: (options ? options.recursive : false) }); } /** Setup the runner's tests so that they are ready to be executed by the harness From 9fec328778b40f6dc9e64cff6dbaab6ce7a387fc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 1 May 2015 17:13:28 -0700 Subject: [PATCH 043/402] Moved gargantuan arrow function that obstructed the actual logic of the method. --- src/harness/harness.ts | 54 ++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8934ab70943..5e905d999db 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -953,7 +953,32 @@ module Harness { var includeBuiltFiles: { unitName: string; content: string }[] = []; var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; - this.settings.forEach(setting => { + this.settings.forEach(setOptionForSetting); + + var fileOutputs: GeneratedFile[] = []; + + var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); + var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles), + (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), + options.target, useCaseSensitiveFileNames, currentDirectory)); + + var emitResult = program.emit(); + + var errors: HarnessDiagnostic[] = []; + ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).forEach(err => { + // TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now + errors.push(getMinimalDiagnostic(err)); + }); + this.lastErrors = errors; + + var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + onComplete(result, program); + + // reset what newline means in case the last test changed it + ts.sys.newLine = newLine; + return options; + + function setOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { switch (setting.flag.toLowerCase()) { // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" case "module": @@ -1084,7 +1109,7 @@ module Harness { case 'inlinesourcemap': options.inlineSourceMap = setting.value === 'true'; break; - + case 'inlinesources': options.inlineSources = setting.value === 'true'; break; @@ -1092,30 +1117,7 @@ module Harness { default: throw new Error('Unsupported compiler setting ' + setting.flag); } - }); - - var fileOutputs: GeneratedFile[] = []; - - var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); - var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles), - (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), - options.target, useCaseSensitiveFileNames, currentDirectory)); - - var emitResult = program.emit(); - - var errors: HarnessDiagnostic[] = []; - ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).forEach(err => { - // TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now - errors.push(getMinimalDiagnostic(err)); - }); - this.lastErrors = errors; - - var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); - onComplete(result, program); - - // reset what newline means in case the last test changed it - ts.sys.newLine = newLine; - return options; + } } public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[], From d47f3be42ec26fc0a0757bdbb4ebb97a97a71316 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 22 Apr 2015 14:11:01 -0700 Subject: [PATCH 044/402] Make expression optional in YieldExpression --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86e680ca8b0..a11d97c45fb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -660,7 +660,7 @@ module ts { export interface YieldExpression extends Expression { asteriskToken?: Node; - expression: Expression; + expression?: Expression; } export interface BinaryExpression extends Expression { From 8aa62b466dd15dbd1a144ab5c228d983ee40b305 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 23 Apr 2015 13:01:42 -0700 Subject: [PATCH 045/402] Improve yield context error message --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- tests/baselines/reference/YieldExpression12_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression14_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression15_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression16_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression17_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression18_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression2_es6.errors.txt | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04766f22c4e..e81da871809 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7897,7 +7897,7 @@ module ts { function checkYieldExpression(node: YieldExpression): void { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Yield)) { - grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); + grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_declaration); } else { grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 14163e81195..21c953e21c2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -120,7 +120,7 @@ module ts { Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, + A_yield_expression_is_only_allowed_in_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator declaration." }, Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 18c98928dda..f7ca2171fea 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -467,7 +467,7 @@ "category": "Error", "code": 1162 }, - "'yield' expression must be contained_within a generator declaration.": { + "A 'yield' expression is only allowed in a generator declaration.": { "category": "Error", "code": 1163 }, diff --git a/tests/baselines/reference/YieldExpression12_es6.errors.txt b/tests/baselines/reference/YieldExpression12_es6.errors.txt index 10843421a3f..3f007c07b6d 100644 --- a/tests/baselines/reference/YieldExpression12_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression12_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): erro constructor() { yield foo ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression14_es6.errors.txt b/tests/baselines/reference/YieldExpression14_es6.errors.txt index baeaf3ba30e..3a47ad2bf39 100644 --- a/tests/baselines/reference/YieldExpression14_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression14_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): erro foo() { yield foo ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression15_es6.errors.txt b/tests/baselines/reference/YieldExpression15_es6.errors.txt index 5e548799f5d..ded6fa9aeb8 100644 --- a/tests/baselines/reference/YieldExpression15_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression15_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ==== var v = () => { yield foo ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index c0d2e4c8fc8..304d4eca05c 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ==== @@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): erro function bar() { yield foo; ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression17_es6.errors.txt b/tests/baselines/reference/YieldExpression17_es6.errors.txt index b39f47b07f9..59b728ac495 100644 --- a/tests/baselines/reference/YieldExpression17_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression17_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ==== @@ -10,4 +10,4 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err ~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression18_es6.errors.txt b/tests/baselines/reference/YieldExpression18_es6.errors.txt index 3a67acdebcd..274592904ed 100644 --- a/tests/baselines/reference/YieldExpression18_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression18_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ==== "use strict"; yield(foo); ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression2_es6.errors.txt b/tests/baselines/reference/YieldExpression2_es6.errors.txt index 553dab51fc2..280f0b88f93 100644 --- a/tests/baselines/reference/YieldExpression2_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression2_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration. +tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ==== yield foo; ~~~~~ -!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. \ No newline at end of file From 8dac1bf033a3aeb49b8c0aee1b704a73d02e7a76 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 23 Apr 2015 13:02:02 -0700 Subject: [PATCH 046/402] Add some tests for yield* --- .../reference/YieldStarExpression1_es6.errors.txt | 10 ++++++++++ .../baselines/reference/YieldStarExpression1_es6.js | 5 +++++ .../reference/YieldStarExpression2_es6.errors.txt | 10 ++++++++++ .../baselines/reference/YieldStarExpression2_es6.js | 5 +++++ .../reference/YieldStarExpression3_es6.errors.txt | 9 +++++++++ .../baselines/reference/YieldStarExpression3_es6.js | 9 +++++++++ .../reference/YieldStarExpression4_es6.errors.txt | 12 ++++++++++++ .../baselines/reference/YieldStarExpression4_es6.js | 9 +++++++++ .../es6/yieldExpressions/YieldStarExpression1_es6.ts | 1 + .../es6/yieldExpressions/YieldStarExpression2_es6.ts | 1 + .../es6/yieldExpressions/YieldStarExpression3_es6.ts | 3 +++ .../es6/yieldExpressions/YieldStarExpression4_es6.ts | 3 +++ 12 files changed, 77 insertions(+) create mode 100644 tests/baselines/reference/YieldStarExpression1_es6.errors.txt create mode 100644 tests/baselines/reference/YieldStarExpression1_es6.js create mode 100644 tests/baselines/reference/YieldStarExpression2_es6.errors.txt create mode 100644 tests/baselines/reference/YieldStarExpression2_es6.js create mode 100644 tests/baselines/reference/YieldStarExpression3_es6.errors.txt create mode 100644 tests/baselines/reference/YieldStarExpression3_es6.js create mode 100644 tests/baselines/reference/YieldStarExpression4_es6.errors.txt create mode 100644 tests/baselines/reference/YieldStarExpression4_es6.js create mode 100644 tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts diff --git a/tests/baselines/reference/YieldStarExpression1_es6.errors.txt b/tests/baselines/reference/YieldStarExpression1_es6.errors.txt new file mode 100644 index 00000000000..9ba5e44f9aa --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression1_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts (2 errors) ==== + yield * []; + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression1_es6.js b/tests/baselines/reference/YieldStarExpression1_es6.js new file mode 100644 index 00000000000..742c5b7d1e7 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression1_es6.js @@ -0,0 +1,5 @@ +//// [YieldStarExpression1_es6.ts] +yield * []; + +//// [YieldStarExpression1_es6.js] +yield * []; diff --git a/tests/baselines/reference/YieldStarExpression2_es6.errors.txt b/tests/baselines/reference/YieldStarExpression2_es6.errors.txt new file mode 100644 index 00000000000..3d0c89fd23f --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression2_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts(1,1): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts(1,8): error TS1109: Expression expected. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts (2 errors) ==== + yield *; + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression2_es6.js b/tests/baselines/reference/YieldStarExpression2_es6.js new file mode 100644 index 00000000000..5b40963d9a2 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression2_es6.js @@ -0,0 +1,5 @@ +//// [YieldStarExpression2_es6.ts] +yield *; + +//// [YieldStarExpression2_es6.js] +yield * ; diff --git a/tests/baselines/reference/YieldStarExpression3_es6.errors.txt b/tests/baselines/reference/YieldStarExpression3_es6.errors.txt new file mode 100644 index 00000000000..25cecc80444 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression3_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts(2,12): error TS1109: Expression expected. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts (1 errors) ==== + function *g() { + yield *; + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression3_es6.js b/tests/baselines/reference/YieldStarExpression3_es6.js new file mode 100644 index 00000000000..7463fc01bc1 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression3_es6.js @@ -0,0 +1,9 @@ +//// [YieldStarExpression3_es6.ts] +function *g() { + yield *; +} + +//// [YieldStarExpression3_es6.js] +function g() { + yield* ; +} diff --git a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt new file mode 100644 index 00000000000..45d96c9ea57 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(2,5): error TS9000: 'yield' expressions are not currently supported. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (2 errors) ==== + function *g() { + ~ +!!! error TS9001: Generators are not currently supported. + yield * []; + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression4_es6.js b/tests/baselines/reference/YieldStarExpression4_es6.js new file mode 100644 index 00000000000..6283b81cca3 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression4_es6.js @@ -0,0 +1,9 @@ +//// [YieldStarExpression4_es6.ts] +function *g() { + yield * []; +} + +//// [YieldStarExpression4_es6.js] +function g() { + yield* []; +} diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts new file mode 100644 index 00000000000..d0b2a172433 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts @@ -0,0 +1 @@ +yield * []; \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts new file mode 100644 index 00000000000..9a618df4bd0 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts @@ -0,0 +1 @@ +yield *; \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts new file mode 100644 index 00000000000..3384d609c16 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts @@ -0,0 +1,3 @@ +function *g() { + yield *; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts new file mode 100644 index 00000000000..4e652232e6a --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts @@ -0,0 +1,3 @@ +function *g() { + yield * []; +} \ No newline at end of file From 124fdb60482ae6ae2b14acc5d157239677999e3e Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 22 Apr 2015 14:57:37 -0700 Subject: [PATCH 047/402] Allow yield expressions, and allow generators only in ES6 and higher --- src/compiler/checker.ts | 11 +++++++---- src/compiler/diagnosticInformationMap.generated.ts | 3 +-- src/compiler/diagnosticMessages.json | 13 +++++-------- .../reference/FunctionDeclaration10_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration11_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration13_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration1_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration6_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration7_es6.errors.txt | 8 ++++---- .../reference/FunctionDeclaration9_es6.errors.txt | 9 +++------ .../reference/FunctionExpression1_es6.errors.txt | 4 ++-- .../reference/FunctionExpression2_es6.errors.txt | 4 ++-- .../FunctionPropertyAssignments1_es6.errors.txt | 4 ++-- .../FunctionPropertyAssignments5_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration1_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration2_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration3_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration7_es6.errors.txt | 4 ++-- .../reference/YieldExpression10_es6.errors.txt | 9 +++------ .../reference/YieldExpression11_es6.errors.txt | 9 +++------ .../reference/YieldExpression13_es6.errors.txt | 9 +++------ .../reference/YieldExpression16_es6.errors.txt | 4 ++-- .../reference/YieldExpression19_es6.errors.txt | 13 +++++-------- .../reference/YieldExpression3_es6.errors.txt | 12 +++--------- .../reference/YieldExpression4_es6.errors.txt | 12 +++--------- .../reference/YieldExpression6_es6.errors.txt | 9 +++------ .../reference/YieldExpression7_es6.errors.txt | 9 +++------ .../reference/YieldExpression8_es6.errors.txt | 9 +++------ .../reference/YieldExpression9_es6.errors.txt | 9 +++------ .../reference/YieldStarExpression4_es6.errors.txt | 9 +++------ .../baselines/reference/generatorES6_1.errors.txt | 12 ------------ tests/baselines/reference/generatorES6_1.symbols | 6 ++++++ tests/baselines/reference/generatorES6_1.types | 6 ++++++ .../baselines/reference/generatorES6_2.errors.txt | 14 -------------- tests/baselines/reference/generatorES6_2.symbols | 10 ++++++++++ tests/baselines/reference/generatorES6_2.types | 10 ++++++++++ .../baselines/reference/generatorES6_3.errors.txt | 12 ------------ tests/baselines/reference/generatorES6_3.symbols | 6 ++++++ tests/baselines/reference/generatorES6_3.types | 7 +++++++ .../baselines/reference/generatorES6_4.errors.txt | 14 -------------- tests/baselines/reference/generatorES6_4.symbols | 10 ++++++++++ tests/baselines/reference/generatorES6_4.types | 11 +++++++++++ .../baselines/reference/generatorES6_5.errors.txt | 12 ------------ tests/baselines/reference/generatorES6_5.symbols | 6 ++++++ tests/baselines/reference/generatorES6_5.types | 10 ++++++++++ .../baselines/reference/generatorES6_6.errors.txt | 14 -------------- tests/baselines/reference/generatorES6_6.symbols | 13 +++++++++++++ tests/baselines/reference/generatorES6_6.types | 13 +++++++++++++ .../templateStringInYieldKeyword.errors.txt | 9 +++------ ...ateStringWithEmbeddedYieldKeywordES6.errors.txt | 14 -------------- ...mplateStringWithEmbeddedYieldKeywordES6.symbols | 9 +++++++++ ...templateStringWithEmbeddedYieldKeywordES6.types | 10 ++++++++++ .../reference/yieldExpression1.errors.txt | 9 +++------ 53 files changed, 216 insertions(+), 230 deletions(-) delete mode 100644 tests/baselines/reference/generatorES6_1.errors.txt create mode 100644 tests/baselines/reference/generatorES6_1.symbols create mode 100644 tests/baselines/reference/generatorES6_1.types delete mode 100644 tests/baselines/reference/generatorES6_2.errors.txt create mode 100644 tests/baselines/reference/generatorES6_2.symbols create mode 100644 tests/baselines/reference/generatorES6_2.types delete mode 100644 tests/baselines/reference/generatorES6_3.errors.txt create mode 100644 tests/baselines/reference/generatorES6_3.symbols create mode 100644 tests/baselines/reference/generatorES6_3.types delete mode 100644 tests/baselines/reference/generatorES6_4.errors.txt create mode 100644 tests/baselines/reference/generatorES6_4.symbols create mode 100644 tests/baselines/reference/generatorES6_4.types delete mode 100644 tests/baselines/reference/generatorES6_5.errors.txt create mode 100644 tests/baselines/reference/generatorES6_5.symbols create mode 100644 tests/baselines/reference/generatorES6_5.types delete mode 100644 tests/baselines/reference/generatorES6_6.errors.txt create mode 100644 tests/baselines/reference/generatorES6_6.symbols create mode 100644 tests/baselines/reference/generatorES6_6.types delete mode 100644 tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt create mode 100644 tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.symbols create mode 100644 tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e81da871809..36863271360 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7899,9 +7899,6 @@ module ts { if (!(node.parserContextFlags & ParserContextFlags.Yield)) { grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_declaration); } - else { - grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported); - } } function checkConditionalExpression(node: ConditionalExpression, contextualMapper?: TypeMapper): Type { @@ -12549,7 +12546,13 @@ module ts { function checkGrammarForGenerator(node: FunctionLikeDeclaration) { if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_currently_supported); + Debug.assert( + node.kind === SyntaxKind.FunctionDeclaration || + node.kind === SyntaxKind.FunctionExpression || + node.kind === SyntaxKind.MethodDeclaration); + if (languageVersion < ScriptTarget.ES6) { + return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); + } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 21c953e21c2..75f15c70a6e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -174,6 +174,7 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1219, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -539,8 +540,6 @@ module ts { enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f7ca2171fea..d6a010f2d01 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -682,8 +682,13 @@ "Export assignment is not supported when '--module' flag is 'system'.": { "category": "Error", "code": 1218 + }, + "Generators are only available when targeting ECMAScript 6 or higher.": { + "category": "Error", + "code": 1219 }, + "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -2149,14 +2154,6 @@ "code": 8017 }, - "'yield' expressions are not currently supported.": { - "category": "Error", - "code": 9000 - }, - "Generators are not currently supported.": { - "category": "Error", - "code": 9001 - }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": { "category": "Error", "code": 9002 diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 8c6b09c82d6..9b0c16e4573 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== function * foo(a = yield => yield) { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt index 1dd8c3f6a1b..9b94fcf65bc 100644 --- a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ==== function * yield() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt index a46097e8a1a..d2c056a19fb 100644 --- a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ==== function * foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. // Legal to use 'yield' in a type context. var v: yield; ~~~~~ diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt index 71b09983939..40eda833ba4 100644 --- a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ==== function * foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index b5ea3f494a7..9e660161c29 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== function*foo(a = yield) { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index f129d3fa30b..945c0b07523 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== function*bar() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. // 'yield' here is an identifier, and not a yield expression. function*foo(a = yield) { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt index 152b1ffc7cc..6f71558bb3c 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== function * foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. var v = { [yield]: foo } - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression1_es6.errors.txt b/tests/baselines/reference/FunctionExpression1_es6.errors.txt index 979178fd4b7..8b76843a0c4 100644 --- a/tests/baselines/reference/FunctionExpression1_es6.errors.txt +++ b/tests/baselines/reference/FunctionExpression1_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ==== var v = function * () { } ~ -!!! error TS9001: Generators are not currently supported. \ No newline at end of file +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression2_es6.errors.txt b/tests/baselines/reference/FunctionExpression2_es6.errors.txt index ab27947d7c5..b39b79a6828 100644 --- a/tests/baselines/reference/FunctionExpression2_es6.errors.txt +++ b/tests/baselines/reference/FunctionExpression2_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ==== var v = function * foo() { } ~ -!!! error TS9001: Generators are not currently supported. \ No newline at end of file +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt index bbabbc97463..24ff737ba6d 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ==== var v = { *foo() { } } ~ -!!! error TS9001: Generators are not currently supported. \ No newline at end of file +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index 596764e58ea..989d7d4ab8a 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ==== var v = { *[foo()]() { } } ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ~~~ !!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt index 9d4e312ed22..cc4c163878d 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ==== class C { *foo() { } ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt index 6373c800994..99f48469d9d 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ==== class C { public * foo() { } ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index 826c1d7fd75..b201b3142f4 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'. @@ -6,7 +6,7 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration class C { *[foo]() { } ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ~~~ !!! error TS2304: Cannot find name 'foo'. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt index ea87da50ed3..63f2e2be6c2 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ==== class C { *foo() { } ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression10_es6.errors.txt b/tests/baselines/reference/YieldExpression10_es6.errors.txt index e0d7ea4ad27..504dbdf9341 100644 --- a/tests/baselines/reference/YieldExpression10_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression10_es6.errors.txt @@ -1,14 +1,11 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,5): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (1 errors) ==== var v = { * foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression11_es6.errors.txt b/tests/baselines/reference/YieldExpression11_es6.errors.txt index 3f322a81f2f..df070d2bd7f 100644 --- a/tests/baselines/reference/YieldExpression11_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression11_es6.errors.txt @@ -1,14 +1,11 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,5): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (1 errors) ==== class C { *foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression13_es6.errors.txt b/tests/baselines/reference/YieldExpression13_es6.errors.txt index fc2d885d381..9a5abc60a41 100644 --- a/tests/baselines/reference/YieldExpression13_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression13_es6.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,19): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ==== function* foo() { yield } ~ -!!! error TS9001: Generators are not currently supported. - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. \ No newline at end of file +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index 304d4eca05c..e14f93f5291 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ==== function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. function bar() { yield foo; ~~~~~ diff --git a/tests/baselines/reference/YieldExpression19_es6.errors.txt b/tests/baselines/reference/YieldExpression19_es6.errors.txt index 9d04d9559b0..ecb2809b8af 100644 --- a/tests/baselines/reference/YieldExpression19_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression19_es6.errors.txt @@ -1,19 +1,16 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(4,7): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (2 errors) ==== function*foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. function bar() { function* quux() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression3_es6.errors.txt b/tests/baselines/reference/YieldExpression3_es6.errors.txt index 1e284c92786..653f24d6c12 100644 --- a/tests/baselines/reference/YieldExpression3_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression3_es6.errors.txt @@ -1,16 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. yield - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression4_es6.errors.txt b/tests/baselines/reference/YieldExpression4_es6.errors.txt index 2d2a7ca3257..73411e94207 100644 --- a/tests/baselines/reference/YieldExpression4_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression4_es6.errors.txt @@ -1,16 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. yield; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression6_es6.errors.txt b/tests/baselines/reference/YieldExpression6_es6.errors.txt index a3d9481601a..494d1b447bd 100644 --- a/tests/baselines/reference/YieldExpression6_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression6_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield*foo - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression7_es6.errors.txt b/tests/baselines/reference/YieldExpression7_es6.errors.txt index 393a03ee269..f26cc84be0a 100644 --- a/tests/baselines/reference/YieldExpression7_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression7_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield foo - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression8_es6.errors.txt b/tests/baselines/reference/YieldExpression8_es6.errors.txt index 3f7933c5bb2..ba9e621fd70 100644 --- a/tests/baselines/reference/YieldExpression8_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression8_es6.errors.txt @@ -1,16 +1,13 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (2 errors) ==== yield(foo); ~~~~~ !!! error TS2304: Cannot find name 'yield'. function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression9_es6.errors.txt b/tests/baselines/reference/YieldExpression9_es6.errors.txt index cd753647327..c3a60cc8667 100644 --- a/tests/baselines/reference/YieldExpression9_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression9_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (1 errors) ==== var v = function*() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt index 45d96c9ea57..ab1ddae6989 100644 --- a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt +++ b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(2,5): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (1 errors) ==== function *g() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield * []; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_1.errors.txt b/tests/baselines/reference/generatorES6_1.errors.txt deleted file mode 100644 index b02da7f0b53..00000000000 --- a/tests/baselines/reference/generatorES6_1.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/generatorES6_1.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/compiler/generatorES6_1.ts(2,5): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/compiler/generatorES6_1.ts (2 errors) ==== - function* foo() { - ~ -!!! error TS9001: Generators are not currently supported. - yield - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_1.symbols b/tests/baselines/reference/generatorES6_1.symbols new file mode 100644 index 00000000000..fc5aa602e01 --- /dev/null +++ b/tests/baselines/reference/generatorES6_1.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/generatorES6_1.ts === +function* foo() { +>foo : Symbol(foo, Decl(generatorES6_1.ts, 0, 0)) + + yield +} diff --git a/tests/baselines/reference/generatorES6_1.types b/tests/baselines/reference/generatorES6_1.types new file mode 100644 index 00000000000..faf16398303 --- /dev/null +++ b/tests/baselines/reference/generatorES6_1.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/generatorES6_1.ts === +function* foo() { +>foo : () => void + + yield +} diff --git a/tests/baselines/reference/generatorES6_2.errors.txt b/tests/baselines/reference/generatorES6_2.errors.txt deleted file mode 100644 index 8d956fc7f63..00000000000 --- a/tests/baselines/reference/generatorES6_2.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/generatorES6_2.ts(2,12): error TS9001: Generators are not currently supported. -tests/cases/compiler/generatorES6_2.ts(3,9): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/compiler/generatorES6_2.ts (2 errors) ==== - class C { - public * foo() { - ~ -!!! error TS9001: Generators are not currently supported. - yield 1 - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_2.symbols b/tests/baselines/reference/generatorES6_2.symbols new file mode 100644 index 00000000000..a64b1304692 --- /dev/null +++ b/tests/baselines/reference/generatorES6_2.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/generatorES6_2.ts === +class C { +>C : Symbol(C, Decl(generatorES6_2.ts, 0, 0)) + + public * foo() { +>foo : Symbol(foo, Decl(generatorES6_2.ts, 0, 9)) + + yield 1 + } +} diff --git a/tests/baselines/reference/generatorES6_2.types b/tests/baselines/reference/generatorES6_2.types new file mode 100644 index 00000000000..2948424b120 --- /dev/null +++ b/tests/baselines/reference/generatorES6_2.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/generatorES6_2.ts === +class C { +>C : C + + public * foo() { +>foo : () => void + + yield 1 + } +} diff --git a/tests/baselines/reference/generatorES6_3.errors.txt b/tests/baselines/reference/generatorES6_3.errors.txt deleted file mode 100644 index e1c1d918ce6..00000000000 --- a/tests/baselines/reference/generatorES6_3.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/generatorES6_3.ts(1,17): error TS9001: Generators are not currently supported. -tests/cases/compiler/generatorES6_3.ts(2,5): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/compiler/generatorES6_3.ts (2 errors) ==== - var v = function*() { - ~ -!!! error TS9001: Generators are not currently supported. - yield 0 - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_3.symbols b/tests/baselines/reference/generatorES6_3.symbols new file mode 100644 index 00000000000..329c96e6de8 --- /dev/null +++ b/tests/baselines/reference/generatorES6_3.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/generatorES6_3.ts === +var v = function*() { +>v : Symbol(v, Decl(generatorES6_3.ts, 0, 3)) + + yield 0 +} diff --git a/tests/baselines/reference/generatorES6_3.types b/tests/baselines/reference/generatorES6_3.types new file mode 100644 index 00000000000..e627fff9efd --- /dev/null +++ b/tests/baselines/reference/generatorES6_3.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/generatorES6_3.ts === +var v = function*() { +>v : () => void +>function*() { yield 0} : () => void + + yield 0 +} diff --git a/tests/baselines/reference/generatorES6_4.errors.txt b/tests/baselines/reference/generatorES6_4.errors.txt deleted file mode 100644 index 37c375e9728..00000000000 --- a/tests/baselines/reference/generatorES6_4.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/generatorES6_4.ts(2,4): error TS9001: Generators are not currently supported. -tests/cases/compiler/generatorES6_4.ts(3,8): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/compiler/generatorES6_4.ts (2 errors) ==== - var v = { - *foo() { - ~ -!!! error TS9001: Generators are not currently supported. - yield 0 - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_4.symbols b/tests/baselines/reference/generatorES6_4.symbols new file mode 100644 index 00000000000..fc514dad45f --- /dev/null +++ b/tests/baselines/reference/generatorES6_4.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/generatorES6_4.ts === +var v = { +>v : Symbol(v, Decl(generatorES6_4.ts, 0, 3)) + + *foo() { +>foo : Symbol(foo, Decl(generatorES6_4.ts, 0, 9)) + + yield 0 + } +} diff --git a/tests/baselines/reference/generatorES6_4.types b/tests/baselines/reference/generatorES6_4.types new file mode 100644 index 00000000000..5b34aff9f6e --- /dev/null +++ b/tests/baselines/reference/generatorES6_4.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/generatorES6_4.ts === +var v = { +>v : { foo(): void; } +>{ *foo() { yield 0 }} : { foo(): void; } + + *foo() { +>foo : () => void + + yield 0 + } +} diff --git a/tests/baselines/reference/generatorES6_5.errors.txt b/tests/baselines/reference/generatorES6_5.errors.txt deleted file mode 100644 index f6fa8a5bc18..00000000000 --- a/tests/baselines/reference/generatorES6_5.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/generatorES6_5.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/compiler/generatorES6_5.ts(2,5): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/compiler/generatorES6_5.ts (2 errors) ==== - function* foo() { - ~ -!!! error TS9001: Generators are not currently supported. - yield a ? b : c; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_5.symbols b/tests/baselines/reference/generatorES6_5.symbols new file mode 100644 index 00000000000..7ed7fe3ab8c --- /dev/null +++ b/tests/baselines/reference/generatorES6_5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/generatorES6_5.ts === +function* foo() { +>foo : Symbol(foo, Decl(generatorES6_5.ts, 0, 0)) + + yield a ? b : c; +} diff --git a/tests/baselines/reference/generatorES6_5.types b/tests/baselines/reference/generatorES6_5.types new file mode 100644 index 00000000000..9e500c7f4b6 --- /dev/null +++ b/tests/baselines/reference/generatorES6_5.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/generatorES6_5.ts === +function* foo() { +>foo : () => void + + yield a ? b : c; +>a ? b : c : any +>a : any +>b : any +>c : any +} diff --git a/tests/baselines/reference/generatorES6_6.errors.txt b/tests/baselines/reference/generatorES6_6.errors.txt deleted file mode 100644 index 1f568aeb9e4..00000000000 --- a/tests/baselines/reference/generatorES6_6.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/generatorES6_6.ts(2,3): error TS9001: Generators are not currently supported. -tests/cases/compiler/generatorES6_6.ts(3,13): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/compiler/generatorES6_6.ts (2 errors) ==== - class C { - *[Symbol.iterator]() { - ~ -!!! error TS9001: Generators are not currently supported. - let a = yield 1; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols new file mode 100644 index 00000000000..85d557fb91f --- /dev/null +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/generatorES6_6.ts === +class C { +>C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) + + *[Symbol.iterator]() { +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) + + let a = yield 1; +>a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) + } +} diff --git a/tests/baselines/reference/generatorES6_6.types b/tests/baselines/reference/generatorES6_6.types new file mode 100644 index 00000000000..731c9b47f55 --- /dev/null +++ b/tests/baselines/reference/generatorES6_6.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/generatorES6_6.ts === +class C { +>C : C + + *[Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + let a = yield 1; +>a : any + } +} diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt index 7b28cf64ae9..fe9937f2a96 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt @@ -1,14 +1,11 @@ -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (2 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (1 errors) ==== function* gen() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. // Once this is supported, the inner expression does not need to be parenthesized. var x = yield `abc${ x }def`; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt deleted file mode 100644 index 46ca3c74b95..00000000000 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,20): error TS9000: 'yield' expressions are not currently supported. - - -==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts (2 errors) ==== - function* gen() { - ~ -!!! error TS9001: Generators are not currently supported. - // Once this is supported, yield *must* be parenthesized. - var x = `abc${ yield 10 }def`; - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. - } - \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.symbols new file mode 100644 index 00000000000..4248d66fb42 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === +function* gen() { +>gen : Symbol(gen, Decl(templateStringWithEmbeddedYieldKeywordES6.ts, 0, 0)) + + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +>x : Symbol(x, Decl(templateStringWithEmbeddedYieldKeywordES6.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types new file mode 100644 index 00000000000..9772a732868 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === +function* gen() { +>gen : () => void + + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +>x : string +>`abc${ yield 10 }def` : string +} + diff --git a/tests/baselines/reference/yieldExpression1.errors.txt b/tests/baselines/reference/yieldExpression1.errors.txt index 91a379e6172..e0c143d39de 100644 --- a/tests/baselines/reference/yieldExpression1.errors.txt +++ b/tests/baselines/reference/yieldExpression1.errors.txt @@ -1,12 +1,9 @@ -tests/cases/compiler/yieldExpression1.ts(1,9): error TS9001: Generators are not currently supported. -tests/cases/compiler/yieldExpression1.ts(2,5): error TS9000: 'yield' expressions are not currently supported. +tests/cases/compiler/yieldExpression1.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -==== tests/cases/compiler/yieldExpression1.ts (2 errors) ==== +==== tests/cases/compiler/yieldExpression1.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: Generators are not currently supported. +!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. yield - ~~~~~ -!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file From d52c224697fca50fa3d421490a7f98c7f63ce019 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 22 Apr 2015 16:35:45 -0700 Subject: [PATCH 048/402] Disallow generators in an ambient context --- src/compiler/checker.ts | 3 +++ .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ .../generatorInAmbientContext1.errors.txt | 9 +++++++++ .../reference/generatorInAmbientContext1.js | 6 ++++++ .../generatorInAmbientContext2.errors.txt | 9 +++++++++ .../reference/generatorInAmbientContext2.js | 6 ++++++ .../generatorInAmbientContext3.d.errors.txt | 9 +++++++++ .../generatorInAmbientContext4.d.errors.txt | 9 +++++++++ .../reference/generatorInAmbientContext5.js | 15 +++++++++++++++ .../generatorInAmbientContext5.symbols | 7 +++++++ .../reference/generatorInAmbientContext5.types | 7 +++++++ .../reference/generatorInAmbientContext6.js | 17 +++++++++++++++++ .../generatorInAmbientContext6.symbols | 7 +++++++ .../reference/generatorInAmbientContext6.types | 7 +++++++ .../generatorInAmbientContext1.ts | 4 ++++ .../generatorInAmbientContext2.ts | 4 ++++ .../generatorInAmbientContext3.d.ts | 4 ++++ .../generatorInAmbientContext4.d.ts | 4 ++++ .../generatorInAmbientContext5.ts | 5 +++++ .../generatorInAmbientContext6.ts | 5 +++++ 21 files changed, 142 insertions(+) create mode 100644 tests/baselines/reference/generatorInAmbientContext1.errors.txt create mode 100644 tests/baselines/reference/generatorInAmbientContext1.js create mode 100644 tests/baselines/reference/generatorInAmbientContext2.errors.txt create mode 100644 tests/baselines/reference/generatorInAmbientContext2.js create mode 100644 tests/baselines/reference/generatorInAmbientContext3.d.errors.txt create mode 100644 tests/baselines/reference/generatorInAmbientContext4.d.errors.txt create mode 100644 tests/baselines/reference/generatorInAmbientContext5.js create mode 100644 tests/baselines/reference/generatorInAmbientContext5.symbols create mode 100644 tests/baselines/reference/generatorInAmbientContext5.types create mode 100644 tests/baselines/reference/generatorInAmbientContext6.js create mode 100644 tests/baselines/reference/generatorInAmbientContext6.symbols create mode 100644 tests/baselines/reference/generatorInAmbientContext6.types create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext5.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext6.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 36863271360..c7bd4adb2e2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12550,6 +12550,9 @@ module ts { node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.MethodDeclaration); + if (isInAmbientContext(node)) { + return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_allowed_in_an_ambient_context); + } if (languageVersion < ScriptTarget.ES6) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 75f15c70a6e..7e5a9b8e241 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -175,6 +175,7 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1219, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, + Generators_are_not_allowed_in_an_ambient_context: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d6a010f2d01..d0ef2d22ffb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -687,6 +687,10 @@ "category": "Error", "code": 1219 }, + "Generators are not allowed in an ambient context.": { + "category": "Error", + "code": 1220 + }, "Duplicate identifier '{0}'.": { diff --git a/tests/baselines/reference/generatorInAmbientContext1.errors.txt b/tests/baselines/reference/generatorInAmbientContext1.errors.txt new file mode 100644 index 00000000000..827257da6f7 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext1.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts(2,5): error TS1219: Generators are not allowed in an ambient context. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts (1 errors) ==== + declare class C { + *generator(): any; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext1.js b/tests/baselines/reference/generatorInAmbientContext1.js new file mode 100644 index 00000000000..e7b4e03e64e --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext1.js @@ -0,0 +1,6 @@ +//// [generatorInAmbientContext1.ts] +declare class C { + *generator(): any; +} + +//// [generatorInAmbientContext1.js] diff --git a/tests/baselines/reference/generatorInAmbientContext2.errors.txt b/tests/baselines/reference/generatorInAmbientContext2.errors.txt new file mode 100644 index 00000000000..0d2439dbe35 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext2.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts(2,14): error TS1219: Generators are not allowed in an ambient context. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts (1 errors) ==== + declare module M { + function *generator(): any; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext2.js b/tests/baselines/reference/generatorInAmbientContext2.js new file mode 100644 index 00000000000..f7742ccc235 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext2.js @@ -0,0 +1,6 @@ +//// [generatorInAmbientContext2.ts] +declare module M { + function *generator(): any; +} + +//// [generatorInAmbientContext2.js] diff --git a/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt b/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt new file mode 100644 index 00000000000..e7cab556be4 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts(2,5): error TS1219: Generators are not allowed in an ambient context. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts (1 errors) ==== + declare class C { + *generator(): any; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt b/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt new file mode 100644 index 00000000000..e47cbd2b7e9 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts(2,14): error TS1219: Generators are not allowed in an ambient context. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts (1 errors) ==== + declare module M { + function *generator(): any; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext5.js b/tests/baselines/reference/generatorInAmbientContext5.js new file mode 100644 index 00000000000..044155e8dd5 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext5.js @@ -0,0 +1,15 @@ +//// [generatorInAmbientContext5.ts] +class C { + *generator(): any { } +} + +//// [generatorInAmbientContext5.js] +class C { + *generator() { } +} + + +//// [generatorInAmbientContext5.d.ts] +declare class C { + generator(): any; +} diff --git a/tests/baselines/reference/generatorInAmbientContext5.symbols b/tests/baselines/reference/generatorInAmbientContext5.symbols new file mode 100644 index 00000000000..78139a7e597 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext5.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext5.ts === +class C { +>C : Symbol(C, Decl(generatorInAmbientContext5.ts, 0, 0)) + + *generator(): any { } +>generator : Symbol(generator, Decl(generatorInAmbientContext5.ts, 0, 9)) +} diff --git a/tests/baselines/reference/generatorInAmbientContext5.types b/tests/baselines/reference/generatorInAmbientContext5.types new file mode 100644 index 00000000000..169aba8201b --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext5.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext5.ts === +class C { +>C : C + + *generator(): any { } +>generator : () => any +} diff --git a/tests/baselines/reference/generatorInAmbientContext6.js b/tests/baselines/reference/generatorInAmbientContext6.js new file mode 100644 index 00000000000..10cfa85d933 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext6.js @@ -0,0 +1,17 @@ +//// [generatorInAmbientContext6.ts] +module M { + export function *generator(): any { } +} + +//// [generatorInAmbientContext6.js] +var M; +(function (M) { + function* generator() { } + M.generator = generator; +})(M || (M = {})); + + +//// [generatorInAmbientContext6.d.ts] +declare module M { + function generator(): any; +} diff --git a/tests/baselines/reference/generatorInAmbientContext6.symbols b/tests/baselines/reference/generatorInAmbientContext6.symbols new file mode 100644 index 00000000000..e921a2b1f96 --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext6.ts === +module M { +>M : Symbol(M, Decl(generatorInAmbientContext6.ts, 0, 0)) + + export function *generator(): any { } +>generator : Symbol(generator, Decl(generatorInAmbientContext6.ts, 0, 10)) +} diff --git a/tests/baselines/reference/generatorInAmbientContext6.types b/tests/baselines/reference/generatorInAmbientContext6.types new file mode 100644 index 00000000000..d960126210e --- /dev/null +++ b/tests/baselines/reference/generatorInAmbientContext6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext6.ts === +module M { +>M : typeof M + + export function *generator(): any { } +>generator : () => any +} diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts new file mode 100644 index 00000000000..b4a3108fe34 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare class C { + *generator(): any; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts new file mode 100644 index 00000000000..f4d560c521f --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare module M { + function *generator(): any; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts new file mode 100644 index 00000000000..b4a3108fe34 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare class C { + *generator(): any; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts new file mode 100644 index 00000000000..f4d560c521f --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare module M { + function *generator(): any; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext5.ts b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext5.ts new file mode 100644 index 00000000000..559b5e8dacb --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext5.ts @@ -0,0 +1,5 @@ +//@target: ES6 +//@declaration: true +class C { + *generator(): any { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext6.ts b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext6.ts new file mode 100644 index 00000000000..fb7c358f189 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext6.ts @@ -0,0 +1,5 @@ +//@target: ES6 +//@declaration: true +module M { + export function *generator(): any { } +} \ No newline at end of file From 7f5a89ae5e597f209f79c5d9263fb3eb5664089d Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 23 Apr 2015 13:25:41 -0700 Subject: [PATCH 049/402] Disallow * token on overload signatures --- src/compiler/checker.ts | 3 +++ .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ .../reference/generatorOverloads1.errors.txt | 14 ++++++++++++++ .../reference/generatorOverloads1.js | 12 ++++++++++++ .../reference/generatorOverloads2.errors.txt | 17 +++++++++++++++++ .../reference/generatorOverloads2.js | 8 ++++++++ .../reference/generatorOverloads3.errors.txt | 14 ++++++++++++++ .../reference/generatorOverloads3.js | 11 +++++++++++ .../reference/generatorOverloads4.js | 11 +++++++++++ .../reference/generatorOverloads4.symbols | 19 +++++++++++++++++++ .../reference/generatorOverloads4.types | 19 +++++++++++++++++++ .../reference/generatorOverloads5.js | 12 ++++++++++++ .../reference/generatorOverloads5.symbols | 19 +++++++++++++++++++ .../reference/generatorOverloads5.types | 19 +++++++++++++++++++ .../yieldExpressions/generatorOverloads1.ts | 6 ++++++ .../yieldExpressions/generatorOverloads2.ts | 6 ++++++ .../yieldExpressions/generatorOverloads3.ts | 6 ++++++ .../yieldExpressions/generatorOverloads4.ts | 6 ++++++ .../yieldExpressions/generatorOverloads5.ts | 6 ++++++ 20 files changed, 213 insertions(+) create mode 100644 tests/baselines/reference/generatorOverloads1.errors.txt create mode 100644 tests/baselines/reference/generatorOverloads1.js create mode 100644 tests/baselines/reference/generatorOverloads2.errors.txt create mode 100644 tests/baselines/reference/generatorOverloads2.js create mode 100644 tests/baselines/reference/generatorOverloads3.errors.txt create mode 100644 tests/baselines/reference/generatorOverloads3.js create mode 100644 tests/baselines/reference/generatorOverloads4.js create mode 100644 tests/baselines/reference/generatorOverloads4.symbols create mode 100644 tests/baselines/reference/generatorOverloads4.types create mode 100644 tests/baselines/reference/generatorOverloads5.js create mode 100644 tests/baselines/reference/generatorOverloads5.symbols create mode 100644 tests/baselines/reference/generatorOverloads5.types create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorOverloads4.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorOverloads5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c7bd4adb2e2..f8ced24b8c5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12553,6 +12553,9 @@ module ts { if (isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } + if (!node.body) { + return grammarErrorOnNode(node.asteriskToken, Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); + } if (languageVersion < ScriptTarget.ES6) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 7e5a9b8e241..1faadd4efcc 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -176,6 +176,7 @@ module ts { Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1219, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, + An_overload_signature_cannot_be_declared_as_a_generator: { code: 1221, category: DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d0ef2d22ffb..c781323b497 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -691,6 +691,10 @@ "category": "Error", "code": 1220 }, + "An overload signature cannot be declared as a generator.": { + "category": "Error", + "code": 1221 + }, "Duplicate identifier '{0}'.": { diff --git a/tests/baselines/reference/generatorOverloads1.errors.txt b/tests/baselines/reference/generatorOverloads1.errors.txt new file mode 100644 index 00000000000..2dea232ae1c --- /dev/null +++ b/tests/baselines/reference/generatorOverloads1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts(2,13): error TS1220: An overload signature cannot be declared as a generator. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts(3,13): error TS1220: An overload signature cannot be declared as a generator. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts (2 errors) ==== + module M { + function* f(s: string): Iterable; + ~ +!!! error TS1220: An overload signature cannot be declared as a generator. + function* f(s: number): Iterable; + ~ +!!! error TS1220: An overload signature cannot be declared as a generator. + function* f(s: any): Iterable { } + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorOverloads1.js b/tests/baselines/reference/generatorOverloads1.js new file mode 100644 index 00000000000..0ce5ae10f4d --- /dev/null +++ b/tests/baselines/reference/generatorOverloads1.js @@ -0,0 +1,12 @@ +//// [generatorOverloads1.ts] +module M { + function* f(s: string): Iterable; + function* f(s: number): Iterable; + function* f(s: any): Iterable { } +} + +//// [generatorOverloads1.js] +var M; +(function (M) { + function* f(s) { } +})(M || (M = {})); diff --git a/tests/baselines/reference/generatorOverloads2.errors.txt b/tests/baselines/reference/generatorOverloads2.errors.txt new file mode 100644 index 00000000000..d17860abf3f --- /dev/null +++ b/tests/baselines/reference/generatorOverloads2.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(2,13): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(3,13): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(4,13): error TS1219: Generators are not allowed in an ambient context. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts (3 errors) ==== + declare module M { + function* f(s: string): Iterable; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + function* f(s: number): Iterable; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + function* f(s: any): Iterable; + ~ +!!! error TS1219: Generators are not allowed in an ambient context. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorOverloads2.js b/tests/baselines/reference/generatorOverloads2.js new file mode 100644 index 00000000000..4fa3837ed36 --- /dev/null +++ b/tests/baselines/reference/generatorOverloads2.js @@ -0,0 +1,8 @@ +//// [generatorOverloads2.ts] +declare module M { + function* f(s: string): Iterable; + function* f(s: number): Iterable; + function* f(s: any): Iterable; +} + +//// [generatorOverloads2.js] diff --git a/tests/baselines/reference/generatorOverloads3.errors.txt b/tests/baselines/reference/generatorOverloads3.errors.txt new file mode 100644 index 00000000000..6f2a5dfa619 --- /dev/null +++ b/tests/baselines/reference/generatorOverloads3.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts(2,5): error TS1220: An overload signature cannot be declared as a generator. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts(3,5): error TS1220: An overload signature cannot be declared as a generator. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts (2 errors) ==== + class C { + *f(s: string): Iterable; + ~ +!!! error TS1220: An overload signature cannot be declared as a generator. + *f(s: number): Iterable; + ~ +!!! error TS1220: An overload signature cannot be declared as a generator. + *f(s: any): Iterable { } + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorOverloads3.js b/tests/baselines/reference/generatorOverloads3.js new file mode 100644 index 00000000000..55ba5dcdc99 --- /dev/null +++ b/tests/baselines/reference/generatorOverloads3.js @@ -0,0 +1,11 @@ +//// [generatorOverloads3.ts] +class C { + *f(s: string): Iterable; + *f(s: number): Iterable; + *f(s: any): Iterable { } +} + +//// [generatorOverloads3.js] +class C { + *f(s) { } +} diff --git a/tests/baselines/reference/generatorOverloads4.js b/tests/baselines/reference/generatorOverloads4.js new file mode 100644 index 00000000000..8ebbcb59381 --- /dev/null +++ b/tests/baselines/reference/generatorOverloads4.js @@ -0,0 +1,11 @@ +//// [generatorOverloads4.ts] +class C { + f(s: string): Iterable; + f(s: number): Iterable; + *f(s: any): Iterable { } +} + +//// [generatorOverloads4.js] +class C { + *f(s) { } +} diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols new file mode 100644 index 00000000000..f21e88e4e6e --- /dev/null +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorOverloads4.ts === +class C { +>C : Symbol(C, Decl(generatorOverloads4.ts, 0, 0)) + + f(s: string): Iterable; +>f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) +>s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) + + f(s: number): Iterable; +>f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) +>s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) + + *f(s: any): Iterable { } +>f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) +>s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +} diff --git a/tests/baselines/reference/generatorOverloads4.types b/tests/baselines/reference/generatorOverloads4.types new file mode 100644 index 00000000000..493e0ac307c --- /dev/null +++ b/tests/baselines/reference/generatorOverloads4.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorOverloads4.ts === +class C { +>C : C + + f(s: string): Iterable; +>f : { (s: string): Iterable; (s: number): Iterable; } +>s : string +>Iterable : Iterable + + f(s: number): Iterable; +>f : { (s: string): Iterable; (s: number): Iterable; } +>s : number +>Iterable : Iterable + + *f(s: any): Iterable { } +>f : { (s: string): Iterable; (s: number): Iterable; } +>s : any +>Iterable : Iterable +} diff --git a/tests/baselines/reference/generatorOverloads5.js b/tests/baselines/reference/generatorOverloads5.js new file mode 100644 index 00000000000..c6d928045fa --- /dev/null +++ b/tests/baselines/reference/generatorOverloads5.js @@ -0,0 +1,12 @@ +//// [generatorOverloads5.ts] +module M { + function f(s: string): Iterable; + function f(s: number): Iterable; + function* f(s: any): Iterable { } +} + +//// [generatorOverloads5.js] +var M; +(function (M) { + function* f(s) { } +})(M || (M = {})); diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols new file mode 100644 index 00000000000..6365a2f205c --- /dev/null +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorOverloads5.ts === +module M { +>M : Symbol(M, Decl(generatorOverloads5.ts, 0, 0)) + + function f(s: string): Iterable; +>f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) +>s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) + + function f(s: number): Iterable; +>f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) +>s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) + + function* f(s: any): Iterable { } +>f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) +>s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +} diff --git a/tests/baselines/reference/generatorOverloads5.types b/tests/baselines/reference/generatorOverloads5.types new file mode 100644 index 00000000000..276baf1ff40 --- /dev/null +++ b/tests/baselines/reference/generatorOverloads5.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorOverloads5.ts === +module M { +>M : typeof M + + function f(s: string): Iterable; +>f : { (s: string): Iterable; (s: number): Iterable; } +>s : string +>Iterable : Iterable + + function f(s: number): Iterable; +>f : { (s: string): Iterable; (s: number): Iterable; } +>s : number +>Iterable : Iterable + + function* f(s: any): Iterable { } +>f : { (s: string): Iterable; (s: number): Iterable; } +>s : any +>Iterable : Iterable +} diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts new file mode 100644 index 00000000000..c21ecea7826 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts @@ -0,0 +1,6 @@ +//@target: ES6 +module M { + function* f(s: string): Iterable; + function* f(s: number): Iterable; + function* f(s: any): Iterable { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts new file mode 100644 index 00000000000..de362aedc8b --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts @@ -0,0 +1,6 @@ +//@target: ES6 +declare module M { + function* f(s: string): Iterable; + function* f(s: number): Iterable; + function* f(s: any): Iterable; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts new file mode 100644 index 00000000000..6f482573241 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + *f(s: string): Iterable; + *f(s: number): Iterable; + *f(s: any): Iterable { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorOverloads4.ts b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads4.ts new file mode 100644 index 00000000000..7342a49a366 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads4.ts @@ -0,0 +1,6 @@ +//@target: ES6 +class C { + f(s: string): Iterable; + f(s: number): Iterable; + *f(s: any): Iterable { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorOverloads5.ts b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads5.ts new file mode 100644 index 00000000000..1efa9af0839 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorOverloads5.ts @@ -0,0 +1,6 @@ +//@target: ES6 +module M { + function f(s: string): Iterable; + function f(s: number): Iterable; + function* f(s: any): Iterable { } +} \ No newline at end of file From be5557a6445a0276a538f91d409b7fd19a852c2d Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 23 Apr 2015 14:55:13 -0700 Subject: [PATCH 050/402] Formatting for generators --- src/services/formatting/rules.ts | 14 +++++++++++++- .../fourslash/generatorDeclarationFormatting.ts | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/generatorDeclarationFormatting.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 0b6a6ad0bdc..b6b33ca51f3 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -193,12 +193,16 @@ module ts.formatting { // Insert space after function keyword for anonymous functions public SpaceAfterAnonymousFunctionKeyword: Rule; public NoSpaceAfterAnonymousFunctionKeyword: Rule; - + // Insert space after @ in decorator public SpaceBeforeAt: Rule; public NoSpaceAfterAt: Rule; public SpaceAfterDecorator: Rule; + // Generator: function* + public NoSpaceBetweenFunctionKeywordAndStar: Rule; + public SpaceAfterStarInGenerator: Rule; + constructor() { /// /// Common Rules @@ -340,6 +344,9 @@ module ts.formatting { this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); + this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete)); + this.SpaceAfterStarInGenerator = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); + // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -357,6 +364,7 @@ module ts.formatting { this.NoSpaceAfterCloseBrace, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, + this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGenerator, this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, this.NoSpaceBetweenReturnAndSemicolon, this.SpaceAfterCertainKeywords, @@ -574,6 +582,10 @@ module ts.formatting { return false; } + static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.FunctionDeclaration || context.contextNode.kind === SyntaxKind.FunctionExpression; + } + static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); } diff --git a/tests/cases/fourslash/generatorDeclarationFormatting.ts b/tests/cases/fourslash/generatorDeclarationFormatting.ts new file mode 100644 index 00000000000..007380fd0de --- /dev/null +++ b/tests/cases/fourslash/generatorDeclarationFormatting.ts @@ -0,0 +1,10 @@ +/// + +//// function *g() { }/*1*/ +//// var v = function *() { };/*2*/ + +format.document(); +goTo.marker('1'); +verify.currentLineContentIs("function* g() { }"); +goTo.marker('2'); +verify.currentLineContentIs("var v = function* () { };"); \ No newline at end of file From 5c48620b17ee423751ba3f94b023f71a24e97d76 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 24 Apr 2015 15:49:05 -0700 Subject: [PATCH 051/402] Move getIteratedType out of checkIteratedType --- src/compiler/checker.ts | 168 ++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8ced24b8c5..10b81677e3a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5850,7 +5850,7 @@ module ts { let index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || (languageVersion >= ScriptTarget.ES6 ? checkIteratedType(type, /*expressionForError*/ undefined) : undefined); + || (languageVersion >= ScriptTarget.ES6 ? getIteratedType(type, /*expressionForError*/ undefined) : undefined); } return undefined; } @@ -6037,7 +6037,7 @@ module ts { // if there is no index type / iterated type. let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - (languageVersion >= ScriptTarget.ES6 ? checkIteratedType(restArrayType, /*expressionForError*/ undefined) : undefined); + (languageVersion >= ScriptTarget.ES6 ? getIteratedType(restArrayType, /*expressionForError*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); @@ -9469,7 +9469,6 @@ module ts { * When errorNode is undefined, it means we should not report any errors. */ function checkIteratedType(iterable: Type, errorNode: Node): Type { - Debug.assert(languageVersion >= ScriptTarget.ES6); let iteratedType = getIteratedType(iterable, errorNode); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. @@ -9478,90 +9477,91 @@ module ts { } return iteratedType; + } - function getIteratedType(iterable: Type, errorNode: Node) { - // We want to treat type as an iterable, and get the type it is an iterable of. The iterable - // must have the following structure (annotated with the names of the variables below): - // - // { // iterable - // [Symbol.iterator]: { // iteratorFunction - // (): { // iterator - // next: { // iteratorNextFunction - // (): { // iteratorNextResult - // value: T // iteratorNextValue - // } - // } - // } - // } - // } - // - // T is the type we are after. At every level that involves analyzing return types - // of signatures, we union the return types of all the signatures. - // - // Another thing to note is that at any step of this process, we could run into a dead end, - // meaning either the property is missing, or we run into the anyType. If either of these things - // happens, we return undefined to signal that we could not find the iterated type. If a property - // is missing, and the previous step did not result in 'any', then we also give an error if the - // caller requested it. Then the caller can decide what to do in the case where there is no iterated - // type. This is different from returning anyType, because that would signify that we have matched the - // whole pattern and that T (above) is 'any'. + function getIteratedType(iterable: Type, errorNode: Node) { + Debug.assert(languageVersion >= ScriptTarget.ES6); + // We want to treat type as an iterable, and get the type it is an iterable of. The iterable + // must have the following structure (annotated with the names of the variables below): + // + // { // iterable + // [Symbol.iterator]: { // iteratorFunction + // (): { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // } + // } + // + // T is the type we are after. At every level that involves analyzing return types + // of signatures, we union the return types of all the signatures. + // + // Another thing to note is that at any step of this process, we could run into a dead end, + // meaning either the property is missing, or we run into the anyType. If either of these things + // happens, we return undefined to signal that we could not find the iterated type. If a property + // is missing, and the previous step did not result in 'any', then we also give an error if the + // caller requested it. Then the caller can decide what to do in the case where there is no iterated + // type. This is different from returning anyType, because that would signify that we have matched the + // whole pattern and that T (above) is 'any'. - if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { - return undefined; - } - - // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), - // then just grab its type argument. - if ((iterable.flags & TypeFlags.Reference) && (iterable).target === globalIterableType) { - return (iterable).typeArguments[0]; - } - - let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); - if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { - return undefined; - } - - let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - - let iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); - if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { - return undefined; - } - - let iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); - if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { - return undefined; - } - - let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - - let iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { - return undefined; - } - - let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - - return iteratorNextValue; + if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { + return undefined; } + + // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), + // then just grab its type argument. + if ((iterable.flags & TypeFlags.Reference) && (iterable).target === globalIterableType) { + return (iterable).typeArguments[0]; + } + + let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); + if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { + return undefined; + } + + let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + + let iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { + return undefined; + } + + let iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); + if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { + return undefined; + } + + let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + + let iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { + return undefined; + } + + let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + if (errorNode) { + error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + + return iteratorNextValue; } /** From a9e1d48c7d417668011de53e1b320fda38ac1371 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 24 Apr 2015 17:37:09 -0700 Subject: [PATCH 052/402] Simplify global generic type instantiation constructors --- src/compiler/checker.ts | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 10b81677e3a..e895e0f40d8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -99,19 +99,19 @@ module ts { let globals: SymbolTable = {}; - let globalArraySymbol: Symbol; let globalESSymbolConstructorSymbol: Symbol; let globalObjectType: ObjectType; let globalFunctionType: ObjectType; - let globalArrayType: ObjectType; + let globalArrayType: GenericType; let globalStringType: ObjectType; let globalNumberType: ObjectType; let globalBooleanType: ObjectType; let globalRegExpType: ObjectType; let globalTemplateStringsArrayType: ObjectType; let globalESSymbolType: ObjectType; - let globalIterableType: ObjectType; + let globalIterableType: GenericType; + let globalIterableIteratorType: GenericType; let anyArrayType: Type; let getGlobalClassDecoratorType: () => ObjectType; @@ -3468,16 +3468,20 @@ module ts { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + function createTypeFromGlobalGenericType(globalGenericType: GenericType, elementType: Type): Type { + return globalGenericType !== emptyObjectType ? createTypeReference(globalGenericType, [elementType]) : emptyObjectType; + } + function createIterableType(elementType: Type): Type { - return globalIterableType !== emptyObjectType ? createTypeReference(globalIterableType, [elementType]) : emptyObjectType; + return createTypeFromGlobalGenericType(globalIterableType, elementType); + } + + function createIterableIteratorType(elementType: Type): Type { + return createTypeFromGlobalGenericType(globalIterableIteratorType, elementType); } 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. - // We instead use globalArraySymbol to obtain the (not yet fully constructed) Array type. - let arrayType = globalArrayType || getDeclaredTypeOfSymbol(globalArraySymbol); - return arrayType !== emptyObjectType ? createTypeReference(arrayType, [elementType]) : emptyObjectType; + return createTypeFromGlobalGenericType(globalArrayType, elementType); } function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type { @@ -8142,6 +8146,16 @@ module ts { } } + function isSyntacticallyValidGenerator(node: SignatureDeclaration): boolean { + if (!(node).asteriskToken || !(node).body) { + return false; + } + + return node.kind === SyntaxKind.MethodDeclaration || + node.kind === SyntaxKind.FunctionDeclaration || + node.kind === SyntaxKind.FunctionExpression; + } + function checkSignatureDeclaration(node: SignatureDeclaration) { // Grammar checking if (node.kind === SyntaxKind.IndexSignature) { @@ -11967,8 +11981,7 @@ module ts { getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArraySymbol = getGlobalTypeSymbol("Array"); - globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, /*arity*/ 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -11986,7 +11999,8 @@ module ts { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; From 65222d6ef12819aaf0453b9d35b3861f621be3cd Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 24 Apr 2015 19:34:39 -0700 Subject: [PATCH 053/402] Check that generator return type is assignable from its IterableIterator type --- src/compiler/checker.ts | 81 ++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e895e0f40d8..b1b3f432ead 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -111,6 +111,7 @@ module ts { let globalTemplateStringsArrayType: ObjectType; let globalESSymbolType: ObjectType; let globalIterableType: GenericType; + let globalIteratorType: GenericType; let globalIterableIteratorType: GenericType; let anyArrayType: Type; @@ -2119,7 +2120,7 @@ module ts { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, - // or it may have led to an error inside getIteratedType. + // or it may have led to an error inside getElementTypeFromIterable. return checkRightHandSideOfForOf((declaration.parent.parent).expression) || anyType; } if (isBindingPattern(declaration.parent)) { @@ -5854,7 +5855,7 @@ module ts { let index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || (languageVersion >= ScriptTarget.ES6 ? getIteratedType(type, /*expressionForError*/ undefined) : undefined); + || (languageVersion >= ScriptTarget.ES6 ? getElementTypeFromIterable(type, /*expressionForError*/ undefined) : undefined); } return undefined; } @@ -6041,7 +6042,7 @@ module ts { // if there is no index type / iterated type. let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - (languageVersion >= ScriptTarget.ES6 ? getIteratedType(restArrayType, /*expressionForError*/ undefined) : undefined); + (languageVersion >= ScriptTarget.ES6 ? getElementTypeFromIterable(restArrayType, /*expressionForError*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); @@ -8188,6 +8189,22 @@ module ts { break; } } + + if (node.type) { + if (languageVersion >= ScriptTarget.ES6 && isSyntacticallyValidGenerator(node)) { + let returnType = getTypeFromTypeNode(node.type); + let generatorElementType = getElementTypeFromIterableIterator(returnType, /*errorNode*/ undefined) || anyType; + let iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + + // Naively, one could check that IterableIterator is assignable to the return type annotation. + // However, that would not catch the error in the following case. + // + // interface BadGenerator extends Iterable, Iterator { } + // function* g(): BadGenerator { } // Iterable and Iterator have different types! + // + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + } + } } checkSpecializedSignatureDeclaration(node); @@ -9385,7 +9402,7 @@ module ts { // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside - // getIteratedType. + // getElementTypeFromIterable. if (iteratedType) { checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } @@ -9483,30 +9500,24 @@ module ts { * When errorNode is undefined, it means we should not report any errors. */ function checkIteratedType(iterable: Type, errorNode: Node): Type { - let iteratedType = getIteratedType(iterable, errorNode); + let elementType = getElementTypeFromIterable(iterable, errorNode); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. - if (errorNode && iteratedType) { - checkTypeAssignableTo(iterable, createIterableType(iteratedType), errorNode); + if (errorNode && elementType) { + checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); } - return iteratedType; + return elementType; } - function getIteratedType(iterable: Type, errorNode: Node) { + function getElementTypeFromIterable(iterable: Type, errorNode: Node): Type { Debug.assert(languageVersion >= ScriptTarget.ES6); // We want to treat type as an iterable, and get the type it is an iterable of. The iterable // must have the following structure (annotated with the names of the variables below): // // { // iterable // [Symbol.iterator]: { // iteratorFunction - // (): { // iterator - // next: { // iteratorNextFunction - // (): { // iteratorNextResult - // value: T // iteratorNextValue - // } - // } - // } + // (): Iterator // } // } // @@ -9544,11 +9555,31 @@ module ts { return undefined; } - let iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); + return getElementTypeFromIterator(getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); + } + + function getElementTypeFromIterator(iterator: Type, errorNode: Node): Type { + // This function has very similar logic as getElementTypeFromIterable, except that it operates on + // Iterators instead of Iterables. Here is the structure: + // + // { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { return undefined; } + // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), + // then just grab its type argument. + if ((iterator.flags & TypeFlags.Reference) && (iterator).target === globalIteratorType) { + return (iterator).typeArguments[0]; + } + let iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { return undefined; @@ -9578,6 +9609,21 @@ module ts { return iteratorNextValue; } + function getElementTypeFromIterableIterator(iterableIterator: Type, errorNode: Node): Type { + if (allConstituentTypesHaveKind(iterableIterator, TypeFlags.Any)) { + return undefined; + } + + // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), + // then just grab its type argument. + if ((iterableIterator.flags & TypeFlags.Reference) && (iterableIterator).target === globalIterableIteratorType) { + return (iterableIterator).typeArguments[0]; + } + + return getElementTypeFromIterable(iterableIterator, errorNode) || + getElementTypeFromIterator(iterableIterator, errorNode); + } + /** * This function does the following steps: * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. @@ -12000,6 +12046,7 @@ module ts { globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { From eada0cd4a72d488353520fd1cd6a58565f595742 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 27 Apr 2015 13:08:50 -0700 Subject: [PATCH 054/402] Yield and yield* have type any --- src/compiler/checker.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b1b3f432ead..e28df84be20 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7899,11 +7899,14 @@ module ts { } } - function checkYieldExpression(node: YieldExpression): void { + function checkYieldExpression(node: YieldExpression): Type { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Yield)) { grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_declaration); } + + // Both yield and yield* expressions are any + return anyType; } function checkConditionalExpression(node: ConditionalExpression, contextualMapper?: TypeMapper): Type { @@ -8093,8 +8096,7 @@ module ts { case SyntaxKind.OmittedExpression: return undefinedType; case SyntaxKind.YieldExpression: - checkYieldExpression(node); - return unknownType; + return checkYieldExpression(node); } return unknownType; } From 21415af1b202c8fb103146102e71d1509e8205fd Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 27 Apr 2015 13:50:31 -0700 Subject: [PATCH 055/402] Rebaseline error codes --- .../reference/FunctionDeclaration10_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration11_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration13_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration1_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration6_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration7_es6.errors.txt | 8 ++++---- .../reference/FunctionDeclaration9_es6.errors.txt | 4 ++-- .../reference/FunctionExpression1_es6.errors.txt | 4 ++-- .../reference/FunctionExpression2_es6.errors.txt | 4 ++-- .../FunctionPropertyAssignments1_es6.errors.txt | 4 ++-- .../FunctionPropertyAssignments5_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration1_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration2_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration3_es6.errors.txt | 4 ++-- .../MemberFunctionDeclaration7_es6.errors.txt | 4 ++-- .../reference/YieldExpression10_es6.errors.txt | 4 ++-- .../reference/YieldExpression11_es6.errors.txt | 4 ++-- .../reference/YieldExpression13_es6.errors.txt | 4 ++-- .../reference/YieldExpression16_es6.errors.txt | 4 ++-- .../reference/YieldExpression19_es6.errors.txt | 8 ++++---- .../reference/YieldExpression3_es6.errors.txt | 4 ++-- .../reference/YieldExpression4_es6.errors.txt | 4 ++-- .../reference/YieldExpression6_es6.errors.txt | 4 ++-- .../reference/YieldExpression7_es6.errors.txt | 4 ++-- .../reference/YieldExpression8_es6.errors.txt | 4 ++-- .../reference/YieldExpression9_es6.errors.txt | 4 ++-- .../reference/YieldStarExpression4_es6.errors.txt | 4 ++-- .../reference/generatorInAmbientContext1.errors.txt | 4 ++-- .../reference/generatorInAmbientContext2.errors.txt | 4 ++-- .../generatorInAmbientContext3.d.errors.txt | 4 ++-- .../generatorInAmbientContext4.d.errors.txt | 4 ++-- .../reference/generatorOverloads1.errors.txt | 8 ++++---- .../reference/generatorOverloads2.errors.txt | 12 ++++++------ .../reference/generatorOverloads3.errors.txt | 8 ++++---- .../templateStringInYieldKeyword.errors.txt | 4 ++-- .../baselines/reference/yieldExpression1.errors.txt | 4 ++-- 36 files changed, 84 insertions(+), 84 deletions(-) diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 9b0c16e4573..c0a45a2be52 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== function * foo(a = yield => yield) { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt index 9b94fcf65bc..2c674a63f93 100644 --- a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ==== function * yield() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt index d2c056a19fb..aeb9e1fa6a6 100644 --- a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ==== function * foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. // Legal to use 'yield' in a type context. var v: yield; ~~~~~ diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt index 40eda833ba4..e3601968a27 100644 --- a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ==== function * foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 9e660161c29..27981b028ed 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== function*foo(a = yield) { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 945c0b07523..45e88ed7efb 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== function*bar() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. // 'yield' here is an identifier, and not a yield expression. function*foo(a = yield) { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt index 6f71558bb3c..b17b945e2f4 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== function * foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. var v = { [yield]: foo } } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression1_es6.errors.txt b/tests/baselines/reference/FunctionExpression1_es6.errors.txt index 8b76843a0c4..0bc04c80860 100644 --- a/tests/baselines/reference/FunctionExpression1_es6.errors.txt +++ b/tests/baselines/reference/FunctionExpression1_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ==== var v = function * () { } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression2_es6.errors.txt b/tests/baselines/reference/FunctionExpression2_es6.errors.txt index b39b79a6828..e58fe7ab4c7 100644 --- a/tests/baselines/reference/FunctionExpression2_es6.errors.txt +++ b/tests/baselines/reference/FunctionExpression2_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ==== var v = function * foo() { } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt index 24ff737ba6d..ebbc2a4dbe1 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ==== var v = { *foo() { } } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index 989d7d4ab8a..b2b071ee5e6 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ==== var v = { *[foo()]() { } } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ~~~ !!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt index cc4c163878d..0da724d7ec3 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ==== class C { *foo() { } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt index 99f48469d9d..8801b74cae5 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ==== class C { public * foo() { } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index b201b3142f4..458a3da62bb 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'. @@ -6,7 +6,7 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration class C { *[foo]() { } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ~~~ !!! error TS2304: Cannot find name 'foo'. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt index 63f2e2be6c2..210485e629f 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ==== class C { *foo() { } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression10_es6.errors.txt b/tests/baselines/reference/YieldExpression10_es6.errors.txt index 504dbdf9341..012cc92f4f2 100644 --- a/tests/baselines/reference/YieldExpression10_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression10_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (1 errors) ==== var v = { * foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); } } diff --git a/tests/baselines/reference/YieldExpression11_es6.errors.txt b/tests/baselines/reference/YieldExpression11_es6.errors.txt index df070d2bd7f..810928bf913 100644 --- a/tests/baselines/reference/YieldExpression11_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression11_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (1 errors) ==== class C { *foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression13_es6.errors.txt b/tests/baselines/reference/YieldExpression13_es6.errors.txt index 9a5abc60a41..57329bb142d 100644 --- a/tests/baselines/reference/YieldExpression13_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression13_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ==== function* foo() { yield } ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index e14f93f5291..ab085ed3cc4 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator declaration. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ==== function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. function bar() { yield foo; ~~~~~ diff --git a/tests/baselines/reference/YieldExpression19_es6.errors.txt b/tests/baselines/reference/YieldExpression19_es6.errors.txt index ecb2809b8af..7d7db15ebb6 100644 --- a/tests/baselines/reference/YieldExpression19_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression19_es6.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (2 errors) ==== function*foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. function bar() { function* quux() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); } } diff --git a/tests/baselines/reference/YieldExpression3_es6.errors.txt b/tests/baselines/reference/YieldExpression3_es6.errors.txt index 653f24d6c12..01bd5a54d59 100644 --- a/tests/baselines/reference/YieldExpression3_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression3_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield yield } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression4_es6.errors.txt b/tests/baselines/reference/YieldExpression4_es6.errors.txt index 73411e94207..dbb543ba86e 100644 --- a/tests/baselines/reference/YieldExpression4_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression4_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield; yield; } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression6_es6.errors.txt b/tests/baselines/reference/YieldExpression6_es6.errors.txt index 494d1b447bd..877c6aeb0ee 100644 --- a/tests/baselines/reference/YieldExpression6_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression6_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield*foo } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression7_es6.errors.txt b/tests/baselines/reference/YieldExpression7_es6.errors.txt index f26cc84be0a..067d11ecde6 100644 --- a/tests/baselines/reference/YieldExpression7_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression7_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield foo } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression8_es6.errors.txt b/tests/baselines/reference/YieldExpression8_es6.errors.txt index ba9e621fd70..32ee997e38a 100644 --- a/tests/baselines/reference/YieldExpression8_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression8_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (2 errors) ==== @@ -8,6 +8,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error !!! error TS2304: Cannot find name 'yield'. function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression9_es6.errors.txt b/tests/baselines/reference/YieldExpression9_es6.errors.txt index c3a60cc8667..a7e53670d0d 100644 --- a/tests/baselines/reference/YieldExpression9_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression9_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (1 errors) ==== var v = function*() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); } \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt index ab1ddae6989..15b9c863e62 100644 --- a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt +++ b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (1 errors) ==== function *g() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield * []; } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext1.errors.txt b/tests/baselines/reference/generatorInAmbientContext1.errors.txt index 827257da6f7..fcfcceb9ff5 100644 --- a/tests/baselines/reference/generatorInAmbientContext1.errors.txt +++ b/tests/baselines/reference/generatorInAmbientContext1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts(2,5): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts(2,5): error TS1220: Generators are not allowed in an ambient context. ==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext1.ts (1 errors) ==== declare class C { *generator(): any; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext2.errors.txt b/tests/baselines/reference/generatorInAmbientContext2.errors.txt index 0d2439dbe35..8f471ef98bc 100644 --- a/tests/baselines/reference/generatorInAmbientContext2.errors.txt +++ b/tests/baselines/reference/generatorInAmbientContext2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts(2,14): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts(2,14): error TS1220: Generators are not allowed in an ambient context. ==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext2.ts (1 errors) ==== declare module M { function *generator(): any; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt b/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt index e7cab556be4..44391cab730 100644 --- a/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt +++ b/tests/baselines/reference/generatorInAmbientContext3.d.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts(2,5): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts(2,5): error TS1220: Generators are not allowed in an ambient context. ==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext3.d.ts (1 errors) ==== declare class C { *generator(): any; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt b/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt index e47cbd2b7e9..2b1701156f0 100644 --- a/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt +++ b/tests/baselines/reference/generatorInAmbientContext4.d.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts(2,14): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts(2,14): error TS1220: Generators are not allowed in an ambient context. ==== tests/cases/conformance/es6/yieldExpressions/generatorInAmbientContext4.d.ts (1 errors) ==== declare module M { function *generator(): any; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorOverloads1.errors.txt b/tests/baselines/reference/generatorOverloads1.errors.txt index 2dea232ae1c..9d2b5a2ee41 100644 --- a/tests/baselines/reference/generatorOverloads1.errors.txt +++ b/tests/baselines/reference/generatorOverloads1.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts(2,13): error TS1220: An overload signature cannot be declared as a generator. -tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts(3,13): error TS1220: An overload signature cannot be declared as a generator. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts(2,13): error TS1221: An overload signature cannot be declared as a generator. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts(3,13): error TS1221: An overload signature cannot be declared as a generator. ==== tests/cases/conformance/es6/yieldExpressions/generatorOverloads1.ts (2 errors) ==== module M { function* f(s: string): Iterable; ~ -!!! error TS1220: An overload signature cannot be declared as a generator. +!!! error TS1221: An overload signature cannot be declared as a generator. function* f(s: number): Iterable; ~ -!!! error TS1220: An overload signature cannot be declared as a generator. +!!! error TS1221: An overload signature cannot be declared as a generator. function* f(s: any): Iterable { } } \ No newline at end of file diff --git a/tests/baselines/reference/generatorOverloads2.errors.txt b/tests/baselines/reference/generatorOverloads2.errors.txt index d17860abf3f..53dad48de63 100644 --- a/tests/baselines/reference/generatorOverloads2.errors.txt +++ b/tests/baselines/reference/generatorOverloads2.errors.txt @@ -1,17 +1,17 @@ -tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(2,13): error TS1219: Generators are not allowed in an ambient context. -tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(3,13): error TS1219: Generators are not allowed in an ambient context. -tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(4,13): error TS1219: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(2,13): error TS1220: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(3,13): error TS1220: Generators are not allowed in an ambient context. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts(4,13): error TS1220: Generators are not allowed in an ambient context. ==== tests/cases/conformance/es6/yieldExpressions/generatorOverloads2.ts (3 errors) ==== declare module M { function* f(s: string): Iterable; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. function* f(s: number): Iterable; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. function* f(s: any): Iterable; ~ -!!! error TS1219: Generators are not allowed in an ambient context. +!!! error TS1220: Generators are not allowed in an ambient context. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorOverloads3.errors.txt b/tests/baselines/reference/generatorOverloads3.errors.txt index 6f2a5dfa619..c68e2fac0b0 100644 --- a/tests/baselines/reference/generatorOverloads3.errors.txt +++ b/tests/baselines/reference/generatorOverloads3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts(2,5): error TS1220: An overload signature cannot be declared as a generator. -tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts(3,5): error TS1220: An overload signature cannot be declared as a generator. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts(2,5): error TS1221: An overload signature cannot be declared as a generator. +tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts(3,5): error TS1221: An overload signature cannot be declared as a generator. ==== tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts (2 errors) ==== class C { *f(s: string): Iterable; ~ -!!! error TS1220: An overload signature cannot be declared as a generator. +!!! error TS1221: An overload signature cannot be declared as a generator. *f(s: number): Iterable; ~ -!!! error TS1220: An overload signature cannot be declared as a generator. +!!! error TS1221: An overload signature cannot be declared as a generator. *f(s: any): Iterable { } } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt index fe9937f2a96..e6eef0a1840 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (1 errors) ==== function* gen() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. // Once this is supported, the inner expression does not need to be parenthesized. var x = yield `abc${ x }def`; } diff --git a/tests/baselines/reference/yieldExpression1.errors.txt b/tests/baselines/reference/yieldExpression1.errors.txt index e0c143d39de..22bd6387b3f 100644 --- a/tests/baselines/reference/yieldExpression1.errors.txt +++ b/tests/baselines/reference/yieldExpression1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/yieldExpression1.ts(1,9): error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/compiler/yieldExpression1.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher. ==== tests/cases/compiler/yieldExpression1.ts (1 errors) ==== function* foo() { ~ -!!! error TS1218: Generators are only available when targeting ECMAScript 6 or higher. +!!! error TS1219: Generators are only available when targeting ECMAScript 6 or higher. yield } \ No newline at end of file From 623507c0f286c46bb88ffc762b636b2144e04fb4 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 27 Apr 2015 15:43:56 -0700 Subject: [PATCH 056/402] Disallow return expressions in a generator --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e28df84be20..53949a65896 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9720,6 +9720,9 @@ module ts { if (func.kind === SyntaxKind.SetAccessor) { error(node.expression, Diagnostics.Setters_cannot_return_a_value); } + else if (func.asteriskToken) { + error(node.expression, Diagnostics.A_return_statement_cannot_specify_a_value_in_a_generator_function); + } else { if (func.kind === SyntaxKind.Constructor) { if (!isTypeAssignableTo(exprType, returnType)) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 1faadd4efcc..aab55767e8b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -366,6 +366,7 @@ module ts { An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + A_return_statement_cannot_specify_a_value_in_a_generator_function: { code: 2502, category: DiagnosticCategory.Error, key: "A return statement cannot specify a value in a generator function." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c781323b497..a1c224df925 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1453,6 +1453,10 @@ "category": "Error", "code": 2501 }, + "A return statement cannot specify a value in a generator function.": { + "category": "Error", + "code": 2502 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From 95bfd7c376b66b17a8314bc522f437fac188f2f6 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 27 Apr 2015 17:01:10 -0700 Subject: [PATCH 057/402] Assignability checking for yield and yield* expressions --- src/compiler/checker.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 53949a65896..9b569eb1d6f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7905,6 +7905,26 @@ module ts { grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_declaration); } + if (node.expression) { + let func = getContainingFunction(node); + // If this is correct code, the func should always have a star. After all, + // we are in a yield context. + // Also, there is no point in doing an assignability check if the function + // has no explicit return type, because the return type is directly computed + // from the yield expressions. + if (func.asteriskToken && func.type) { + let signatureElementType = getElementTypeFromIterableIterator(getTypeFromTypeNode(func.type), /*errorNode*/ undefined) || unknownType; + let expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); + if (node.asteriskToken) { + let expressionElementType = checkIteratedType(expressionType, node.expression); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + } + else { + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + } + } + } + // Both yield and yield* expressions are any return anyType; } @@ -9480,7 +9500,7 @@ module ts { } if (languageVersion >= ScriptTarget.ES6) { - return checkIteratedType(inputType, errorNode) || anyType; + return checkIteratedType(inputType, errorNode); } if (allowStringInput) { @@ -9509,7 +9529,7 @@ module ts { checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); } - return elementType; + return elementType || anyType; } function getElementTypeFromIterable(iterable: Type, errorNode: Node): Type { From 44777b9737ade5f6b7215bacb3f1c6ac8a6309fc Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 27 Apr 2015 19:27:20 -0700 Subject: [PATCH 058/402] Contextual typing for yield expressions --- src/compiler/checker.ts | 46 ++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9b569eb1d6f..889104aa6dd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5704,20 +5704,41 @@ module ts { } function getContextualTypeForReturnExpression(node: Expression): Type { + let func = getContainingFunction(node); + if (func && !func.asteriskToken) { + return getContextualReturnType(func); + } + + return undefined; + } + + function getContextualTypeForYieldOperand(node: YieldExpression): Type { let func = getContainingFunction(node); if (func) { - // If the containing function has a return type annotation, is a constructor, or is a get accessor whose - // corresponding set accessor has a type annotation, return statements in the function are contextually typed - if (func.type || func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, SyntaxKind.SetAccessor))) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - } - // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature - // and that call signature is non-generic, return statements are contextually typed by the return type of the signature - let signature = getContextualSignatureForFunctionLikeDeclaration(func); - if (signature) { - return getReturnTypeOfSignature(signature); + let contextualReturnType = getContextualReturnType(func); + if (contextualReturnType) { + return node.asteriskToken + ? contextualReturnType + : getElementTypeFromIterableIterator(contextualReturnType, /*errorNode*/ undefined); } } + + return undefined; + } + + function getContextualReturnType(functionDecl: FunctionLikeDeclaration): Type { + // If the containing function has a return type annotation, is a constructor, or is a get accessor whose + // corresponding set accessor has a type annotation, return statements in the function are contextually typed + if (functionDecl.type || functionDecl.kind === SyntaxKind.Constructor || functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); + } + // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature + // and that call signature is non-generic, return statements are contextually typed by the return type of the signature + let signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + if (signature) { + return getReturnTypeOfSignature(signature); + } + return undefined; } @@ -5887,6 +5908,8 @@ module ts { case SyntaxKind.ArrowFunction: case SyntaxKind.ReturnStatement: return getContextualTypeForReturnExpression(node); + case SyntaxKind.YieldExpression: + return getContextualTypeForYieldOperand(parent); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return getContextualTypeForArgument(parent, node); @@ -7912,7 +7935,7 @@ module ts { // Also, there is no point in doing an assignability check if the function // has no explicit return type, because the return type is directly computed // from the yield expressions. - if (func.asteriskToken && func.type) { + if (func && func.asteriskToken && func.type) { let signatureElementType = getElementTypeFromIterableIterator(getTypeFromTypeNode(func.type), /*errorNode*/ undefined) || unknownType; let expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); if (node.asteriskToken) { @@ -9533,7 +9556,6 @@ module ts { } function getElementTypeFromIterable(iterable: Type, errorNode: Node): Type { - Debug.assert(languageVersion >= ScriptTarget.ES6); // We want to treat type as an iterable, and get the type it is an iterable of. The iterable // must have the following structure (annotated with the names of the variables below): // From 7fce7751494715b715060cc4d95761f67246795a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 28 Apr 2015 17:48:32 -0700 Subject: [PATCH 059/402] Infer return types from yield and yield* expressions --- src/compiler/checker.ts | 139 ++++++------------ .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 + src/compiler/utilities.ts | 134 +++++++++++++++++ 4 files changed, 185 insertions(+), 93 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 889104aa6dd..838bfb92185 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7260,16 +7260,35 @@ module ts { } else { // Aggregate the types of expressions within all the return statements. - let types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); - if (types.length === 0) { - return voidType; + let types: Type[]; + if (func.asteriskToken) { + types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); + if (types.length === 0) { + return createIterableIteratorType(anyType); + } + } + else { + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + if (types.length === 0) { + return voidType; + } } // When return statements are contextually typed we allow the return type to be a union type. Otherwise we require the // return expressions to have a best common supertype. type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); if (!type) { - error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + if (func.asteriskToken) { + error(func, Diagnostics.No_best_common_type_exists_among_yield_expressions); + return createIterableIteratorType(unknownType); + } + else { + error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); + return unknownType; + } + } + + if (func.asteriskToken) { + type = createIterableIteratorType(type); } } if (!contextualSignature) { @@ -7278,7 +7297,28 @@ module ts { return getWidenedType(type); } - /// Returns a set of types relating to every return expression relating to a function block. + function checkAndAggregateYieldOperandTypes(body: Block, contextualMapper?: TypeMapper): Type[] { + let aggregatedTypes: Type[] = []; + + forEachYieldExpression(body, yieldExpression => { + let expr = yieldExpression.expression; + if (expr) { + let type = checkExpressionCached(expr, contextualMapper); + + if (yieldExpression.asteriskToken) { + // A yield* expression effectively yields everything that its operand yields + type = checkIteratedType(type, yieldExpression.expression); + } + + if (!contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + + return aggregatedTypes; + } + function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper): Type[] { let aggregatedTypes: Type[] = []; @@ -11253,93 +11293,6 @@ module ts { return node.parent && node.parent.kind === SyntaxKind.ExpressionWithTypeArguments; } - function isTypeNode(node: Node): boolean { - if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { - return true; - } - - switch (node.kind) { - case SyntaxKind.AnyKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.SymbolKeyword: - return true; - case SyntaxKind.VoidKeyword: - return node.parent.kind !== SyntaxKind.VoidExpression; - case SyntaxKind.StringLiteral: - // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === SyntaxKind.Parameter; - case SyntaxKind.ExpressionWithTypeArguments: - return true; - - // Identifiers and qualified names may be type nodes, depending on their context. Climb - // above them to find the lowest container - case SyntaxKind.Identifier: - // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) { - node = node.parent; - } - else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node) { - node = node.parent; - } - // fall through - case SyntaxKind.QualifiedName: - case SyntaxKind.PropertyAccessExpression: - // At this point, node is either a qualified name or an identifier - Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression, - "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - - let parent = node.parent; - if (parent.kind === SyntaxKind.TypeQuery) { - return false; - } - // Do not recursively call isTypeNode on the parent. In the example: - // - // let a: A.B.C; - // - // Calling isTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. - if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) { - return true; - } - switch (parent.kind) { - case SyntaxKind.ExpressionWithTypeArguments: - return true; - case SyntaxKind.TypeParameter: - return node === (parent).constraint; - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.Parameter: - case SyntaxKind.VariableDeclaration: - return node === (parent).type; - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.Constructor: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - return node === (parent).type; - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - return node === (parent).type; - case SyntaxKind.TypeAssertionExpression: - return node === (parent).type; - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - return (parent).typeArguments && indexOf((parent).typeArguments, node) >= 0; - case SyntaxKind.TaggedTemplateExpression: - // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. - return false; - } - } - - return false; - } - function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide: EntityName): ImportEqualsDeclaration | ExportAssignment { while (nodeOnRightSide.parent.kind === SyntaxKind.QualifiedName) { nodeOnRightSide = nodeOnRightSide.parent; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index aab55767e8b..9c059aa248e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -367,6 +367,7 @@ module ts { A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, A_return_statement_cannot_specify_a_value_in_a_generator_function: { code: 2502, category: DiagnosticCategory.Error, key: "A return statement cannot specify a value in a generator function." }, + No_best_common_type_exists_among_yield_expressions: { code: 2503, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a1c224df925..1a4d157b927 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1457,6 +1457,10 @@ "category": "Error", "code": 2502 }, + "No best common type exists among yield expressions.": { + "category": "Error", + "code": 2503 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3e825c6802c..d0754bccd68 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -408,6 +408,93 @@ module ts { export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/ + export function isTypeNode(node: Node): boolean { + if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { + return true; + } + + switch (node.kind) { + case SyntaxKind.AnyKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.SymbolKeyword: + return true; + case SyntaxKind.VoidKeyword: + return node.parent.kind !== SyntaxKind.VoidExpression; + case SyntaxKind.StringLiteral: + // Specialized signatures can have string literals as their parameters' type names + return node.parent.kind === SyntaxKind.Parameter; + case SyntaxKind.ExpressionWithTypeArguments: + return true; + + // Identifiers and qualified names may be type nodes, depending on their context. Climb + // above them to find the lowest container + case SyntaxKind.Identifier: + // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. + if (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) { + node = node.parent; + } + else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node) { + node = node.parent; + } + // fall through + case SyntaxKind.QualifiedName: + case SyntaxKind.PropertyAccessExpression: + // At this point, node is either a qualified name or an identifier + Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression, + "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + + let parent = node.parent; + if (parent.kind === SyntaxKind.TypeQuery) { + return false; + } + // Do not recursively call isTypeNode on the parent. In the example: + // + // let a: A.B.C; + // + // Calling isTypeNode would consider the qualified name A.B a type node. Only C or + // A.B.C is a type node. + if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) { + return true; + } + switch (parent.kind) { + case SyntaxKind.ExpressionWithTypeArguments: + return true; + case SyntaxKind.TypeParameter: + return node === (parent).constraint; + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.Parameter: + case SyntaxKind.VariableDeclaration: + return node === (parent).type; + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return node === (parent).type; + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + return node === (parent).type; + case SyntaxKind.TypeAssertionExpression: + return node === (parent).type; + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + return (parent).typeArguments && indexOf((parent).typeArguments, node) >= 0; + case SyntaxKind.TaggedTemplateExpression: + // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. + return false; + } + } + + return false; + } + // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. export function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T { @@ -438,6 +525,52 @@ module ts { } } + export function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void { + + return traverse(body); + + function traverse(node: Node): void { + // Yield expressions may occur in decorators + if (node.decorators) { + forEach(node.decorators, traverse); + } + + switch (node.kind) { + case SyntaxKind.YieldExpression: + visitor(node); + let operand = (node).expression; + if (operand) { + traverse(operand); + } + case SyntaxKind.EnumDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.TypeAliasDeclaration: + // These are not allowed inside a generator now, but eventually they may be allowed + // as local types. Regardless, any yield statements contained within them should be + // skipped in this traversal. + return; + case SyntaxKind.ClassDeclaration: + // A class declaration/expression may extend a yield expression + forEach((node).heritageClauses, traverse); + return; + default: + if (isFunctionLike(node)) { + let name = (node).name; + if (name && name.kind === SyntaxKind.ComputedPropertyName) { + traverse((name).expression); + return; + } + } + else if (!isTypeNode(node)) { + // This is the general case, which should include mostly expressions and statements. + // Also includes NodeArrays. + forEachChild(node, traverse); + } + } + } + } + export function isVariableLike(node: Node): boolean { if (node) { switch (node.kind) { @@ -736,6 +869,7 @@ module ts { case SyntaxKind.TemplateExpression: case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.OmittedExpression: + case SyntaxKind.YieldExpression: return true; case SyntaxKind.QualifiedName: while (node.parent.kind === SyntaxKind.QualifiedName) { From 48a91b0084fa85d25c483c42562b8e45545761df Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 29 Apr 2015 12:36:00 -0700 Subject: [PATCH 060/402] Fix some crashes in the checker --- src/compiler/checker.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 838bfb92185..95c187b7bc0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -91,6 +91,9 @@ module ts { let resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__"); let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + let emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + emptyGenericType.instantiations = {}; + let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -3435,16 +3438,16 @@ module ts { } if (!symbol) { - return emptyObjectType; + return arity ? emptyGenericType : emptyObjectType; } let type = getDeclaredTypeOfSymbol(symbol); if (!(type.flags & TypeFlags.ObjectType)) { error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); - return emptyObjectType; + return arity ? emptyGenericType : emptyObjectType; } if (((type).typeParameters ? (type).typeParameters.length : 0) !== arity) { error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); - return emptyObjectType; + return arity ? emptyGenericType : emptyObjectType; } return type; } @@ -3470,7 +3473,7 @@ module ts { } function createTypeFromGlobalGenericType(globalGenericType: GenericType, elementType: Type): Type { - return globalGenericType !== emptyObjectType ? createTypeReference(globalGenericType, [elementType]) : emptyObjectType; + return globalGenericType !== emptyGenericType ? createTypeReference(globalGenericType, [elementType]) : emptyObjectType; } function createIterableType(elementType: Type): Type { @@ -12057,6 +12060,9 @@ module ts { // a global Symbol already, particularly if it is a class. globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); globalESSymbolConstructorSymbol = undefined; + globalIterableType = emptyGenericType; + globalIteratorType = emptyGenericType; + globalIterableIteratorType = emptyGenericType; } anyArrayType = createArrayType(anyType); From d163f8326df21add6fc19d887869d7300ef3192a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 29 Apr 2015 19:06:03 -0700 Subject: [PATCH 061/402] Accept baselines --- tests/baselines/reference/generatorES6_1.types | 3 ++- tests/baselines/reference/generatorES6_2.types | 4 +++- tests/baselines/reference/generatorES6_3.types | 6 ++++-- tests/baselines/reference/generatorES6_4.types | 8 +++++--- tests/baselines/reference/generatorES6_5.types | 3 ++- tests/baselines/reference/generatorES6_6.types | 2 ++ .../templateStringWithEmbeddedYieldKeywordES6.types | 4 +++- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/baselines/reference/generatorES6_1.types b/tests/baselines/reference/generatorES6_1.types index faf16398303..13ac7c05844 100644 --- a/tests/baselines/reference/generatorES6_1.types +++ b/tests/baselines/reference/generatorES6_1.types @@ -1,6 +1,7 @@ === tests/cases/compiler/generatorES6_1.ts === function* foo() { ->foo : () => void +>foo : () => IterableIterator yield +>yield : any } diff --git a/tests/baselines/reference/generatorES6_2.types b/tests/baselines/reference/generatorES6_2.types index 2948424b120..9c9c8692757 100644 --- a/tests/baselines/reference/generatorES6_2.types +++ b/tests/baselines/reference/generatorES6_2.types @@ -3,8 +3,10 @@ class C { >C : C public * foo() { ->foo : () => void +>foo : () => IterableIterator yield 1 +>yield 1 : any +>1 : number } } diff --git a/tests/baselines/reference/generatorES6_3.types b/tests/baselines/reference/generatorES6_3.types index e627fff9efd..e87ad23ba77 100644 --- a/tests/baselines/reference/generatorES6_3.types +++ b/tests/baselines/reference/generatorES6_3.types @@ -1,7 +1,9 @@ === tests/cases/compiler/generatorES6_3.ts === var v = function*() { ->v : () => void ->function*() { yield 0} : () => void +>v : () => IterableIterator +>function*() { yield 0} : () => IterableIterator yield 0 +>yield 0 : any +>0 : number } diff --git a/tests/baselines/reference/generatorES6_4.types b/tests/baselines/reference/generatorES6_4.types index 5b34aff9f6e..64b0924919b 100644 --- a/tests/baselines/reference/generatorES6_4.types +++ b/tests/baselines/reference/generatorES6_4.types @@ -1,11 +1,13 @@ === tests/cases/compiler/generatorES6_4.ts === var v = { ->v : { foo(): void; } ->{ *foo() { yield 0 }} : { foo(): void; } +>v : { foo(): IterableIterator; } +>{ *foo() { yield 0 }} : { foo(): IterableIterator; } *foo() { ->foo : () => void +>foo : () => IterableIterator yield 0 +>yield 0 : any +>0 : number } } diff --git a/tests/baselines/reference/generatorES6_5.types b/tests/baselines/reference/generatorES6_5.types index 9e500c7f4b6..12396f69e24 100644 --- a/tests/baselines/reference/generatorES6_5.types +++ b/tests/baselines/reference/generatorES6_5.types @@ -1,8 +1,9 @@ === tests/cases/compiler/generatorES6_5.ts === function* foo() { ->foo : () => void +>foo : () => IterableIterator yield a ? b : c; +>yield a ? b : c : any >a ? b : c : any >a : any >b : any diff --git a/tests/baselines/reference/generatorES6_6.types b/tests/baselines/reference/generatorES6_6.types index 731c9b47f55..4e3de8cea1e 100644 --- a/tests/baselines/reference/generatorES6_6.types +++ b/tests/baselines/reference/generatorES6_6.types @@ -9,5 +9,7 @@ class C { let a = yield 1; >a : any +>yield 1 : any +>1 : number } } diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types index 9772a732868..3a6f5d16726 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -1,10 +1,12 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === function* gen() { ->gen : () => void +>gen : () => IterableIterator // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; >x : string >`abc${ yield 10 }def` : string +>yield 10 : any +>10 : number } From a9055b872908ef4e0e0adf2ca46d373f87a1593b Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 30 Apr 2015 15:27:58 -0700 Subject: [PATCH 062/402] Fix contextual typing of object literal methods --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 95c187b7bc0..be9047326ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5952,8 +5952,10 @@ module ts { } function getContextualSignatureForFunctionLikeDeclaration(node: FunctionLikeDeclaration): Signature { - // Only function expressions and arrow functions are contextually typed. - return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + // Only function expressions, arrow functions, and object literal methods are contextually typed. + return isFunctionExpressionOrArrowFunction(node) || isObjectLiteralMethod(node) + ? getContextualSignature(node) + : undefined; } // Return the contextual signature for a given expression node. A contextual type provides a From ba1ed04ee207aec6250e7b41b094372f13a71815 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 30 Apr 2015 15:29:53 -0700 Subject: [PATCH 063/402] Improve error for void generator --- src/compiler/checker.ts | 23 +++++++++++-------- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index be9047326ca..4e4a6eab823 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8283,16 +8283,21 @@ module ts { if (node.type) { if (languageVersion >= ScriptTarget.ES6 && isSyntacticallyValidGenerator(node)) { let returnType = getTypeFromTypeNode(node.type); - let generatorElementType = getElementTypeFromIterableIterator(returnType, /*errorNode*/ undefined) || anyType; - let iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + if (returnType === voidType) { + error(node.type, Diagnostics.A_generator_cannot_have_a_void_type_annotation); + } + else { + let generatorElementType = getElementTypeFromIterableIterator(returnType, /*errorNode*/ undefined) || anyType; + let iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); - // Naively, one could check that IterableIterator is assignable to the return type annotation. - // However, that would not catch the error in the following case. - // - // interface BadGenerator extends Iterable, Iterator { } - // function* g(): BadGenerator { } // Iterable and Iterator have different types! - // - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + // Naively, one could check that IterableIterator is assignable to the return type annotation. + // However, that would not catch the error in the following case. + // + // interface BadGenerator extends Iterable, Iterator { } + // function* g(): BadGenerator { } // Iterable and Iterator have different types! + // + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + } } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9c059aa248e..05a963bd693 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -368,6 +368,7 @@ module ts { A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, A_return_statement_cannot_specify_a_value_in_a_generator_function: { code: 2502, category: DiagnosticCategory.Error, key: "A return statement cannot specify a value in a generator function." }, No_best_common_type_exists_among_yield_expressions: { code: 2503, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, + A_generator_cannot_have_a_void_type_annotation: { code: 2504, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 1a4d157b927..55391764067 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1461,6 +1461,10 @@ "category": "Error", "code": 2503 }, + "A generator cannot have a 'void' type annotation.": { + "category": "Error", + "code": 2504 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From 9f019526a8c33101f11745b45625896f37c75b5b Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 30 Apr 2015 19:05:57 -0700 Subject: [PATCH 064/402] Add implicit any error for generator with no type annotation and no yield operands --- src/compiler/checker.ts | 19 ++++++++++++++++--- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4e4a6eab823..b733457923b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7269,7 +7269,12 @@ module ts { if (func.asteriskToken) { types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); if (types.length === 0) { - return createIterableIteratorType(anyType); + let iterableIteratorAny = createIterableIteratorType(anyType); + if (compilerOptions.noImplicitAny) { + error(func.asteriskToken, + Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); + } + return iterableIteratorAny; } } else { @@ -9074,8 +9079,16 @@ module ts { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method // in an ambient context - if (compilerOptions.noImplicitAny && nodeIsMissing(node.body) && !node.type && !isPrivateWithinAmbient(node)) { - reportImplicitAnyError(node, anyType); + if (produceDiagnostics && compilerOptions.noImplicitAny && !node.type && !isPrivateWithinAmbient(node)) { + if (nodeIsMissing(node.body)) { + reportImplicitAnyError(node, anyType); + } + else if (node.asteriskToken) { + // A generator with a body and no type annotation can still cause an implicit any if it is has + // no yield expressions, or its yield expressions do not have operands. The only way to find out + // is to try checking its return type. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 05a963bd693..2332e520ba2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -527,6 +527,7 @@ module ts { _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 55391764067..3ce59b552b1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2101,6 +2101,10 @@ "category": "Error", "code": 7024 }, + "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type.": { + "category": "Error", + "code": 7025 + }, "You cannot rename this element.": { "category": "Error", "code": 8000 From 37f5e411db8a399175ef50efaa696f03d92b21be Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 30 Apr 2015 19:32:23 -0700 Subject: [PATCH 065/402] Remove error for having return expressions in a generator --- src/compiler/checker.ts | 26 +++++++++++-------- .../diagnosticInformationMap.generated.ts | 5 ++-- src/compiler/diagnosticMessages.json | 8 ++---- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b733457923b..3c637b03f19 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9822,21 +9822,25 @@ module ts { if (func) { let returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); let exprType = checkExpressionCached(node.expression); + + if (func.asteriskToken) { + // A generator does not need its return expressions checked against its return type. + // Instead, the yield expressions are checked against the element type. + // TODO: Check return expressions of generators when return type tracking is added + // for generators. + return; + } + if (func.kind === SyntaxKind.SetAccessor) { error(node.expression, Diagnostics.Setters_cannot_return_a_value); } - else if (func.asteriskToken) { - error(node.expression, Diagnostics.A_return_statement_cannot_specify_a_value_in_a_generator_function); + else if (func.kind === SyntaxKind.Constructor) { + if (!isTypeAssignableTo(exprType, returnType)) { + error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + } } - else { - if (func.kind === SyntaxKind.Constructor) { - if (!isTypeAssignableTo(exprType, returnType)) { - error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); - } - } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { - checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); - } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 2332e520ba2..1776f185a9b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -366,9 +366,8 @@ module ts { An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, - A_return_statement_cannot_specify_a_value_in_a_generator_function: { code: 2502, category: DiagnosticCategory.Error, key: "A return statement cannot specify a value in a generator function." }, - No_best_common_type_exists_among_yield_expressions: { code: 2503, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, - A_generator_cannot_have_a_void_type_annotation: { code: 2504, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + No_best_common_type_exists_among_yield_expressions: { code: 2502, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, + A_generator_cannot_have_a_void_type_annotation: { code: 2503, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3ce59b552b1..7a1f8a3e728 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1453,17 +1453,13 @@ "category": "Error", "code": 2501 }, - "A return statement cannot specify a value in a generator function.": { + "No best common type exists among yield expressions.": { "category": "Error", "code": 2502 }, - "No best common type exists among yield expressions.": { - "category": "Error", - "code": 2503 - }, "A generator cannot have a 'void' type annotation.": { "category": "Error", - "code": 2504 + "code": 2503 }, "Import declaration '{0}' is using private name '{1}'.": { From 9133ab62ee2297776bcef818203448b2ee30ec82 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 4 May 2015 14:18:03 -0700 Subject: [PATCH 066/402] Adjust symbol baselines after rebase --- tests/baselines/reference/generatorES6_6.symbols | 2 +- tests/baselines/reference/generatorOverloads4.symbols | 6 +++--- tests/baselines/reference/generatorOverloads5.symbols | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 85d557fb91f..4cdac0f12c5 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -4,7 +4,7 @@ class C { *[Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) let a = yield 1; diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index f21e88e4e6e..d604595a5e7 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index 6365a2f205c..9f28579b63f 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) } From fbce0a56de8d421d843857470a37ab10d146f86f Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 4 May 2015 14:27:33 -0700 Subject: [PATCH 067/402] Cache element types of iterable and iterator --- src/compiler/checker.ts | 108 ++++++++++++++++++++++------------------ src/compiler/types.ts | 7 +++ 2 files changed, 67 insertions(+), 48 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3c637b03f19..3a57bd9fdff 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7317,7 +7317,7 @@ module ts { if (yieldExpression.asteriskToken) { // A yield* expression effectively yields everything that its operand yields - type = checkIteratedType(type, yieldExpression.expression); + type = checkElementTypeOfIterable(type, yieldExpression.expression); } if (!contains(aggregatedTypes, type)) { @@ -7989,7 +7989,7 @@ module ts { let signatureElementType = getElementTypeFromIterableIterator(getTypeFromTypeNode(func.type), /*errorNode*/ undefined) || unknownType; let expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); if (node.asteriskToken) { - let expressionElementType = checkIteratedType(expressionType, node.expression); + let expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { @@ -9586,7 +9586,7 @@ module ts { } if (languageVersion >= ScriptTarget.ES6) { - return checkIteratedType(inputType, errorNode); + return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -9607,7 +9607,7 @@ module ts { /** * When errorNode is undefined, it means we should not report any errors. */ - function checkIteratedType(iterable: Type, errorNode: Node): Type { + function checkElementTypeOfIterable(iterable: Type, errorNode: Node): Type { let elementType = getElementTypeFromIterable(iterable, errorNode); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. @@ -9643,26 +9643,32 @@ module ts { return undefined; } - // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), - // then just grab its type argument. - if ((iterable.flags & TypeFlags.Reference) && (iterable).target === globalIterableType) { - return (iterable).typeArguments[0]; - } - - let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); - if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { - return undefined; - } - - let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + let typeAsIterable = iterable; + if (!typeAsIterable.iterableElementType) { + // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), + // then just grab its type argument. + if ((iterable.flags & TypeFlags.Reference) && (iterable).target === globalIterableType) { + typeAsIterable.iterableElementType = (iterable).typeArguments[0]; + } + else { + let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); + if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { + return undefined; + } + + let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + + typeAsIterable.iterableElementType = getElementTypeFromIterator(getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); } - return undefined; } - return getElementTypeFromIterator(getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); + return typeAsIterable.iterableElementType; } function getElementTypeFromIterator(iterator: Type, errorNode: Node): Type { @@ -9681,39 +9687,45 @@ module ts { return undefined; } - // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), - // then just grab its type argument. - if ((iterator.flags & TypeFlags.Reference) && (iterator).target === globalIteratorType) { - return (iterator).typeArguments[0]; - } - - let iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); - if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { - return undefined; - } - - let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, Diagnostics.An_iterator_must_have_a_next_method); + let typeAsIterator = iterator; + if (!typeAsIterator.iteratorElementType) { + // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), + // then just grab its type argument. + if ((iterator.flags & TypeFlags.Reference) && (iterator).target === globalIteratorType) { + typeAsIterator.iteratorElementType = (iterator).typeArguments[0]; } - return undefined; - } + else { + let iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); + if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { + return undefined; + } - let iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { - return undefined; - } + let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } - let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + let iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { + return undefined; + } + + let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + if (errorNode) { + error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + + typeAsIterator.iteratorElementType = iteratorNextValue; } - return undefined; } - return iteratorNextValue; + return typeAsIterator.iteratorElementType; } function getElementTypeFromIterableIterator(iterableIterator: Type, errorNode: Node): Type { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a11d97c45fb..2554bd45b4c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1543,6 +1543,13 @@ module ts { numberIndexType: Type; // Numeric index type } + /* @internal */ + // Just a place to cache element types of iterables and iterators + export interface IterableOrIteratorType extends ObjectType, UnionType { + iterableElementType?: Type; + iteratorElementType?: Type; + } + // Type parameters (TypeFlags.TypeParameter) export interface TypeParameter extends Type { constraint: Type; // Constraint From 6183c81f9e4c48d012aacf2923954908aebde8b7 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 4 May 2015 15:59:30 -0700 Subject: [PATCH 068/402] Formatting for yield and yield* expressions --- src/services/formatting/rules.ts | 15 ++++++++-- .../cases/fourslash/yieldKeywordFormatting.ts | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/yieldKeywordFormatting.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index b6b33ca51f3..4947b296a4d 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -201,7 +201,9 @@ module ts.formatting { // Generator: function* public NoSpaceBetweenFunctionKeywordAndStar: Rule; - public SpaceAfterStarInGenerator: Rule; + public SpaceAfterStarInGeneratorDeclaration: Rule; + public NoSpaceBetweenYieldKeywordAndStar: Rule; + public SpaceBetweenYieldOrYieldStarAndOperand: Rule; constructor() { /// @@ -345,7 +347,9 @@ module ts.formatting { this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete)); - this.SpaceAfterStarInGenerator = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); + this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); + this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = @@ -364,8 +368,9 @@ module ts.formatting { this.NoSpaceAfterCloseBrace, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, - this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGenerator, + this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, + this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, this.NoSpaceBetweenReturnAndSemicolon, this.SpaceAfterCertainKeywords, this.SpaceAfterLetConstInVariableDeclaration, @@ -725,5 +730,9 @@ module ts.formatting { static IsVoidOpContext(context: FormattingContext): boolean { return context.currentTokenSpan.kind === SyntaxKind.VoidKeyword && context.currentTokenParent.kind === SyntaxKind.VoidExpression; } + + static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.YieldExpression && (context.contextNode).expression !== undefined; + } } } \ No newline at end of file diff --git a/tests/cases/fourslash/yieldKeywordFormatting.ts b/tests/cases/fourslash/yieldKeywordFormatting.ts new file mode 100644 index 00000000000..8ea5d86673e --- /dev/null +++ b/tests/cases/fourslash/yieldKeywordFormatting.ts @@ -0,0 +1,28 @@ +/// + +////function* g3() { +/////*1*/ yield ; +/////*2*/ g3().next( yield ); +/////*3*/ yield new Bar; +/////*4*/ yield * new Bar; +/////*5*/ yield * [new Bar]; +/////*6*/ yield+ 1; +/////*7*/ yield++ 1; +////} + +format.document(); +let expected = + [ + " yield;", + " g3().next(yield);", + " yield new Bar;", + " yield* new Bar;", + " yield* [new Bar];", + " yield + 1;", // Should be "yield +1". This case is covered by bug 3028. + " yield ++1;" + ]; + +for (let i = 0; i < expected.length; i++) { + goTo.marker("" + (i + 1)); + verify.currentLineContentIs(expected[i]); +} From 28d9c6cd7e3acc43c9af4f2e8d9466824480d0ac Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 4 May 2015 16:15:55 -0700 Subject: [PATCH 069/402] Add tests for generators --- .../reference/generatorTypeCheck1.js | 5 ++ .../reference/generatorTypeCheck1.symbols | 5 ++ .../reference/generatorTypeCheck1.types | 5 ++ .../reference/generatorTypeCheck10.js | 9 ++++ .../reference/generatorTypeCheck10.symbols | 7 +++ .../reference/generatorTypeCheck10.types | 7 +++ .../reference/generatorTypeCheck11.js | 9 ++++ .../reference/generatorTypeCheck11.symbols | 7 +++ .../reference/generatorTypeCheck11.types | 8 ++++ .../reference/generatorTypeCheck12.js | 9 ++++ .../reference/generatorTypeCheck12.symbols | 7 +++ .../reference/generatorTypeCheck12.types | 8 ++++ .../reference/generatorTypeCheck13.js | 11 +++++ .../reference/generatorTypeCheck13.symbols | 8 ++++ .../reference/generatorTypeCheck13.types | 12 +++++ .../reference/generatorTypeCheck14.js | 11 +++++ .../reference/generatorTypeCheck14.symbols | 7 +++ .../reference/generatorTypeCheck14.types | 11 +++++ .../reference/generatorTypeCheck15.js | 9 ++++ .../reference/generatorTypeCheck15.symbols | 6 +++ .../reference/generatorTypeCheck15.types | 7 +++ .../reference/generatorTypeCheck16.js | 9 ++++ .../reference/generatorTypeCheck16.symbols | 6 +++ .../reference/generatorTypeCheck16.types | 6 +++ .../reference/generatorTypeCheck17.js | 17 +++++++ .../reference/generatorTypeCheck17.symbols | 19 ++++++++ .../reference/generatorTypeCheck17.types | 23 +++++++++ .../reference/generatorTypeCheck18.errors.txt | 14 ++++++ .../reference/generatorTypeCheck18.js | 17 +++++++ .../reference/generatorTypeCheck19.js | 17 +++++++ .../reference/generatorTypeCheck19.symbols | 19 ++++++++ .../reference/generatorTypeCheck19.types | 24 ++++++++++ .../reference/generatorTypeCheck2.js | 5 ++ .../reference/generatorTypeCheck2.symbols | 5 ++ .../reference/generatorTypeCheck2.types | 5 ++ .../reference/generatorTypeCheck20.errors.txt | 14 ++++++ .../reference/generatorTypeCheck20.js | 17 +++++++ .../reference/generatorTypeCheck21.errors.txt | 12 +++++ .../reference/generatorTypeCheck21.js | 17 +++++++ .../reference/generatorTypeCheck22.js | 26 ++++++++++ .../reference/generatorTypeCheck22.symbols | 30 ++++++++++++ .../reference/generatorTypeCheck22.types | 42 ++++++++++++++++ .../reference/generatorTypeCheck23.js | 28 +++++++++++ .../reference/generatorTypeCheck23.symbols | 33 +++++++++++++ .../reference/generatorTypeCheck23.types | 47 ++++++++++++++++++ .../reference/generatorTypeCheck24.js | 28 +++++++++++ .../reference/generatorTypeCheck24.symbols | 33 +++++++++++++ .../reference/generatorTypeCheck24.types | 48 +++++++++++++++++++ .../reference/generatorTypeCheck25.errors.txt | 36 ++++++++++++++ .../reference/generatorTypeCheck25.js | 26 ++++++++++ .../reference/generatorTypeCheck26.js | 13 +++++ .../reference/generatorTypeCheck26.symbols | 22 +++++++++ .../reference/generatorTypeCheck26.types | 30 ++++++++++++ .../reference/generatorTypeCheck27.js | 13 +++++ .../reference/generatorTypeCheck27.symbols | 13 +++++ .../reference/generatorTypeCheck27.types | 21 ++++++++ .../reference/generatorTypeCheck28.js | 17 +++++++ .../reference/generatorTypeCheck28.symbols | 20 ++++++++ .../reference/generatorTypeCheck28.types | 25 ++++++++++ .../reference/generatorTypeCheck29.js | 13 +++++ .../reference/generatorTypeCheck29.symbols | 14 ++++++ .../reference/generatorTypeCheck29.types | 22 +++++++++ .../reference/generatorTypeCheck3.js | 5 ++ .../reference/generatorTypeCheck3.symbols | 5 ++ .../reference/generatorTypeCheck3.types | 5 ++ .../reference/generatorTypeCheck30.js | 13 +++++ .../reference/generatorTypeCheck30.symbols | 14 ++++++ .../reference/generatorTypeCheck30.types | 22 +++++++++ .../reference/generatorTypeCheck31.errors.txt | 13 +++++ .../reference/generatorTypeCheck31.js | 13 +++++ .../reference/generatorTypeCheck32.errors.txt | 8 ++++ .../reference/generatorTypeCheck32.js | 7 +++ .../reference/generatorTypeCheck33.js | 15 ++++++ .../reference/generatorTypeCheck33.symbols | 11 +++++ .../reference/generatorTypeCheck33.types | 16 +++++++ .../reference/generatorTypeCheck34.js | 15 ++++++ .../reference/generatorTypeCheck34.symbols | 11 +++++ .../reference/generatorTypeCheck34.types | 15 ++++++ .../reference/generatorTypeCheck35.js | 15 ++++++ .../reference/generatorTypeCheck35.symbols | 11 +++++ .../reference/generatorTypeCheck35.types | 15 ++++++ .../reference/generatorTypeCheck36.js | 9 ++++ .../reference/generatorTypeCheck36.symbols | 6 +++ .../reference/generatorTypeCheck36.types | 9 ++++ .../reference/generatorTypeCheck37.js | 9 ++++ .../reference/generatorTypeCheck37.symbols | 6 +++ .../reference/generatorTypeCheck37.types | 9 ++++ .../reference/generatorTypeCheck38.js | 13 +++++ .../reference/generatorTypeCheck38.symbols | 12 +++++ .../reference/generatorTypeCheck38.types | 15 ++++++ .../reference/generatorTypeCheck39.errors.txt | 27 +++++++++++ .../reference/generatorTypeCheck39.js | 33 +++++++++++++ .../reference/generatorTypeCheck4.js | 5 ++ .../reference/generatorTypeCheck4.symbols | 4 ++ .../reference/generatorTypeCheck4.types | 4 ++ .../reference/generatorTypeCheck40.errors.txt | 12 +++++ .../reference/generatorTypeCheck40.js | 10 ++++ .../reference/generatorTypeCheck41.js | 13 +++++ .../reference/generatorTypeCheck41.symbols | 10 ++++ .../reference/generatorTypeCheck41.types | 14 ++++++ .../reference/generatorTypeCheck42.js | 16 +++++++ .../reference/generatorTypeCheck42.symbols | 12 +++++ .../reference/generatorTypeCheck42.types | 15 ++++++ .../reference/generatorTypeCheck43.js | 16 +++++++ .../reference/generatorTypeCheck43.symbols | 12 +++++ .../reference/generatorTypeCheck43.types | 15 ++++++ .../reference/generatorTypeCheck44.js | 17 +++++++ .../reference/generatorTypeCheck44.symbols | 12 +++++ .../reference/generatorTypeCheck44.types | 17 +++++++ .../reference/generatorTypeCheck45.js | 7 +++ .../reference/generatorTypeCheck45.symbols | 27 +++++++++++ .../reference/generatorTypeCheck45.types | 33 +++++++++++++ .../reference/generatorTypeCheck46.js | 19 ++++++++ .../reference/generatorTypeCheck46.symbols | 38 +++++++++++++++ .../reference/generatorTypeCheck46.types | 47 ++++++++++++++++++ .../reference/generatorTypeCheck47.errors.txt | 8 ++++ .../reference/generatorTypeCheck47.js | 6 +++ .../reference/generatorTypeCheck48.errors.txt | 10 ++++ .../reference/generatorTypeCheck48.js | 10 ++++ .../reference/generatorTypeCheck49.js | 10 ++++ .../reference/generatorTypeCheck49.symbols | 7 +++ .../reference/generatorTypeCheck49.types | 9 ++++ .../reference/generatorTypeCheck5.js | 5 ++ .../reference/generatorTypeCheck5.symbols | 4 ++ .../reference/generatorTypeCheck5.types | 4 ++ .../reference/generatorTypeCheck50.js | 10 ++++ .../reference/generatorTypeCheck50.symbols | 7 +++ .../reference/generatorTypeCheck50.types | 9 ++++ .../reference/generatorTypeCheck51.errors.txt | 12 +++++ .../reference/generatorTypeCheck51.js | 14 ++++++ .../reference/generatorTypeCheck6.errors.txt | 7 +++ .../reference/generatorTypeCheck6.js | 5 ++ .../reference/generatorTypeCheck7.errors.txt | 12 +++++ .../reference/generatorTypeCheck7.js | 8 ++++ .../reference/generatorTypeCheck8.errors.txt | 16 +++++++ .../reference/generatorTypeCheck8.js | 6 +++ .../reference/generatorTypeCheck9.errors.txt | 7 +++ .../reference/generatorTypeCheck9.js | 5 ++ .../yieldExpressions/generatorTypeCheck1.ts | 2 + .../yieldExpressions/generatorTypeCheck10.ts | 4 ++ .../yieldExpressions/generatorTypeCheck11.ts | 4 ++ .../yieldExpressions/generatorTypeCheck12.ts | 4 ++ .../yieldExpressions/generatorTypeCheck13.ts | 5 ++ .../yieldExpressions/generatorTypeCheck14.ts | 5 ++ .../yieldExpressions/generatorTypeCheck15.ts | 4 ++ .../yieldExpressions/generatorTypeCheck16.ts | 4 ++ .../yieldExpressions/generatorTypeCheck17.ts | 7 +++ .../yieldExpressions/generatorTypeCheck18.ts | 7 +++ .../yieldExpressions/generatorTypeCheck19.ts | 7 +++ .../yieldExpressions/generatorTypeCheck2.ts | 2 + .../yieldExpressions/generatorTypeCheck20.ts | 7 +++ .../yieldExpressions/generatorTypeCheck21.ts | 7 +++ .../yieldExpressions/generatorTypeCheck22.ts | 11 +++++ .../yieldExpressions/generatorTypeCheck23.ts | 12 +++++ .../yieldExpressions/generatorTypeCheck24.ts | 12 +++++ .../yieldExpressions/generatorTypeCheck25.ts | 11 +++++ .../yieldExpressions/generatorTypeCheck26.ts | 6 +++ .../yieldExpressions/generatorTypeCheck27.ts | 6 +++ .../yieldExpressions/generatorTypeCheck28.ts | 8 ++++ .../yieldExpressions/generatorTypeCheck29.ts | 6 +++ .../yieldExpressions/generatorTypeCheck3.ts | 2 + .../yieldExpressions/generatorTypeCheck30.ts | 6 +++ .../yieldExpressions/generatorTypeCheck31.ts | 6 +++ .../yieldExpressions/generatorTypeCheck32.ts | 3 ++ .../yieldExpressions/generatorTypeCheck33.ts | 7 +++ .../yieldExpressions/generatorTypeCheck34.ts | 7 +++ .../yieldExpressions/generatorTypeCheck35.ts | 7 +++ .../yieldExpressions/generatorTypeCheck36.ts | 4 ++ .../yieldExpressions/generatorTypeCheck37.ts | 4 ++ .../yieldExpressions/generatorTypeCheck38.ts | 6 +++ .../yieldExpressions/generatorTypeCheck39.ts | 10 ++++ .../yieldExpressions/generatorTypeCheck4.ts | 2 + .../yieldExpressions/generatorTypeCheck40.ts | 4 ++ .../yieldExpressions/generatorTypeCheck41.ts | 6 +++ .../yieldExpressions/generatorTypeCheck42.ts | 8 ++++ .../yieldExpressions/generatorTypeCheck43.ts | 8 ++++ .../yieldExpressions/generatorTypeCheck44.ts | 8 ++++ .../yieldExpressions/generatorTypeCheck45.ts | 4 ++ .../yieldExpressions/generatorTypeCheck46.ts | 10 ++++ .../yieldExpressions/generatorTypeCheck47.ts | 4 ++ .../yieldExpressions/generatorTypeCheck48.ts | 6 +++ .../yieldExpressions/generatorTypeCheck49.ts | 6 +++ .../yieldExpressions/generatorTypeCheck5.ts | 2 + .../yieldExpressions/generatorTypeCheck50.ts | 6 +++ .../yieldExpressions/generatorTypeCheck51.ts | 8 ++++ .../yieldExpressions/generatorTypeCheck6.ts | 2 + .../yieldExpressions/generatorTypeCheck7.ts | 5 ++ .../yieldExpressions/generatorTypeCheck8.ts | 3 ++ .../yieldExpressions/generatorTypeCheck9.ts | 2 + 189 files changed, 2254 insertions(+) create mode 100644 tests/baselines/reference/generatorTypeCheck1.js create mode 100644 tests/baselines/reference/generatorTypeCheck1.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck1.types create mode 100644 tests/baselines/reference/generatorTypeCheck10.js create mode 100644 tests/baselines/reference/generatorTypeCheck10.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck10.types create mode 100644 tests/baselines/reference/generatorTypeCheck11.js create mode 100644 tests/baselines/reference/generatorTypeCheck11.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck11.types create mode 100644 tests/baselines/reference/generatorTypeCheck12.js create mode 100644 tests/baselines/reference/generatorTypeCheck12.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck12.types create mode 100644 tests/baselines/reference/generatorTypeCheck13.js create mode 100644 tests/baselines/reference/generatorTypeCheck13.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck13.types create mode 100644 tests/baselines/reference/generatorTypeCheck14.js create mode 100644 tests/baselines/reference/generatorTypeCheck14.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck14.types create mode 100644 tests/baselines/reference/generatorTypeCheck15.js create mode 100644 tests/baselines/reference/generatorTypeCheck15.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck15.types create mode 100644 tests/baselines/reference/generatorTypeCheck16.js create mode 100644 tests/baselines/reference/generatorTypeCheck16.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck16.types create mode 100644 tests/baselines/reference/generatorTypeCheck17.js create mode 100644 tests/baselines/reference/generatorTypeCheck17.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck17.types create mode 100644 tests/baselines/reference/generatorTypeCheck18.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck18.js create mode 100644 tests/baselines/reference/generatorTypeCheck19.js create mode 100644 tests/baselines/reference/generatorTypeCheck19.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck19.types create mode 100644 tests/baselines/reference/generatorTypeCheck2.js create mode 100644 tests/baselines/reference/generatorTypeCheck2.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck2.types create mode 100644 tests/baselines/reference/generatorTypeCheck20.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck20.js create mode 100644 tests/baselines/reference/generatorTypeCheck21.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck21.js create mode 100644 tests/baselines/reference/generatorTypeCheck22.js create mode 100644 tests/baselines/reference/generatorTypeCheck22.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck22.types create mode 100644 tests/baselines/reference/generatorTypeCheck23.js create mode 100644 tests/baselines/reference/generatorTypeCheck23.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck23.types create mode 100644 tests/baselines/reference/generatorTypeCheck24.js create mode 100644 tests/baselines/reference/generatorTypeCheck24.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck24.types create mode 100644 tests/baselines/reference/generatorTypeCheck25.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck25.js create mode 100644 tests/baselines/reference/generatorTypeCheck26.js create mode 100644 tests/baselines/reference/generatorTypeCheck26.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck26.types create mode 100644 tests/baselines/reference/generatorTypeCheck27.js create mode 100644 tests/baselines/reference/generatorTypeCheck27.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck27.types create mode 100644 tests/baselines/reference/generatorTypeCheck28.js create mode 100644 tests/baselines/reference/generatorTypeCheck28.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck28.types create mode 100644 tests/baselines/reference/generatorTypeCheck29.js create mode 100644 tests/baselines/reference/generatorTypeCheck29.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck29.types create mode 100644 tests/baselines/reference/generatorTypeCheck3.js create mode 100644 tests/baselines/reference/generatorTypeCheck3.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck3.types create mode 100644 tests/baselines/reference/generatorTypeCheck30.js create mode 100644 tests/baselines/reference/generatorTypeCheck30.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck30.types create mode 100644 tests/baselines/reference/generatorTypeCheck31.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck31.js create mode 100644 tests/baselines/reference/generatorTypeCheck32.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck32.js create mode 100644 tests/baselines/reference/generatorTypeCheck33.js create mode 100644 tests/baselines/reference/generatorTypeCheck33.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck33.types create mode 100644 tests/baselines/reference/generatorTypeCheck34.js create mode 100644 tests/baselines/reference/generatorTypeCheck34.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck34.types create mode 100644 tests/baselines/reference/generatorTypeCheck35.js create mode 100644 tests/baselines/reference/generatorTypeCheck35.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck35.types create mode 100644 tests/baselines/reference/generatorTypeCheck36.js create mode 100644 tests/baselines/reference/generatorTypeCheck36.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck36.types create mode 100644 tests/baselines/reference/generatorTypeCheck37.js create mode 100644 tests/baselines/reference/generatorTypeCheck37.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck37.types create mode 100644 tests/baselines/reference/generatorTypeCheck38.js create mode 100644 tests/baselines/reference/generatorTypeCheck38.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck38.types create mode 100644 tests/baselines/reference/generatorTypeCheck39.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck39.js create mode 100644 tests/baselines/reference/generatorTypeCheck4.js create mode 100644 tests/baselines/reference/generatorTypeCheck4.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck4.types create mode 100644 tests/baselines/reference/generatorTypeCheck40.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck40.js create mode 100644 tests/baselines/reference/generatorTypeCheck41.js create mode 100644 tests/baselines/reference/generatorTypeCheck41.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck41.types create mode 100644 tests/baselines/reference/generatorTypeCheck42.js create mode 100644 tests/baselines/reference/generatorTypeCheck42.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck42.types create mode 100644 tests/baselines/reference/generatorTypeCheck43.js create mode 100644 tests/baselines/reference/generatorTypeCheck43.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck43.types create mode 100644 tests/baselines/reference/generatorTypeCheck44.js create mode 100644 tests/baselines/reference/generatorTypeCheck44.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck44.types create mode 100644 tests/baselines/reference/generatorTypeCheck45.js create mode 100644 tests/baselines/reference/generatorTypeCheck45.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck45.types create mode 100644 tests/baselines/reference/generatorTypeCheck46.js create mode 100644 tests/baselines/reference/generatorTypeCheck46.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck46.types create mode 100644 tests/baselines/reference/generatorTypeCheck47.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck47.js create mode 100644 tests/baselines/reference/generatorTypeCheck48.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck48.js create mode 100644 tests/baselines/reference/generatorTypeCheck49.js create mode 100644 tests/baselines/reference/generatorTypeCheck49.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck49.types create mode 100644 tests/baselines/reference/generatorTypeCheck5.js create mode 100644 tests/baselines/reference/generatorTypeCheck5.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck5.types create mode 100644 tests/baselines/reference/generatorTypeCheck50.js create mode 100644 tests/baselines/reference/generatorTypeCheck50.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck50.types create mode 100644 tests/baselines/reference/generatorTypeCheck51.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck51.js create mode 100644 tests/baselines/reference/generatorTypeCheck6.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck6.js create mode 100644 tests/baselines/reference/generatorTypeCheck7.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck7.js create mode 100644 tests/baselines/reference/generatorTypeCheck8.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck8.js create mode 100644 tests/baselines/reference/generatorTypeCheck9.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck9.js create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck17.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck18.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck19.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck20.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck21.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck38.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck4.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck45.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck46.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck5.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck6.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck9.ts diff --git a/tests/baselines/reference/generatorTypeCheck1.js b/tests/baselines/reference/generatorTypeCheck1.js new file mode 100644 index 00000000000..eb3cbcd2fe0 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck1.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck1.ts] +function* g1(): Iterator { } + +//// [generatorTypeCheck1.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols new file mode 100644 index 00000000000..6c70c77465a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === +function* g1(): Iterator { } +>g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1657, 1)) + diff --git a/tests/baselines/reference/generatorTypeCheck1.types b/tests/baselines/reference/generatorTypeCheck1.types new file mode 100644 index 00000000000..3f02fe4b095 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck1.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === +function* g1(): Iterator { } +>g1 : () => Iterator +>Iterator : Iterator + diff --git a/tests/baselines/reference/generatorTypeCheck10.js b/tests/baselines/reference/generatorTypeCheck10.js new file mode 100644 index 00000000000..252f3011613 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck10.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck10.ts] +function* g(): IterableIterator { + return; +} + +//// [generatorTypeCheck10.js] +function* g() { + return; +} diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols new file mode 100644 index 00000000000..d45ab32ba95 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === +function* g(): IterableIterator { +>g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) + + return; +} diff --git a/tests/baselines/reference/generatorTypeCheck10.types b/tests/baselines/reference/generatorTypeCheck10.types new file mode 100644 index 00000000000..f9304e3b168 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck10.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === +function* g(): IterableIterator { +>g : () => IterableIterator +>IterableIterator : IterableIterator + + return; +} diff --git a/tests/baselines/reference/generatorTypeCheck11.js b/tests/baselines/reference/generatorTypeCheck11.js new file mode 100644 index 00000000000..4898f661f26 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck11.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck11.ts] +function* g(): IterableIterator { + return 0; +} + +//// [generatorTypeCheck11.js] +function* g() { + return 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols new file mode 100644 index 00000000000..62777f2384d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === +function* g(): IterableIterator { +>g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) + + return 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck11.types b/tests/baselines/reference/generatorTypeCheck11.types new file mode 100644 index 00000000000..ce47d497851 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck11.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === +function* g(): IterableIterator { +>g : () => IterableIterator +>IterableIterator : IterableIterator + + return 0; +>0 : number +} diff --git a/tests/baselines/reference/generatorTypeCheck12.js b/tests/baselines/reference/generatorTypeCheck12.js new file mode 100644 index 00000000000..058b0a0772d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck12.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck12.ts] +function* g(): IterableIterator { + return ""; +} + +//// [generatorTypeCheck12.js] +function* g() { + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols new file mode 100644 index 00000000000..5b5f6cda05a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === +function* g(): IterableIterator { +>g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) + + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck12.types b/tests/baselines/reference/generatorTypeCheck12.types new file mode 100644 index 00000000000..3dd3c20f18d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck12.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === +function* g(): IterableIterator { +>g : () => IterableIterator +>IterableIterator : IterableIterator + + return ""; +>"" : string +} diff --git a/tests/baselines/reference/generatorTypeCheck13.js b/tests/baselines/reference/generatorTypeCheck13.js new file mode 100644 index 00000000000..26308b0ac7e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck13.js @@ -0,0 +1,11 @@ +//// [generatorTypeCheck13.ts] +function* g(): IterableIterator { + yield 0; + return ""; +} + +//// [generatorTypeCheck13.js] +function* g() { + yield 0; + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols new file mode 100644 index 00000000000..a9123bf3e62 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === +function* g(): IterableIterator { +>g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) + + yield 0; + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck13.types b/tests/baselines/reference/generatorTypeCheck13.types new file mode 100644 index 00000000000..d77b630ae72 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck13.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === +function* g(): IterableIterator { +>g : () => IterableIterator +>IterableIterator : IterableIterator + + yield 0; +>yield 0 : any +>0 : number + + return ""; +>"" : string +} diff --git a/tests/baselines/reference/generatorTypeCheck14.js b/tests/baselines/reference/generatorTypeCheck14.js new file mode 100644 index 00000000000..a7dcc87a3a9 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck14.js @@ -0,0 +1,11 @@ +//// [generatorTypeCheck14.ts] +function* g() { + yield 0; + return ""; +} + +//// [generatorTypeCheck14.js] +function* g() { + yield 0; + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck14.symbols b/tests/baselines/reference/generatorTypeCheck14.symbols new file mode 100644 index 00000000000..36d10d88545 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck14.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck14.ts, 0, 0)) + + yield 0; + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck14.types b/tests/baselines/reference/generatorTypeCheck14.types new file mode 100644 index 00000000000..db1b5bde19a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck14.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts === +function* g() { +>g : () => IterableIterator + + yield 0; +>yield 0 : any +>0 : number + + return ""; +>"" : string +} diff --git a/tests/baselines/reference/generatorTypeCheck15.js b/tests/baselines/reference/generatorTypeCheck15.js new file mode 100644 index 00000000000..d359c100486 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck15.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck15.ts] +function* g() { + return ""; +} + +//// [generatorTypeCheck15.js] +function* g() { + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck15.symbols b/tests/baselines/reference/generatorTypeCheck15.symbols new file mode 100644 index 00000000000..3d914d0bd6f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck15.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck15.ts, 0, 0)) + + return ""; +} diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types new file mode 100644 index 00000000000..4437d78572d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === +function* g() { +>g : () => IterableIterator + + return ""; +>"" : string +} diff --git a/tests/baselines/reference/generatorTypeCheck16.js b/tests/baselines/reference/generatorTypeCheck16.js new file mode 100644 index 00000000000..7b8b93deabd --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck16.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck16.ts] +function* g() { + return; +} + +//// [generatorTypeCheck16.js] +function* g() { + return; +} diff --git a/tests/baselines/reference/generatorTypeCheck16.symbols b/tests/baselines/reference/generatorTypeCheck16.symbols new file mode 100644 index 00000000000..bbc22cc4a2d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck16.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck16.ts, 0, 0)) + + return; +} diff --git a/tests/baselines/reference/generatorTypeCheck16.types b/tests/baselines/reference/generatorTypeCheck16.types new file mode 100644 index 00000000000..a607ad851c1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck16.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts === +function* g() { +>g : () => IterableIterator + + return; +} diff --git a/tests/baselines/reference/generatorTypeCheck17.js b/tests/baselines/reference/generatorTypeCheck17.js new file mode 100644 index 00000000000..8c3ebb59ea6 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck17.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck17.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +function* g(): IterableIterator { + yield; + yield new Bar; +} + +//// [generatorTypeCheck17.js] +class Foo { +} +class Bar extends Foo { +} +function* g() { + yield; + yield new Bar; +} diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols new file mode 100644 index 00000000000..a8b62a0db78 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck17.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) +>x : Symbol(x, Decl(generatorTypeCheck17.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck17.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) +>y : Symbol(y, Decl(generatorTypeCheck17.ts, 1, 23)) + +function* g(): IterableIterator { +>g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) + + yield; + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck17.ts, 0, 23)) +} diff --git a/tests/baselines/reference/generatorTypeCheck17.types b/tests/baselines/reference/generatorTypeCheck17.types new file mode 100644 index 00000000000..0ea7212040b --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck17.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck17.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +function* g(): IterableIterator { +>g : () => IterableIterator +>IterableIterator : IterableIterator +>Foo : Foo + + yield; +>yield : any + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar +} diff --git a/tests/baselines/reference/generatorTypeCheck18.errors.txt b/tests/baselines/reference/generatorTypeCheck18.errors.txt new file mode 100644 index 00000000000..2c6deab9821 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck18.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck18.ts(5,11): error TS2322: Type 'Baz' is not assignable to type 'Foo'. + Property 'x' is missing in type 'Baz'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck18.ts (1 errors) ==== + class Foo { x: number } + class Baz { z: number } + function* g(): IterableIterator { + yield; + yield new Baz; + ~~~~~~~ +!!! error TS2322: Type 'Baz' is not assignable to type 'Foo'. +!!! error TS2322: Property 'x' is missing in type 'Baz'. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck18.js b/tests/baselines/reference/generatorTypeCheck18.js new file mode 100644 index 00000000000..5907dd14b29 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck18.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck18.ts] +class Foo { x: number } +class Baz { z: number } +function* g(): IterableIterator { + yield; + yield new Baz; +} + +//// [generatorTypeCheck18.js] +class Foo { +} +class Baz { +} +function* g() { + yield; + yield new Baz; +} diff --git a/tests/baselines/reference/generatorTypeCheck19.js b/tests/baselines/reference/generatorTypeCheck19.js new file mode 100644 index 00000000000..375d7b36ecc --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck19.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck19.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +function* g(): IterableIterator { + yield; + yield * [new Bar]; +} + +//// [generatorTypeCheck19.js] +class Foo { +} +class Bar extends Foo { +} +function* g() { + yield; + yield* [new Bar]; +} diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols new file mode 100644 index 00000000000..06f2397f467 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck19.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) +>x : Symbol(x, Decl(generatorTypeCheck19.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck19.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) +>y : Symbol(y, Decl(generatorTypeCheck19.ts, 1, 23)) + +function* g(): IterableIterator { +>g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) + + yield; + yield * [new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck19.ts, 0, 23)) +} diff --git a/tests/baselines/reference/generatorTypeCheck19.types b/tests/baselines/reference/generatorTypeCheck19.types new file mode 100644 index 00000000000..2b4f1396c2e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck19.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck19.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +function* g(): IterableIterator { +>g : () => IterableIterator +>IterableIterator : IterableIterator +>Foo : Foo + + yield; +>yield : any + + yield * [new Bar]; +>yield * [new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar +} diff --git a/tests/baselines/reference/generatorTypeCheck2.js b/tests/baselines/reference/generatorTypeCheck2.js new file mode 100644 index 00000000000..559946b0fcb --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck2.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck2.ts] +function* g1(): Iterable { } + +//// [generatorTypeCheck2.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols new file mode 100644 index 00000000000..285be06fe7b --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === +function* g1(): Iterable { } +>g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) + diff --git a/tests/baselines/reference/generatorTypeCheck2.types b/tests/baselines/reference/generatorTypeCheck2.types new file mode 100644 index 00000000000..882367fa3d4 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck2.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === +function* g1(): Iterable { } +>g1 : () => Iterable +>Iterable : Iterable + diff --git a/tests/baselines/reference/generatorTypeCheck20.errors.txt b/tests/baselines/reference/generatorTypeCheck20.errors.txt new file mode 100644 index 00000000000..c6e8200d106 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck20.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck20.ts(5,13): error TS2322: Type 'Baz' is not assignable to type 'Foo'. + Property 'x' is missing in type 'Baz'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck20.ts (1 errors) ==== + class Foo { x: number } + class Baz { z: number } + function* g(): IterableIterator { + yield; + yield * [new Baz]; + ~~~~~~~~~ +!!! error TS2322: Type 'Baz' is not assignable to type 'Foo'. +!!! error TS2322: Property 'x' is missing in type 'Baz'. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck20.js b/tests/baselines/reference/generatorTypeCheck20.js new file mode 100644 index 00000000000..c7336079bf0 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck20.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck20.ts] +class Foo { x: number } +class Baz { z: number } +function* g(): IterableIterator { + yield; + yield * [new Baz]; +} + +//// [generatorTypeCheck20.js] +class Foo { +} +class Baz { +} +function* g() { + yield; + yield* [new Baz]; +} diff --git a/tests/baselines/reference/generatorTypeCheck21.errors.txt b/tests/baselines/reference/generatorTypeCheck21.errors.txt new file mode 100644 index 00000000000..0ef66aa1bd7 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck21.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck21.ts(5,13): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck21.ts (1 errors) ==== + class Foo { x: number } + class Bar extends Foo { y: string } + function* g(): IterableIterator { + yield; + yield * new Bar; + ~~~~~~~ +!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck21.js b/tests/baselines/reference/generatorTypeCheck21.js new file mode 100644 index 00000000000..83d1007a2c2 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck21.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck21.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +function* g(): IterableIterator { + yield; + yield * new Bar; +} + +//// [generatorTypeCheck21.js] +class Foo { +} +class Bar extends Foo { +} +function* g() { + yield; + yield* new Bar; +} diff --git a/tests/baselines/reference/generatorTypeCheck22.js b/tests/baselines/reference/generatorTypeCheck22.js new file mode 100644 index 00000000000..0045e115e6f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck22.js @@ -0,0 +1,26 @@ +//// [generatorTypeCheck22.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +function* g3() { + yield; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} + +//// [generatorTypeCheck22.js] +class Foo { +} +class Bar extends Foo { +} +class Baz { +} +function* g3() { + yield; + yield new Bar; + yield new Baz; + yield* [new Bar]; + yield* [new Baz]; +} diff --git a/tests/baselines/reference/generatorTypeCheck22.symbols b/tests/baselines/reference/generatorTypeCheck22.symbols new file mode 100644 index 00000000000..24ed2f13404 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck22.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck22.ts, 0, 0)) +>x : Symbol(x, Decl(generatorTypeCheck22.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck22.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck22.ts, 0, 0)) +>y : Symbol(y, Decl(generatorTypeCheck22.ts, 1, 23)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck22.ts, 1, 35)) +>z : Symbol(z, Decl(generatorTypeCheck22.ts, 2, 11)) + +function* g3() { +>g3 : Symbol(g3, Decl(generatorTypeCheck22.ts, 2, 23)) + + yield; + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck22.ts, 0, 23)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck22.ts, 1, 35)) + + yield *[new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck22.ts, 0, 23)) + + yield *[new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck22.ts, 1, 35)) +} diff --git a/tests/baselines/reference/generatorTypeCheck22.types b/tests/baselines/reference/generatorTypeCheck22.types new file mode 100644 index 00000000000..897d5f9400c --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck22.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g3() { +>g3 : () => IterableIterator + + yield; +>yield : any + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz + + yield *[new Bar]; +>yield *[new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar + + yield *[new Baz]; +>yield *[new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck23.js b/tests/baselines/reference/generatorTypeCheck23.js new file mode 100644 index 00000000000..37c2c239e2c --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck23.js @@ -0,0 +1,28 @@ +//// [generatorTypeCheck23.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +function* g3() { + yield; + yield new Foo; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} + +//// [generatorTypeCheck23.js] +class Foo { +} +class Bar extends Foo { +} +class Baz { +} +function* g3() { + yield; + yield new Foo; + yield new Bar; + yield new Baz; + yield* [new Bar]; + yield* [new Baz]; +} diff --git a/tests/baselines/reference/generatorTypeCheck23.symbols b/tests/baselines/reference/generatorTypeCheck23.symbols new file mode 100644 index 00000000000..f0ce785a845 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck23.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck23.ts, 0, 0)) +>x : Symbol(x, Decl(generatorTypeCheck23.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck23.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck23.ts, 0, 0)) +>y : Symbol(y, Decl(generatorTypeCheck23.ts, 1, 23)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck23.ts, 1, 35)) +>z : Symbol(z, Decl(generatorTypeCheck23.ts, 2, 11)) + +function* g3() { +>g3 : Symbol(g3, Decl(generatorTypeCheck23.ts, 2, 23)) + + yield; + yield new Foo; +>Foo : Symbol(Foo, Decl(generatorTypeCheck23.ts, 0, 0)) + + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck23.ts, 0, 23)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck23.ts, 1, 35)) + + yield *[new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck23.ts, 0, 23)) + + yield *[new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck23.ts, 1, 35)) +} diff --git a/tests/baselines/reference/generatorTypeCheck23.types b/tests/baselines/reference/generatorTypeCheck23.types new file mode 100644 index 00000000000..47df973efb9 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck23.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g3() { +>g3 : () => IterableIterator + + yield; +>yield : any + + yield new Foo; +>yield new Foo : any +>new Foo : Foo +>Foo : typeof Foo + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz + + yield *[new Bar]; +>yield *[new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar + + yield *[new Baz]; +>yield *[new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck24.js b/tests/baselines/reference/generatorTypeCheck24.js new file mode 100644 index 00000000000..8b6018243ca --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck24.js @@ -0,0 +1,28 @@ +//// [generatorTypeCheck24.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +function* g3() { + yield; + yield * [new Foo]; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} + +//// [generatorTypeCheck24.js] +class Foo { +} +class Bar extends Foo { +} +class Baz { +} +function* g3() { + yield; + yield* [new Foo]; + yield new Bar; + yield new Baz; + yield* [new Bar]; + yield* [new Baz]; +} diff --git a/tests/baselines/reference/generatorTypeCheck24.symbols b/tests/baselines/reference/generatorTypeCheck24.symbols new file mode 100644 index 00000000000..db8be576a99 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck24.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck24.ts, 0, 0)) +>x : Symbol(x, Decl(generatorTypeCheck24.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck24.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck24.ts, 0, 0)) +>y : Symbol(y, Decl(generatorTypeCheck24.ts, 1, 23)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck24.ts, 1, 35)) +>z : Symbol(z, Decl(generatorTypeCheck24.ts, 2, 11)) + +function* g3() { +>g3 : Symbol(g3, Decl(generatorTypeCheck24.ts, 2, 23)) + + yield; + yield * [new Foo]; +>Foo : Symbol(Foo, Decl(generatorTypeCheck24.ts, 0, 0)) + + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck24.ts, 0, 23)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck24.ts, 1, 35)) + + yield *[new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck24.ts, 0, 23)) + + yield *[new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck24.ts, 1, 35)) +} diff --git a/tests/baselines/reference/generatorTypeCheck24.types b/tests/baselines/reference/generatorTypeCheck24.types new file mode 100644 index 00000000000..a82470b23b6 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck24.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g3() { +>g3 : () => IterableIterator + + yield; +>yield : any + + yield * [new Foo]; +>yield * [new Foo] : any +>[new Foo] : Foo[] +>new Foo : Foo +>Foo : typeof Foo + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz + + yield *[new Bar]; +>yield *[new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar + + yield *[new Baz]; +>yield *[new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck25.errors.txt b/tests/baselines/reference/generatorTypeCheck25.errors.txt new file mode 100644 index 00000000000..8d414c7c471 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck25.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error TS2322: Type '() => IterableIterator' is not assignable to type '() => Iterable'. + Type 'IterableIterator' is not assignable to type 'Iterable'. + Types of property '[Symbol.iterator]' are incompatible. + Type '() => IterableIterator' is not assignable to type '() => Iterator'. + Type 'IterableIterator' is not assignable to type 'Iterator'. + Types of property 'next' are incompatible. + Type '(value?: any) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'Bar | Baz' is not assignable to type 'Foo'. + Type 'Baz' is not assignable to type 'Foo'. + Property 'x' is missing in type 'Baz'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts (1 errors) ==== + class Foo { x: number } + class Bar extends Foo { y: string } + class Baz { z: number } + var g3: () => Iterable = function* () { + ~~ +!!! error TS2322: Type '() => IterableIterator' is not assignable to type '() => Iterable'. +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => IterableIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '(value?: any) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'Bar | Baz' is not assignable to type 'Foo'. +!!! error TS2322: Type 'Baz' is not assignable to type 'Foo'. +!!! error TS2322: Property 'x' is missing in type 'Baz'. + yield; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck25.js b/tests/baselines/reference/generatorTypeCheck25.js new file mode 100644 index 00000000000..894561bcc93 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck25.js @@ -0,0 +1,26 @@ +//// [generatorTypeCheck25.ts] +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +var g3: () => Iterable = function* () { + yield; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} + +//// [generatorTypeCheck25.js] +class Foo { +} +class Bar extends Foo { +} +class Baz { +} +var g3 = function* () { + yield; + yield new Bar; + yield new Baz; + yield* [new Bar]; + yield* [new Baz]; +}; diff --git a/tests/baselines/reference/generatorTypeCheck26.js b/tests/baselines/reference/generatorTypeCheck26.js new file mode 100644 index 00000000000..d5c1a4c7947 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck26.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck26.ts] +function* g(): IterableIterator<(x: string) => number> { + yield x => x.length; + yield *[x => x.length]; + return x => x.length; +} + +//// [generatorTypeCheck26.js] +function* g() { + yield x => x.length; + yield* [x => x.length]; + return x => x.length; +} diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols new file mode 100644 index 00000000000..b0017a31461 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === +function* g(): IterableIterator<(x: string) => number> { +>g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) + + yield x => x.length; +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 1, 9)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 1, 9)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + + yield *[x => x.length]; +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 2, 12)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 2, 12)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + + return x => x.length; +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 3, 10)) +>x : Symbol(x, Decl(generatorTypeCheck26.ts, 3, 10)) +} diff --git a/tests/baselines/reference/generatorTypeCheck26.types b/tests/baselines/reference/generatorTypeCheck26.types new file mode 100644 index 00000000000..8141a866c8e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck26.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === +function* g(): IterableIterator<(x: string) => number> { +>g : () => IterableIterator<(x: string) => number> +>IterableIterator : IterableIterator +>x : string + + yield x => x.length; +>yield x => x.length : any +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + + yield *[x => x.length]; +>yield *[x => x.length] : any +>[x => x.length] : ((x: string) => number)[] +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + + return x => x.length; +>x => x.length : (x: any) => any +>x : any +>x.length : any +>x : any +>length : any +} diff --git a/tests/baselines/reference/generatorTypeCheck27.js b/tests/baselines/reference/generatorTypeCheck27.js new file mode 100644 index 00000000000..528d510bed2 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck27.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck27.ts] +function* g(): IterableIterator<(x: string) => number> { + yield * function* () { + yield x => x.length; + } (); +} + +//// [generatorTypeCheck27.js] +function* g() { + yield* function* () { + yield x => x.length; + }(); +} diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols new file mode 100644 index 00000000000..f32d3274c4f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === +function* g(): IterableIterator<(x: string) => number> { +>g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) +>x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) + + yield * function* () { + yield x => x.length; +>x : Symbol(x, Decl(generatorTypeCheck27.ts, 2, 13)) +>x : Symbol(x, Decl(generatorTypeCheck27.ts, 2, 13)) + + } (); +} diff --git a/tests/baselines/reference/generatorTypeCheck27.types b/tests/baselines/reference/generatorTypeCheck27.types new file mode 100644 index 00000000000..7b120cfffc4 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck27.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === +function* g(): IterableIterator<(x: string) => number> { +>g : () => IterableIterator<(x: string) => number> +>IterableIterator : IterableIterator +>x : string + + yield * function* () { +>yield * function* () { yield x => x.length; } () : any +>function* () { yield x => x.length; } () : IterableIterator<(x: any) => any> +>function* () { yield x => x.length; } : () => IterableIterator<(x: any) => any> + + yield x => x.length; +>yield x => x.length : any +>x => x.length : (x: any) => any +>x : any +>x.length : any +>x : any +>length : any + + } (); +} diff --git a/tests/baselines/reference/generatorTypeCheck28.js b/tests/baselines/reference/generatorTypeCheck28.js new file mode 100644 index 00000000000..e94fd9b7e38 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck28.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck28.ts] +function* g(): IterableIterator<(x: string) => number> { + yield * { + *[Symbol.iterator]() { + yield x => x.length; + } + }; +} + +//// [generatorTypeCheck28.js] +function* g() { + yield* { + *[Symbol.iterator]() { + yield x => x.length; + } + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols new file mode 100644 index 00000000000..bb6c9c1d646 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === +function* g(): IterableIterator<(x: string) => number> { +>g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) +>x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) + + yield * { + *[Symbol.iterator]() { +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) + + yield x => x.length; +>x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + } + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck28.types b/tests/baselines/reference/generatorTypeCheck28.types new file mode 100644 index 00000000000..1afae072758 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck28.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === +function* g(): IterableIterator<(x: string) => number> { +>g : () => IterableIterator<(x: string) => number> +>IterableIterator : IterableIterator +>x : string + + yield * { +>yield * { *[Symbol.iterator]() { yield x => x.length; } } : any +>{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): IterableIterator<(x: string) => number>; } + + *[Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + yield x => x.length; +>yield x => x.length : any +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + } + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck29.js b/tests/baselines/reference/generatorTypeCheck29.js new file mode 100644 index 00000000000..4f5204f89fc --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck29.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck29.ts] +function* g2(): Iterator number>> { + yield function* () { + yield x => x.length; + } () +} + +//// [generatorTypeCheck29.js] +function* g2() { + yield function* () { + yield x => x.length; + }(); +} diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols new file mode 100644 index 00000000000..e4c10e5713e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === +function* g2(): Iterator number>> { +>g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1657, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) +>x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) + + yield function* () { + yield x => x.length; +>x : Symbol(x, Decl(generatorTypeCheck29.ts, 2, 13)) +>x : Symbol(x, Decl(generatorTypeCheck29.ts, 2, 13)) + + } () +} diff --git a/tests/baselines/reference/generatorTypeCheck29.types b/tests/baselines/reference/generatorTypeCheck29.types new file mode 100644 index 00000000000..85cb32e5759 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck29.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === +function* g2(): Iterator number>> { +>g2 : () => Iterator number>> +>Iterator : Iterator +>Iterable : Iterable +>x : string + + yield function* () { +>yield function* () { yield x => x.length; } () : any +>function* () { yield x => x.length; } () : IterableIterator<(x: any) => any> +>function* () { yield x => x.length; } : () => IterableIterator<(x: any) => any> + + yield x => x.length; +>yield x => x.length : any +>x => x.length : (x: any) => any +>x : any +>x.length : any +>x : any +>length : any + + } () +} diff --git a/tests/baselines/reference/generatorTypeCheck3.js b/tests/baselines/reference/generatorTypeCheck3.js new file mode 100644 index 00000000000..9d884a92f5e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck3.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck3.ts] +function* g1(): IterableIterator { } + +//// [generatorTypeCheck3.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols new file mode 100644 index 00000000000..b972a8e33a7 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === +function* g1(): IterableIterator { } +>g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1667, 1)) + diff --git a/tests/baselines/reference/generatorTypeCheck3.types b/tests/baselines/reference/generatorTypeCheck3.types new file mode 100644 index 00000000000..9d2fb9d517d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck3.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === +function* g1(): IterableIterator { } +>g1 : () => IterableIterator +>IterableIterator : IterableIterator + diff --git a/tests/baselines/reference/generatorTypeCheck30.js b/tests/baselines/reference/generatorTypeCheck30.js new file mode 100644 index 00000000000..e652dd1b55f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck30.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck30.ts] +function* g2(): Iterator number>> { + yield function* () { + yield x => x.length; + } () +} + +//// [generatorTypeCheck30.js] +function* g2() { + yield function* () { + yield x => x.length; + }(); +} diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols new file mode 100644 index 00000000000..873b7dcfbf8 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === +function* g2(): Iterator number>> { +>g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1657, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) +>x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) + + yield function* () { + yield x => x.length; +>x : Symbol(x, Decl(generatorTypeCheck30.ts, 2, 13)) +>x : Symbol(x, Decl(generatorTypeCheck30.ts, 2, 13)) + + } () +} diff --git a/tests/baselines/reference/generatorTypeCheck30.types b/tests/baselines/reference/generatorTypeCheck30.types new file mode 100644 index 00000000000..2ed94dff531 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck30.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === +function* g2(): Iterator number>> { +>g2 : () => Iterator number>> +>Iterator : Iterator +>Iterable : Iterable +>x : string + + yield function* () { +>yield function* () { yield x => x.length; } () : any +>function* () { yield x => x.length; } () : IterableIterator<(x: any) => any> +>function* () { yield x => x.length; } : () => IterableIterator<(x: any) => any> + + yield x => x.length; +>yield x => x.length : any +>x => x.length : (x: any) => any +>x : any +>x.length : any +>x : any +>length : any + + } () +} diff --git a/tests/baselines/reference/generatorTypeCheck31.errors.txt b/tests/baselines/reference/generatorTypeCheck31.errors.txt new file mode 100644 index 00000000000..a0336b464a4 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck31.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts (1 errors) ==== + function* g2(): Iterator<() => Iterable<(x: string) => number>> { + yield function* () { + ~~~~~~~~~~~~~~ + yield x => x.length; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } () + ~~~~~~~~ +!!! error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck31.js b/tests/baselines/reference/generatorTypeCheck31.js new file mode 100644 index 00000000000..2037b0ec621 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck31.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck31.ts] +function* g2(): Iterator<() => Iterable<(x: string) => number>> { + yield function* () { + yield x => x.length; + } () +} + +//// [generatorTypeCheck31.js] +function* g2() { + yield function* () { + yield x => x.length; + }(); +} diff --git a/tests/baselines/reference/generatorTypeCheck32.errors.txt b/tests/baselines/reference/generatorTypeCheck32.errors.txt new file mode 100644 index 00000000000..6cd379fd47d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck32.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts(2,29): error TS1163: A 'yield' expression is only allowed in a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts (1 errors) ==== + var s: string; + var f: () => number = () => yield s; + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck32.js b/tests/baselines/reference/generatorTypeCheck32.js new file mode 100644 index 00000000000..5ec8e9214f3 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck32.js @@ -0,0 +1,7 @@ +//// [generatorTypeCheck32.ts] +var s: string; +var f: () => number = () => yield s; + +//// [generatorTypeCheck32.js] +var s; +var f = () => yield s; diff --git a/tests/baselines/reference/generatorTypeCheck33.js b/tests/baselines/reference/generatorTypeCheck33.js new file mode 100644 index 00000000000..256e4c94be7 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck33.js @@ -0,0 +1,15 @@ +//// [generatorTypeCheck33.ts] +function* g() { + yield 0; + function* g2() { + yield ""; + } +} + +//// [generatorTypeCheck33.js] +function* g() { + yield 0; + function* g2() { + yield ""; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck33.symbols b/tests/baselines/reference/generatorTypeCheck33.symbols new file mode 100644 index 00000000000..b1bda8808f2 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck33.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck33.ts, 0, 0)) + + yield 0; + function* g2() { +>g2 : Symbol(g2, Decl(generatorTypeCheck33.ts, 1, 12)) + + yield ""; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck33.types b/tests/baselines/reference/generatorTypeCheck33.types new file mode 100644 index 00000000000..f3b8af225d1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck33.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts === +function* g() { +>g : () => IterableIterator + + yield 0; +>yield 0 : any +>0 : number + + function* g2() { +>g2 : () => IterableIterator + + yield ""; +>yield "" : any +>"" : string + } +} diff --git a/tests/baselines/reference/generatorTypeCheck34.js b/tests/baselines/reference/generatorTypeCheck34.js new file mode 100644 index 00000000000..20b88b9a090 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck34.js @@ -0,0 +1,15 @@ +//// [generatorTypeCheck34.ts] +function* g() { + yield 0; + function* g2() { + return ""; + } +} + +//// [generatorTypeCheck34.js] +function* g() { + yield 0; + function* g2() { + return ""; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck34.symbols b/tests/baselines/reference/generatorTypeCheck34.symbols new file mode 100644 index 00000000000..343b68c3bda --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck34.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck34.ts, 0, 0)) + + yield 0; + function* g2() { +>g2 : Symbol(g2, Decl(generatorTypeCheck34.ts, 1, 12)) + + return ""; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types new file mode 100644 index 00000000000..35063e988eb --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts === +function* g() { +>g : () => IterableIterator + + yield 0; +>yield 0 : any +>0 : number + + function* g2() { +>g2 : () => IterableIterator + + return ""; +>"" : string + } +} diff --git a/tests/baselines/reference/generatorTypeCheck35.js b/tests/baselines/reference/generatorTypeCheck35.js new file mode 100644 index 00000000000..e2b1c10850a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck35.js @@ -0,0 +1,15 @@ +//// [generatorTypeCheck35.ts] +function* g() { + yield 0; + function g2() { + return ""; + } +} + +//// [generatorTypeCheck35.js] +function* g() { + yield 0; + function g2() { + return ""; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck35.symbols b/tests/baselines/reference/generatorTypeCheck35.symbols new file mode 100644 index 00000000000..43271b79e9e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck35.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck35.ts, 0, 0)) + + yield 0; + function g2() { +>g2 : Symbol(g2, Decl(generatorTypeCheck35.ts, 1, 12)) + + return ""; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck35.types b/tests/baselines/reference/generatorTypeCheck35.types new file mode 100644 index 00000000000..0bfc22ab3f0 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck35.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts === +function* g() { +>g : () => IterableIterator + + yield 0; +>yield 0 : any +>0 : number + + function g2() { +>g2 : () => string + + return ""; +>"" : string + } +} diff --git a/tests/baselines/reference/generatorTypeCheck36.js b/tests/baselines/reference/generatorTypeCheck36.js new file mode 100644 index 00000000000..a207860603b --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck36.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck36.ts] +function* g() { + yield yield 0; +} + +//// [generatorTypeCheck36.js] +function* g() { + yield yield 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck36.symbols b/tests/baselines/reference/generatorTypeCheck36.symbols new file mode 100644 index 00000000000..dc7eb37fe30 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck36.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck36.ts, 0, 0)) + + yield yield 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck36.types b/tests/baselines/reference/generatorTypeCheck36.types new file mode 100644 index 00000000000..110a4d3e02e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck36.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts === +function* g() { +>g : () => IterableIterator + + yield yield 0; +>yield yield 0 : any +>yield 0 : any +>0 : number +} diff --git a/tests/baselines/reference/generatorTypeCheck37.js b/tests/baselines/reference/generatorTypeCheck37.js new file mode 100644 index 00000000000..4c73dfe558a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck37.js @@ -0,0 +1,9 @@ +//// [generatorTypeCheck37.ts] +function* g() { + return yield yield 0; +} + +//// [generatorTypeCheck37.js] +function* g() { + return yield yield 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck37.symbols b/tests/baselines/reference/generatorTypeCheck37.symbols new file mode 100644 index 00000000000..8939c5382e2 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck37.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck37.ts, 0, 0)) + + return yield yield 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck37.types b/tests/baselines/reference/generatorTypeCheck37.types new file mode 100644 index 00000000000..e8611ec167a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck37.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts === +function* g() { +>g : () => IterableIterator + + return yield yield 0; +>yield yield 0 : any +>yield 0 : any +>0 : number +} diff --git a/tests/baselines/reference/generatorTypeCheck38.js b/tests/baselines/reference/generatorTypeCheck38.js new file mode 100644 index 00000000000..de5258db785 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck38.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck38.ts] +var yield; +function* g() { + yield 0; + var v: typeof yield; +} + +//// [generatorTypeCheck38.js] +var yield; +function* g() { + yield 0; + var v; +} diff --git a/tests/baselines/reference/generatorTypeCheck38.symbols b/tests/baselines/reference/generatorTypeCheck38.symbols new file mode 100644 index 00000000000..83410159b1a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck38.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck38.ts === +var yield; +>yield : Symbol(yield, Decl(generatorTypeCheck38.ts, 0, 3)) + +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck38.ts, 0, 10)) + + yield 0; + var v: typeof yield; +>v : Symbol(v, Decl(generatorTypeCheck38.ts, 3, 7)) +>yield : Symbol(yield, Decl(generatorTypeCheck38.ts, 0, 3)) +} diff --git a/tests/baselines/reference/generatorTypeCheck38.types b/tests/baselines/reference/generatorTypeCheck38.types new file mode 100644 index 00000000000..08503e8640f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck38.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck38.ts === +var yield; +>yield : any + +function* g() { +>g : () => IterableIterator + + yield 0; +>yield 0 : any +>0 : number + + var v: typeof yield; +>v : any +>yield : any +} diff --git a/tests/baselines/reference/generatorTypeCheck39.errors.txt b/tests/baselines/reference/generatorTypeCheck39.errors.txt new file mode 100644 index 00000000000..e44812cef0d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck39.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(5,5): error TS1129: Statement expected. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(5,6): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(5,16): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(5,22): error TS1005: ',' expected. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(9,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts (5 errors) ==== + function decorator(x: any) { + return y => { }; + } + function* g() { + @decorator(yield 0) + ~ +!!! error TS1129: Statement expected. + ~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~ +!!! error TS1005: ',' expected. + class C { + x = yield 0; + } + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck39.js b/tests/baselines/reference/generatorTypeCheck39.js new file mode 100644 index 00000000000..f1163b9af52 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck39.js @@ -0,0 +1,33 @@ +//// [generatorTypeCheck39.ts] +function decorator(x: any) { + return y => { }; +} +function* g() { + @decorator(yield 0) + class C { + x = yield 0; + } +} + +//// [generatorTypeCheck39.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); + switch (arguments.length) { + case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); + case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); + case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); + } +}; +function decorator(x) { + return y => { }; +} +function* g() { } +let C = class { + constructor() { + this.x = yield 0; + } +}; +Object.defineProperty(C, "name", { value: "C", configurable: true }); +C = __decorate([ + decorator(yield, 0) +], C); diff --git a/tests/baselines/reference/generatorTypeCheck4.js b/tests/baselines/reference/generatorTypeCheck4.js new file mode 100644 index 00000000000..8c0d7aeddd1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck4.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck4.ts] +function* g1(): {} { } + +//// [generatorTypeCheck4.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck4.symbols b/tests/baselines/reference/generatorTypeCheck4.symbols new file mode 100644 index 00000000000..fb7cd93e0d9 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck4.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck4.ts === +function* g1(): {} { } +>g1 : Symbol(g1, Decl(generatorTypeCheck4.ts, 0, 0)) + diff --git a/tests/baselines/reference/generatorTypeCheck4.types b/tests/baselines/reference/generatorTypeCheck4.types new file mode 100644 index 00000000000..c90fda0c0fc --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck4.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck4.ts === +function* g1(): {} { } +>g1 : () => {} + diff --git a/tests/baselines/reference/generatorTypeCheck40.errors.txt b/tests/baselines/reference/generatorTypeCheck40.errors.txt new file mode 100644 index 00000000000..4d3880ad4aa --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck40.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,21): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts (2 errors) ==== + function* g() { + class C extends (yield 0) { } + ~ +!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration. + ~~~~~~~~~ +!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck40.js b/tests/baselines/reference/generatorTypeCheck40.js new file mode 100644 index 00000000000..fe9bb797d77 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck40.js @@ -0,0 +1,10 @@ +//// [generatorTypeCheck40.ts] +function* g() { + class C extends (yield 0) { } +} + +//// [generatorTypeCheck40.js] +function* g() { + class C extends (yield 0) { + } +} diff --git a/tests/baselines/reference/generatorTypeCheck41.js b/tests/baselines/reference/generatorTypeCheck41.js new file mode 100644 index 00000000000..51c5ce3d416 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck41.js @@ -0,0 +1,13 @@ +//// [generatorTypeCheck41.ts] +function* g() { + let x = { + [yield 0]: 0 + } +} + +//// [generatorTypeCheck41.js] +function* g() { + let x = { + [yield 0]: 0 + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck41.symbols b/tests/baselines/reference/generatorTypeCheck41.symbols new file mode 100644 index 00000000000..9111affa875 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck41.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck41.ts, 0, 0)) + + let x = { +>x : Symbol(x, Decl(generatorTypeCheck41.ts, 1, 7)) + + [yield 0]: 0 + } +} diff --git a/tests/baselines/reference/generatorTypeCheck41.types b/tests/baselines/reference/generatorTypeCheck41.types new file mode 100644 index 00000000000..926aef95ce5 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck41.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts === +function* g() { +>g : () => IterableIterator + + let x = { +>x : {} +>{ [yield 0]: 0 } : {} + + [yield 0]: 0 +>yield 0 : any +>0 : number +>0 : number + } +} diff --git a/tests/baselines/reference/generatorTypeCheck42.js b/tests/baselines/reference/generatorTypeCheck42.js new file mode 100644 index 00000000000..c58802b1a81 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck42.js @@ -0,0 +1,16 @@ +//// [generatorTypeCheck42.ts] +function* g() { + let x = { + [yield 0]() { + + } + } +} + +//// [generatorTypeCheck42.js] +function* g() { + let x = { + [yield 0]() { + } + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck42.symbols b/tests/baselines/reference/generatorTypeCheck42.symbols new file mode 100644 index 00000000000..a49534fd211 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck42.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck42.ts, 0, 0)) + + let x = { +>x : Symbol(x, Decl(generatorTypeCheck42.ts, 1, 7)) + + [yield 0]() { + + } + } +} diff --git a/tests/baselines/reference/generatorTypeCheck42.types b/tests/baselines/reference/generatorTypeCheck42.types new file mode 100644 index 00000000000..855c4697f40 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck42.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts === +function* g() { +>g : () => IterableIterator + + let x = { +>x : {} +>{ [yield 0]() { } } : {} + + [yield 0]() { +>yield 0 : any +>0 : number + + } + } +} diff --git a/tests/baselines/reference/generatorTypeCheck43.js b/tests/baselines/reference/generatorTypeCheck43.js new file mode 100644 index 00000000000..c7dc2dad393 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck43.js @@ -0,0 +1,16 @@ +//// [generatorTypeCheck43.ts] +function* g() { + let x = { + *[yield 0]() { + + } + } +} + +//// [generatorTypeCheck43.js] +function* g() { + let x = { + *[yield 0]() { + } + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck43.symbols b/tests/baselines/reference/generatorTypeCheck43.symbols new file mode 100644 index 00000000000..f5f7b6c359f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck43.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck43.ts, 0, 0)) + + let x = { +>x : Symbol(x, Decl(generatorTypeCheck43.ts, 1, 7)) + + *[yield 0]() { + + } + } +} diff --git a/tests/baselines/reference/generatorTypeCheck43.types b/tests/baselines/reference/generatorTypeCheck43.types new file mode 100644 index 00000000000..50fc7e30c86 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck43.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts === +function* g() { +>g : () => IterableIterator + + let x = { +>x : {} +>{ *[yield 0]() { } } : {} + + *[yield 0]() { +>yield 0 : any +>0 : number + + } + } +} diff --git a/tests/baselines/reference/generatorTypeCheck44.js b/tests/baselines/reference/generatorTypeCheck44.js new file mode 100644 index 00000000000..238998ad974 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck44.js @@ -0,0 +1,17 @@ +//// [generatorTypeCheck44.ts] +function* g() { + let x = { + get [yield 0]() { + return 0; + } + } +} + +//// [generatorTypeCheck44.js] +function* g() { + let x = { + get [yield 0]() { + return 0; + } + }; +} diff --git a/tests/baselines/reference/generatorTypeCheck44.symbols b/tests/baselines/reference/generatorTypeCheck44.symbols new file mode 100644 index 00000000000..b6606064c43 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck44.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts === +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck44.ts, 0, 0)) + + let x = { +>x : Symbol(x, Decl(generatorTypeCheck44.ts, 1, 7)) + + get [yield 0]() { + return 0; + } + } +} diff --git a/tests/baselines/reference/generatorTypeCheck44.types b/tests/baselines/reference/generatorTypeCheck44.types new file mode 100644 index 00000000000..2fc67f90556 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck44.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts === +function* g() { +>g : () => IterableIterator + + let x = { +>x : {} +>{ get [yield 0]() { return 0; } } : {} + + get [yield 0]() { +>yield 0 : any +>0 : number + + return 0; +>0 : number + } + } +} diff --git a/tests/baselines/reference/generatorTypeCheck45.js b/tests/baselines/reference/generatorTypeCheck45.js new file mode 100644 index 00000000000..20f64e53c9d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck45.js @@ -0,0 +1,7 @@ +//// [generatorTypeCheck45.ts] +declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T): T; + +foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, should be string + +//// [generatorTypeCheck45.js] +foo("", function* () { yield x => x.length; }, p => undefined); // T is fixed, should be string diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols new file mode 100644 index 00000000000..b53eb9c9211 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck45.ts === +declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T): T; +>foo : Symbol(foo, Decl(generatorTypeCheck45.ts, 0, 0)) +>T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) +>U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) +>x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) +>T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) +>fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1657, 1)) +>x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) +>T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) +>U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) +>fun2 : Symbol(fun2, Decl(generatorTypeCheck45.ts, 0, 66)) +>y : Symbol(y, Decl(generatorTypeCheck45.ts, 0, 74)) +>U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) +>T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) +>T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) + +foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, should be string +>foo : Symbol(foo, Decl(generatorTypeCheck45.ts, 0, 0)) +>x : Symbol(x, Decl(generatorTypeCheck45.ts, 2, 28)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(generatorTypeCheck45.ts, 2, 28)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>p : Symbol(p, Decl(generatorTypeCheck45.ts, 2, 45)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/generatorTypeCheck45.types b/tests/baselines/reference/generatorTypeCheck45.types new file mode 100644 index 00000000000..7ea442420d6 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck45.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck45.ts === +declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T): T; +>foo : (x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T) => T +>T : T +>U : U +>x : T +>T : T +>fun : () => Iterator<(x: T) => U> +>Iterator : Iterator +>x : T +>T : T +>U : U +>fun2 : (y: U) => T +>y : U +>U : U +>T : T +>T : T + +foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, should be string +>foo("", function* () { yield x => x.length }, p => undefined) : string +>foo : (x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T) => T +>"" : string +>function* () { yield x => x.length } : () => IterableIterator<(x: string) => number> +>yield x => x.length : any +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number +>p => undefined : (p: number) => any +>p : number +>undefined : undefined + diff --git a/tests/baselines/reference/generatorTypeCheck46.js b/tests/baselines/reference/generatorTypeCheck46.js new file mode 100644 index 00000000000..0270f9e3a33 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck46.js @@ -0,0 +1,19 @@ +//// [generatorTypeCheck46.ts] +declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T): T; + +foo("", function* () { + yield* { + *[Symbol.iterator]() { + yield x => x.length + } + } +}, p => undefined); // T is fixed, should be string + +//// [generatorTypeCheck46.js] +foo("", function* () { + yield* { + *[Symbol.iterator]() { + yield x => x.length; + } + }; +}, p => undefined); // T is fixed, should be string diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols new file mode 100644 index 00000000000..4ccdfd28a4f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck46.ts === +declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T): T; +>foo : Symbol(foo, Decl(generatorTypeCheck46.ts, 0, 0)) +>T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) +>U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) +>x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) +>T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) +>fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) +>x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) +>T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) +>U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) +>fun2 : Symbol(fun2, Decl(generatorTypeCheck46.ts, 0, 66)) +>y : Symbol(y, Decl(generatorTypeCheck46.ts, 0, 74)) +>U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) +>T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) +>T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) + +foo("", function* () { +>foo : Symbol(foo, Decl(generatorTypeCheck46.ts, 0, 0)) + + yield* { + *[Symbol.iterator]() { +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) + + yield x => x.length +>x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + } + } +}, p => undefined); // T is fixed, should be string +>p : Symbol(p, Decl(generatorTypeCheck46.ts, 8, 2)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/generatorTypeCheck46.types b/tests/baselines/reference/generatorTypeCheck46.types new file mode 100644 index 00000000000..daf0d67b6ec --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck46.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck46.ts === +declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T): T; +>foo : (x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T) => T +>T : T +>U : U +>x : T +>T : T +>fun : () => Iterable<(x: T) => U> +>Iterable : Iterable +>x : T +>T : T +>U : U +>fun2 : (y: U) => T +>y : U +>U : U +>T : T +>T : T + +foo("", function* () { +>foo("", function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }}, p => undefined) : string +>foo : (x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T) => T +>"" : string +>function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => IterableIterator<(x: string) => number> + + yield* { +>yield* { *[Symbol.iterator]() { yield x => x.length } } : any +>{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): IterableIterator<(x: string) => number>; } + + *[Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + yield x => x.length +>yield x => x.length : any +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + } + } +}, p => undefined); // T is fixed, should be string +>p => undefined : (p: number) => any +>p : number +>undefined : undefined + diff --git a/tests/baselines/reference/generatorTypeCheck47.errors.txt b/tests/baselines/reference/generatorTypeCheck47.errors.txt new file mode 100644 index 00000000000..f5264f7ce96 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck47.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts(2,9): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts (1 errors) ==== + + function* g() { } + ~ +!!! error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck47.js b/tests/baselines/reference/generatorTypeCheck47.js new file mode 100644 index 00000000000..b06fb96b435 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck47.js @@ -0,0 +1,6 @@ +//// [generatorTypeCheck47.ts] + +function* g() { } + +//// [generatorTypeCheck47.js] +function* g() { } diff --git a/tests/baselines/reference/generatorTypeCheck48.errors.txt b/tests/baselines/reference/generatorTypeCheck48.errors.txt new file mode 100644 index 00000000000..c91626cd813 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck48.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts(2,9): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts (1 errors) ==== + + function* g() { + ~ +!!! error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + yield; + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck48.js b/tests/baselines/reference/generatorTypeCheck48.js new file mode 100644 index 00000000000..579d6dcf0e1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck48.js @@ -0,0 +1,10 @@ +//// [generatorTypeCheck48.ts] + +function* g() { + yield; +} + +//// [generatorTypeCheck48.js] +function* g() { + yield; +} diff --git a/tests/baselines/reference/generatorTypeCheck49.js b/tests/baselines/reference/generatorTypeCheck49.js new file mode 100644 index 00000000000..b544c7e4225 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck49.js @@ -0,0 +1,10 @@ +//// [generatorTypeCheck49.ts] + +function* g() { + yield 0; +} + +//// [generatorTypeCheck49.js] +function* g() { + yield 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck49.symbols b/tests/baselines/reference/generatorTypeCheck49.symbols new file mode 100644 index 00000000000..d24deed3d80 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck49.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts === + +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck49.ts, 0, 0)) + + yield 0; +} diff --git a/tests/baselines/reference/generatorTypeCheck49.types b/tests/baselines/reference/generatorTypeCheck49.types new file mode 100644 index 00000000000..f56cca33438 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck49.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts === + +function* g() { +>g : () => IterableIterator + + yield 0; +>yield 0 : any +>0 : number +} diff --git a/tests/baselines/reference/generatorTypeCheck5.js b/tests/baselines/reference/generatorTypeCheck5.js new file mode 100644 index 00000000000..1acfc110578 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck5.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck5.ts] +function* g1(): any { } + +//// [generatorTypeCheck5.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck5.symbols b/tests/baselines/reference/generatorTypeCheck5.symbols new file mode 100644 index 00000000000..3f889e3cadf --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck5.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck5.ts === +function* g1(): any { } +>g1 : Symbol(g1, Decl(generatorTypeCheck5.ts, 0, 0)) + diff --git a/tests/baselines/reference/generatorTypeCheck5.types b/tests/baselines/reference/generatorTypeCheck5.types new file mode 100644 index 00000000000..6918a00663c --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck5.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck5.ts === +function* g1(): any { } +>g1 : () => any + diff --git a/tests/baselines/reference/generatorTypeCheck50.js b/tests/baselines/reference/generatorTypeCheck50.js new file mode 100644 index 00000000000..856e3867ab6 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck50.js @@ -0,0 +1,10 @@ +//// [generatorTypeCheck50.ts] + +function* g() { + yield yield; +} + +//// [generatorTypeCheck50.js] +function* g() { + yield yield; +} diff --git a/tests/baselines/reference/generatorTypeCheck50.symbols b/tests/baselines/reference/generatorTypeCheck50.symbols new file mode 100644 index 00000000000..412a1ac1ea7 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck50.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts === + +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck50.ts, 0, 0)) + + yield yield; +} diff --git a/tests/baselines/reference/generatorTypeCheck50.types b/tests/baselines/reference/generatorTypeCheck50.types new file mode 100644 index 00000000000..342d7406dce --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck50.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts === + +function* g() { +>g : () => IterableIterator + + yield yield; +>yield yield : any +>yield : any +} diff --git a/tests/baselines/reference/generatorTypeCheck51.errors.txt b/tests/baselines/reference/generatorTypeCheck51.errors.txt new file mode 100644 index 00000000000..f4fc5723a5e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck51.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts(2,9): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts (1 errors) ==== + + function* g() { + ~ +!!! error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + function* h() { + yield 0; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck51.js b/tests/baselines/reference/generatorTypeCheck51.js new file mode 100644 index 00000000000..f3519065c3d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck51.js @@ -0,0 +1,14 @@ +//// [generatorTypeCheck51.ts] + +function* g() { + function* h() { + yield 0; + } +} + +//// [generatorTypeCheck51.js] +function* g() { + function* h() { + yield 0; + } +} diff --git a/tests/baselines/reference/generatorTypeCheck6.errors.txt b/tests/baselines/reference/generatorTypeCheck6.errors.txt new file mode 100644 index 00000000000..35f2cc2016d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck6.ts(1,17): error TS2322: Type 'IterableIterator' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck6.ts (1 errors) ==== + function* g1(): number { } + ~~~~~~ +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck6.js b/tests/baselines/reference/generatorTypeCheck6.js new file mode 100644 index 00000000000..de0f92f77f1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck6.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck6.ts] +function* g1(): number { } + +//// [generatorTypeCheck6.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck7.errors.txt b/tests/baselines/reference/generatorTypeCheck7.errors.txt new file mode 100644 index 00000000000..2653ecf8cd5 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck7.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts(4,17): error TS2322: Type 'IterableIterator' is not assignable to type 'WeirdIter'. + Property 'hello' is missing in type 'IterableIterator'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts (1 errors) ==== + interface WeirdIter extends IterableIterator { + hello: string; + } + function* g1(): WeirdIter { } + ~~~~~~~~~ +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'WeirdIter'. +!!! error TS2322: Property 'hello' is missing in type 'IterableIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck7.js b/tests/baselines/reference/generatorTypeCheck7.js new file mode 100644 index 00000000000..c2d47f9483c --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck7.js @@ -0,0 +1,8 @@ +//// [generatorTypeCheck7.ts] +interface WeirdIter extends IterableIterator { + hello: string; +} +function* g1(): WeirdIter { } + +//// [generatorTypeCheck7.js] +function* g1() { } diff --git a/tests/baselines/reference/generatorTypeCheck8.errors.txt b/tests/baselines/reference/generatorTypeCheck8.errors.txt new file mode 100644 index 00000000000..cedfecda60b --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck8.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error TS2322: Type 'IterableIterator' is not assignable to type 'BadGenerator'. + Types of property 'next' are incompatible. + Type '(value?: any) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts (1 errors) ==== + interface BadGenerator extends Iterator, Iterable { } + function* g3(): BadGenerator { } + ~~~~~~~~~~~~ +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'BadGenerator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '(value?: any) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck8.js b/tests/baselines/reference/generatorTypeCheck8.js new file mode 100644 index 00000000000..97058c2eaa0 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck8.js @@ -0,0 +1,6 @@ +//// [generatorTypeCheck8.ts] +interface BadGenerator extends Iterator, Iterable { } +function* g3(): BadGenerator { } + +//// [generatorTypeCheck8.js] +function* g3() { } diff --git a/tests/baselines/reference/generatorTypeCheck9.errors.txt b/tests/baselines/reference/generatorTypeCheck9.errors.txt new file mode 100644 index 00000000000..95e3229fca9 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck9.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck9.ts(1,17): error TS2503: A generator cannot have a 'void' type annotation. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck9.ts (1 errors) ==== + function* g3(): void { } + ~~~~ +!!! error TS2503: A generator cannot have a 'void' type annotation. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck9.js b/tests/baselines/reference/generatorTypeCheck9.js new file mode 100644 index 00000000000..3bdeec0a4a9 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck9.js @@ -0,0 +1,5 @@ +//// [generatorTypeCheck9.ts] +function* g3(): void { } + +//// [generatorTypeCheck9.js] +function* g3() { } diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts new file mode 100644 index 00000000000..c01d7f5340f --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g1(): Iterator { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts new file mode 100644 index 00000000000..813ea07075d --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g(): IterableIterator { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts new file mode 100644 index 00000000000..e77ec3d911c --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g(): IterableIterator { + return 0; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts new file mode 100644 index 00000000000..6f602a23981 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g(): IterableIterator { + return ""; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts new file mode 100644 index 00000000000..a21d9e8ab63 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts @@ -0,0 +1,5 @@ +//@target: ES6 +function* g(): IterableIterator { + yield 0; + return ""; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts new file mode 100644 index 00000000000..74761b14772 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts @@ -0,0 +1,5 @@ +//@target: ES6 +function* g() { + yield 0; + return ""; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts new file mode 100644 index 00000000000..b810a13aa55 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g() { + return ""; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts new file mode 100644 index 00000000000..06d3de394ef --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g() { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck17.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck17.ts new file mode 100644 index 00000000000..15d760b7949 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck17.ts @@ -0,0 +1,7 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +function* g(): IterableIterator { + yield; + yield new Bar; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck18.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck18.ts new file mode 100644 index 00000000000..d63e69d1b86 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck18.ts @@ -0,0 +1,7 @@ +//@target: ES6 +class Foo { x: number } +class Baz { z: number } +function* g(): IterableIterator { + yield; + yield new Baz; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck19.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck19.ts new file mode 100644 index 00000000000..e9b2cc29b27 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck19.ts @@ -0,0 +1,7 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +function* g(): IterableIterator { + yield; + yield * [new Bar]; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts new file mode 100644 index 00000000000..b66b3aab356 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g1(): Iterable { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck20.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck20.ts new file mode 100644 index 00000000000..5cb029205da --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck20.ts @@ -0,0 +1,7 @@ +//@target: ES6 +class Foo { x: number } +class Baz { z: number } +function* g(): IterableIterator { + yield; + yield * [new Baz]; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck21.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck21.ts new file mode 100644 index 00000000000..991f082141e --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck21.ts @@ -0,0 +1,7 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +function* g(): IterableIterator { + yield; + yield * new Bar; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts new file mode 100644 index 00000000000..0359ba3c4c9 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts @@ -0,0 +1,11 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +function* g3() { + yield; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts new file mode 100644 index 00000000000..20c98e9e7e7 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts @@ -0,0 +1,12 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +function* g3() { + yield; + yield new Foo; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts new file mode 100644 index 00000000000..9b383d8a02a --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts @@ -0,0 +1,12 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +function* g3() { + yield; + yield * [new Foo]; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts new file mode 100644 index 00000000000..9a942f174ae --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts @@ -0,0 +1,11 @@ +//@target: ES6 +class Foo { x: number } +class Bar extends Foo { y: string } +class Baz { z: number } +var g3: () => Iterable = function* () { + yield; + yield new Bar; + yield new Baz; + yield *[new Bar]; + yield *[new Baz]; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts new file mode 100644 index 00000000000..334d21e3833 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function* g(): IterableIterator<(x: string) => number> { + yield x => x.length; + yield *[x => x.length]; + return x => x.length; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts new file mode 100644 index 00000000000..f501aa407f8 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function* g(): IterableIterator<(x: string) => number> { + yield * function* () { + yield x => x.length; + } (); +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts new file mode 100644 index 00000000000..7a190e5bd45 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts @@ -0,0 +1,8 @@ +//@target: ES6 +function* g(): IterableIterator<(x: string) => number> { + yield * { + *[Symbol.iterator]() { + yield x => x.length; + } + }; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts new file mode 100644 index 00000000000..be99cf02441 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function* g2(): Iterator number>> { + yield function* () { + yield x => x.length; + } () +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts new file mode 100644 index 00000000000..9b0e6f5ef59 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g1(): IterableIterator { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts new file mode 100644 index 00000000000..be99cf02441 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function* g2(): Iterator number>> { + yield function* () { + yield x => x.length; + } () +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts new file mode 100644 index 00000000000..f4082f7b46f --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function* g2(): Iterator<() => Iterable<(x: string) => number>> { + yield function* () { + yield x => x.length; + } () +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts new file mode 100644 index 00000000000..f975eefa841 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var s: string; +var f: () => number = () => yield s; \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts new file mode 100644 index 00000000000..4bb94263831 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts @@ -0,0 +1,7 @@ +//@target: ES6 +function* g() { + yield 0; + function* g2() { + yield ""; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts new file mode 100644 index 00000000000..3afd5617a08 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts @@ -0,0 +1,7 @@ +//@target: ES6 +function* g() { + yield 0; + function* g2() { + return ""; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts new file mode 100644 index 00000000000..9adab4c0ed9 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts @@ -0,0 +1,7 @@ +//@target: ES6 +function* g() { + yield 0; + function g2() { + return ""; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts new file mode 100644 index 00000000000..e304dda4828 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g() { + yield yield 0; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts new file mode 100644 index 00000000000..f9fe46f4285 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g() { + return yield yield 0; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck38.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck38.ts new file mode 100644 index 00000000000..03bb28ef0ec --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck38.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var yield; +function* g() { + yield 0; + var v: typeof yield; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts new file mode 100644 index 00000000000..b578f8f2399 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts @@ -0,0 +1,10 @@ +//@target: ES6 +function decorator(x: any) { + return y => { }; +} +function* g() { + @decorator(yield 0) + class C { + x = yield 0; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck4.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck4.ts new file mode 100644 index 00000000000..160aee0d709 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck4.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g1(): {} { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts new file mode 100644 index 00000000000..2dee3dedf02 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts @@ -0,0 +1,4 @@ +//@target: ES6 +function* g() { + class C extends (yield 0) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts new file mode 100644 index 00000000000..caa4eed0747 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function* g() { + let x = { + [yield 0]: 0 + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts new file mode 100644 index 00000000000..4fe9ddced96 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts @@ -0,0 +1,8 @@ +//@target: ES6 +function* g() { + let x = { + [yield 0]() { + + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts new file mode 100644 index 00000000000..e2b72f4b790 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts @@ -0,0 +1,8 @@ +//@target: ES6 +function* g() { + let x = { + *[yield 0]() { + + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts new file mode 100644 index 00000000000..e7146fa6915 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts @@ -0,0 +1,8 @@ +//@target: ES6 +function* g() { + let x = { + get [yield 0]() { + return 0; + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck45.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck45.ts new file mode 100644 index 00000000000..ce0822da412 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck45.ts @@ -0,0 +1,4 @@ +//@target: ES6 +declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T): T; + +foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, should be string \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck46.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck46.ts new file mode 100644 index 00000000000..53c5c7131db --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck46.ts @@ -0,0 +1,10 @@ +//@target: ES6 +declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T): T; + +foo("", function* () { + yield* { + *[Symbol.iterator]() { + yield x => x.length + } + } +}, p => undefined); // T is fixed, should be string \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts new file mode 100644 index 00000000000..6eb9fa74a6e --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts @@ -0,0 +1,4 @@ +//@target: ES6 +//@noImplicitAny: true + +function* g() { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts new file mode 100644 index 00000000000..65885f28a5b --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts @@ -0,0 +1,6 @@ +//@target: ES6 +//@noImplicitAny: true + +function* g() { + yield; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts new file mode 100644 index 00000000000..956704d8a4c --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts @@ -0,0 +1,6 @@ +//@target: ES6 +//@noImplicitAny: true + +function* g() { + yield 0; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck5.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck5.ts new file mode 100644 index 00000000000..c1b659604ba --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck5.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g1(): any { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts new file mode 100644 index 00000000000..1261d4b268b --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts @@ -0,0 +1,6 @@ +//@target: ES6 +//@noImplicitAny: true + +function* g() { + yield yield; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts new file mode 100644 index 00000000000..be88b9b99aa --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts @@ -0,0 +1,8 @@ +//@target: ES6 +//@noImplicitAny: true + +function* g() { + function* h() { + yield 0; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck6.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck6.ts new file mode 100644 index 00000000000..8f61f87db83 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck6.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g1(): number { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts new file mode 100644 index 00000000000..59e9b489d5f --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts @@ -0,0 +1,5 @@ +//@target: ES6 +interface WeirdIter extends IterableIterator { + hello: string; +} +function* g1(): WeirdIter { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts new file mode 100644 index 00000000000..659406ee999 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts @@ -0,0 +1,3 @@ +//@target: ES6 +interface BadGenerator extends Iterator, Iterable { } +function* g3(): BadGenerator { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck9.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck9.ts new file mode 100644 index 00000000000..f4386c70feb --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck9.ts @@ -0,0 +1,2 @@ +//@target: ES6 +function* g3(): void { } \ No newline at end of file From 5fcc4e9a4952d220559cf5f72e61683ea9c6fcc5 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 4 May 2015 16:44:26 -0700 Subject: [PATCH 070/402] Remove Generator interface from ES6 lib. We may need to add a better typing later --- src/lib/es6.d.ts | 8 - ...owFunctionWhenUsingArguments14_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments15_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments16_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments17_ES6.symbols | 2 +- ...owFunctionWhenUsingArguments18_ES6.symbols | 2 +- tests/baselines/reference/for-of37.symbols | 2 +- tests/baselines/reference/for-of38.symbols | 2 +- tests/baselines/reference/for-of40.symbols | 2 +- tests/baselines/reference/for-of45.symbols | 2 +- tests/baselines/reference/for-of50.symbols | 2 +- .../reference/iterableArrayPattern30.symbols | 2 +- tests/baselines/reference/typedArrays.symbols | 324 +++++++++--------- 13 files changed, 173 insertions(+), 181 deletions(-) diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index fb0c64f8495..db3569f2018 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -500,14 +500,6 @@ interface GeneratorFunctionConstructor { } declare var GeneratorFunction: GeneratorFunctionConstructor; -interface Generator extends IterableIterator { - next(value?: any): IteratorResult; - throw(exception: any): IteratorResult; - return(value: T): IteratorResult; - [Symbol.iterator](): Generator; - [Symbol.toStringTag]: string; -} - interface Math { /** * Returns the number of leading zero bits in the 32-bit binary representation of a number. diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 18e1063f1e6..47bcda2d856 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1686, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 6885b359416..4b962d87d96 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1686, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index ae6be6f7951..ca584a34f82 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1686, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index c8bf211897a..7283c4d4f3b 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1686, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index cc867dd2c72..eee5f867802 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1686, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 93f6c4f7dd6..f9971c1c49c 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1859, 1), Decl(lib.d.ts, 1881, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index fab42d91724..b3495f019e6 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1859, 1), Decl(lib.d.ts, 1881, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index 1cd3538f987..ca6db1fb169 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1859, 1), Decl(lib.d.ts, 1881, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 9fda4cb4e0a..7d2b56346f9 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1859, 1), Decl(lib.d.ts, 1881, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index c176e1aca0c..8252ee872ad 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1859, 1), Decl(lib.d.ts, 1881, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 0f50713b43d..565a5075eda 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1859, 1), Decl(lib.d.ts, 1881, 11)) diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 27b72cc54f1..2d8108e9088 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -242,65 +242,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2381, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2381, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2373, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2373, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2671, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2671, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2663, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2663, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3251, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3251, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3243, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3243, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3541, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3541, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3533, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3533, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3831, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3831, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4121, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4121, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4113, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4113, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4411, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4411, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4403, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4403, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4701, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4701, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4693, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4693, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2961, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2961, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2953, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2953, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2099, 42), Decl(lib.d.ts, 2389, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2379, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2389, 44), Decl(lib.d.ts, 2679, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2669, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2969, 60), Decl(lib.d.ts, 3259, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3249, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3259, 46), Decl(lib.d.ts, 3549, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3539, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3549, 48), Decl(lib.d.ts, 3839, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3829, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3839, 46), Decl(lib.d.ts, 4129, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4119, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4129, 48), Decl(lib.d.ts, 4419, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4409, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4419, 50), Decl(lib.d.ts, 4709, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4699, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2679, 46), Decl(lib.d.ts, 2969, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2959, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) From 58e21caa4a2c3636a23f7ae5be571d0794d97f47 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 4 May 2015 16:53:34 -0700 Subject: [PATCH 071/402] Removed 'fileMetadataNames'. --- src/harness/harness.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ad91c4e28d9..bc0ddbce144 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1509,15 +1509,6 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines - // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", - "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", - "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", - "errortruncation", "usecasesensitivefilenames", "preserveconstenums", - "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "separatecompilation", "inlinesourcemap", "maproot", "sourceroot", - "inlinesources", "emitdecoratormetadata"]; - function extractCompilerSettings(content: string): CompilerSetting[] { var opts: CompilerSetting[] = []; @@ -1551,10 +1542,8 @@ module Harness { if (testMetaData) { // Comment line, check for global/file @options and record them optionRegex.lastIndex = 0; - var fileNameIndex = fileMetadataNames.indexOf(testMetaData[1].toLowerCase()); - if (fileNameIndex === -1) { - throw new Error('Unrecognized metadata name "' + testMetaData[1] + '". Available file metadata names are: ' + fileMetadataNames.join(', ')); - } else if (fileNameIndex === 0) { + var metaDataName = testMetaData[1].toLowerCase(); + if (metaDataName === "filename") { currentFileOptions[testMetaData[1]] = testMetaData[2]; } else { continue; From d2857751b250ecc3041c4fba230ac8bc379478f4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 5 May 2015 17:27:31 -0700 Subject: [PATCH 072/402] Always include 'lib.d.ts' last in tests unless '@noLib' is specified. --- src/compiler/checker.ts | 2 ++ src/harness/harness.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6b889e58e58..47e1828711a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10958,6 +10958,8 @@ module ts { function checkSourceFile(node: SourceFile) { let start = new Date().getTime(); + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. let skipCheck = node.hasNoDefaultLib && compilerOptions.noLibCheck; if (!skipCheck) { checkSourceFileWorker(node); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 024a9748aa3..4aa2775b243 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -962,12 +962,19 @@ module Harness { var includeBuiltFiles: { unitName: string; content: string }[] = []; var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; - this.settings.forEach(setOptionForSetting); + this.settings.forEach(setCompilerOptionForSetting); var fileOutputs: GeneratedFile[] = []; var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); - var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles), + if (!options.noLib) { + // Unless the user doesn't want a default lib at all, + // always push the default lib in *last* to normalize the type/symbol baselines. + programFiles.push(defaultLibFileName); + } + + var program = ts.createProgram(programFiles, options, + createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles), (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine)); @@ -986,8 +993,8 @@ module Harness { // reset what newline means in case the last test changed it ts.sys.newLine = newLine; return options; - - function setOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { + + function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { switch (setting.flag.toLowerCase()) { // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" case "module": From 8add21446b1cf7f13d52e0a2d3aa2c3cb6d56691 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 5 May 2015 17:29:49 -0700 Subject: [PATCH 073/402] Update tests to use '@noLib: true'. --- tests/cases/compiler/noDefaultLib.ts | 1 + tests/cases/conformance/decorators/1.0lib-noErrors.ts | 1 + .../parser/ecmascript5/RegressionTests/parser509698.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/cases/compiler/noDefaultLib.ts b/tests/cases/compiler/noDefaultLib.ts index 92c8a63fc64..718f5e216b8 100644 --- a/tests/cases/compiler/noDefaultLib.ts +++ b/tests/cases/compiler/noDefaultLib.ts @@ -1,3 +1,4 @@ +// @noLib: true /// var x; diff --git a/tests/cases/conformance/decorators/1.0lib-noErrors.ts b/tests/cases/conformance/decorators/1.0lib-noErrors.ts index 6966e3e70d0..c070dd6966c 100644 --- a/tests/cases/conformance/decorators/1.0lib-noErrors.ts +++ b/tests/cases/conformance/decorators/1.0lib-noErrors.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @noLib: true /* ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use diff --git a/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts b/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts index f33abc85b53..bf795084568 100644 --- a/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts +++ b/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts @@ -1,3 +1,4 @@ +// @noLib: true ///